Skip to content

Commit

Permalink
Updating tests to not affect other ones when run from a group
Browse files Browse the repository at this point in the history
Adding NoCrossContamination group
Shortening group class names
Renaming lib_controller group
Updating test imports to include the core AppController by default
Some cosmetics




git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8123 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
mariuswilms committed Mar 21, 2009
1 parent fc7773f commit fd7d671
Show file tree
Hide file tree
Showing 51 changed files with 536 additions and 239 deletions.
14 changes: 13 additions & 1 deletion cake/tests/cases/basics.test.php
Expand Up @@ -40,7 +40,19 @@ class BasicsTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->_localePaths = Configure::read('localePaths');
Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
$this->_language = Configure::read('Config.language');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('localePaths', $this->_localePaths);
Configure::write('Config.language', $this->_language);
}
/**
* testHttpBase method
Expand Down Expand Up @@ -119,7 +131,7 @@ function testEnv() {
* @return void
*/
function testUses() {
$this->skipIf(class_exists('Security') || class_exists('Sanitize'), 'Security and/or Sanitize class already loaded');
$this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded');

$this->assertFalse(class_exists('Security'));
$this->assertFalse(class_exists('Sanitize'));
Expand Down
11 changes: 5 additions & 6 deletions cake/tests/cases/console/cake.test.php
Expand Up @@ -123,10 +123,9 @@ class ShellDispatcherTest extends UnitTestCase {
* @return void
*/
function setUp() {
if (!isset($this->pluginPaths)) {
$this->pluginPaths = Configure::read('pluginPaths');
$this->shellPaths = Configure::read('shellPaths');
}
$this->_pluginPaths = Configure::read('pluginPaths');
$this->_shellPaths = Configure::read('shellPaths');

Configure::write('pluginPaths', array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
));
Expand All @@ -142,8 +141,8 @@ function setUp() {
* @return void
*/
function tearDown() {
Configure::write('pluginPaths', $this->pluginPaths);
Configure::write('shellPaths', $this->shellPaths);
Configure::write('pluginPaths', $this->_pluginPaths);
Configure::write('shellPaths', $this->_shellPaths);
}
/**
* testParseParams method
Expand Down
5 changes: 4 additions & 1 deletion cake/tests/cases/console/libs/shell.test.php
Expand Up @@ -78,7 +78,10 @@ class ShellTest extends CakeTestCase {
* @var array
* @access public
*/
var $fixtures = array('core.post', 'core.comment');
var $fixtures = array(
'core.post', 'core.comment', 'core.article', 'core.user',
'core.tag', 'core.articles_tag', 'core.attachment'
);
/**
* setUp method
*
Expand Down
35 changes: 29 additions & 6 deletions cake/tests/cases/dispatcher.test.php
Expand Up @@ -24,8 +24,13 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
require_once CAKE.'dispatcher.php';
App::import('Core', 'AppController');
require_once CAKE . 'dispatcher.php';

if (!class_exists('AppController')) {
require_once LIBS . 'controller' . DS . 'app_controller.php';
} elseif (!defined('APP_CONTROLLER_EXISTS')){
define('APP_CONTROLLER_EXISTS', true);
}
/**
* TestDispatcher class
*
Expand Down Expand Up @@ -491,11 +496,23 @@ class DispatcherTest extends CakeTestCase {
function setUp() {
$this->_get = $_GET;
$_GET = array();
$this->_post = $_POST;
$this->_files = $_FILES;
$this->_server = $_SERVER;

$this->_app = Configure::read('App');
Configure::write('App.base', false);
Configure::write('App.baseUrl', false);
Configure::write('App.dir', 'app');
Configure::write('App.webroot', 'webroot');

$this->_cache = Configure::read('Cache');
Configure::write('Cache.disable', true);

$this->_vendorPaths = Configure::read('vendorPaths');
$this->_pluginPaths = Configure::read('pluginPaths');
$this->_viewPaths = Configure::read('viewPaths');
$this->_debug = Configure::read('debug');
}
/**
* tearDown method
Expand All @@ -505,6 +522,15 @@ function setUp() {
*/
function tearDown() {
$_GET = $this->_get;
$_POST = $this->_post;
$_FILES = $this->_files;
$_SERVER = $this->_server;
Configure::write('App', $this->_app);
Configure::write('Cache', $this->_cache);
Configure::write('vendorPaths', $this->_vendorPaths);
Configure::write('pluginPaths', $this->_pluginPaths);
Configure::write('viewPaths', $this->_viewPaths);
Configure::write('debug', $this->_debug);
}
/**
* testParseParamsWithoutZerosAndEmptyPost method
Expand Down Expand Up @@ -626,8 +652,6 @@ function testQueryStringOnRoot() {
$this->assertTrue(isset($result['url']['sleep']));
$this->assertTrue(isset($result['url']['coffee']));
$this->assertEqual($result['url']['coffee'], 'life');

$_GET = $this->_get;
}
/**
* testFileUploadArrayStructure method
Expand Down Expand Up @@ -854,8 +878,6 @@ function testFileUploadArrayStructure() {
)
);
$this->assertEqual($result['data'], $expected);

$_FILES = array();
}
/**
* testGetUrl method
Expand Down Expand Up @@ -1614,6 +1636,7 @@ function testTestPluginDispatch() {
* @return void
*/
function testChangingParamsFromBeforeFilter() {
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
$Dispatcher =& new TestDispatcher();
$url = 'some_posts/index/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
Expand Down
7 changes: 5 additions & 2 deletions cake/tests/cases/libs/cache/apc.test.php
Expand Up @@ -45,7 +45,7 @@ function skip() {
if (Cache::engine('Apc')) {
$skip = false;
}
$this->skipif($skip, 'Apc is not installed or configured properly');
$this->skipIf($skip, '%s Apc is not installed or configured properly');
}
/**
* setUp method
Expand All @@ -54,7 +54,9 @@ function skip() {
* @return void
*/
function setUp() {
Cache::config('apc', array('engine'=>'Apc', 'prefix' => 'cake_'));
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_'));
}
/**
* tearDown method
Expand All @@ -63,6 +65,7 @@ function setUp() {
* @return void
*/
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
Expand Down
17 changes: 10 additions & 7 deletions cake/tests/cases/libs/cache/file.test.php
Expand Up @@ -45,23 +45,26 @@ class FileEngineTest extends CakeTestCase {
*/
var $config = array();
/**
* start method
* startCase method
*
* @access public
* @return void
*/
function start() {
$this->config = Cache::config('default');
$settings = Cache::config('default', array('engine'=> 'File', 'path' => CACHE));
function startCase() {
$this->_cacheDisable = Configure::read('Cache.disable');
$this->_cacheConfig = Cache::config('default');
Configure::write('Cache.disable', false);
Cache::config('default', array('engine' => 'File', 'path' => CACHE));
}
/**
* end method
* endCase method
*
* @access public
* @return void
*/
function end() {
Cache::config('default', $this->config['settings']);
function endCase() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default', $this->_cacheConfig['settings']);
}
/**
* testCacheDirChange method
Expand Down
12 changes: 8 additions & 4 deletions cake/tests/cases/libs/cache/memcache.test.php
Expand Up @@ -26,7 +26,8 @@
*/
if (!class_exists('Cache')) {
require LIBS . 'cache.php';
}/**
}
/**
* MemcacheEngineTest class
*
* @package cake
Expand All @@ -50,7 +51,7 @@ function skip() {
if (Cache::engine('Memcache')) {
$skip = false;
}
$this->skipIf($skip, 'Memcache is not installed or configured properly');
$this->skipIf($skip, '%s Memcache is not installed or configured properly');
}
/**
* setUp method
Expand All @@ -59,7 +60,9 @@ function skip() {
* @return void
*/
function setUp() {
Cache::config('memcache', array('engine'=>'Memcache', 'prefix' => 'cake_'));
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('memcache', array('engine' => 'Memcache', 'prefix' => 'cake_'));
}
/**
* tearDown method
Expand All @@ -68,6 +71,7 @@ function setUp() {
* @return void
*/
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
Expand Down Expand Up @@ -107,7 +111,7 @@ function testMultipleServers() {
}
}

if ($this->skipIf(!$available, 'Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) {
if ($this->skipIf(!$available, '%s Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) {
return;
}

Expand Down
7 changes: 5 additions & 2 deletions cake/tests/cases/libs/cache/xcache.test.php
Expand Up @@ -45,7 +45,7 @@ function skip() {
if ($result = Cache::engine('Xcache')) {
$skip = false;
}
$this->skipif($skip, 'Xcache is not installed or configured properly');
$this->skipIf($skip, '%s Xcache is not installed or configured properly');
}
/**
* setUp method
Expand All @@ -54,7 +54,9 @@ function skip() {
* @return void
*/
function setUp() {
Cache::config('xcache', array('engine'=>'Xcache', 'prefix' => 'cake_'));
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('xcache', array('engine' => 'Xcache', 'prefix' => 'cake_'));
}
/**
* tearDown method
Expand All @@ -63,6 +65,7 @@ function setUp() {
* @return void
*/
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
Expand Down
7 changes: 6 additions & 1 deletion cake/tests/cases/libs/cake_test_case.test.php
Expand Up @@ -25,7 +25,12 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('Core', 'CakeTestCase');
App::import('Core', 'AppController');

if (!class_exists('AppController')) {
require_once LIBS . 'controller' . DS . 'app_controller.php';
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
define('APP_CONTROLLER_EXISTS', true);
}

Mock::generate('CakeHtmlReporter');
Mock::generate('CakeTestCase', 'CakeDispatcherMockTestCase');
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/cases/libs/code_coverage_manager.test.php
Expand Up @@ -40,7 +40,7 @@ class CodeCoverageManagerTest extends CakeTestCase {
* @access public
*/
function skip() {
$this->skipif (!extension_loaded('xdebug'), 'XDebug not installed');
$this->skipIf(!extension_loaded('xdebug'), '%s XDebug not installed');
}
/**
* startTest Method
Expand Down
8 changes: 5 additions & 3 deletions cake/tests/cases/libs/configure.test.php
Expand Up @@ -39,8 +39,10 @@ class ConfigureTest extends CakeTestCase {
* @return void
*/
function setUp() {
parent::setUp();
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', true);

$this->_debug = Configure::read('debug');
}
/**
* tearDown method
Expand All @@ -67,8 +69,8 @@ function tearDown() {
if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'test.php')) {
unlink(TMP . 'cache' . DS . 'persistent' . DS . 'test.php');
}
Configure::write('debug', 2);
parent::tearDown();
Configure::write('debug', $this->_debug);
Configure::write('Cache.disable', $this->_cacheDisable);
}
/**
* testListObjects method
Expand Down
25 changes: 20 additions & 5 deletions cake/tests/cases/libs/controller/component.test.php
Expand Up @@ -62,9 +62,8 @@ class AppController extends Controller {
* @access public
*/
var $components = array('Orange' => array('colour' => 'blood orange'));

}
} else if (!defined('APP_CONTROLLER_EXISTS')){
} elseif (!defined('APP_CONTROLLER_EXISTS')){
define('APP_CONTROLLER_EXISTS', true);
}
/**
Expand Down Expand Up @@ -281,10 +280,21 @@ class ComponentTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->_pluginPaths = Configure::read('pluginPaths');
Configure::write('pluginPaths', array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
));
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('pluginPaths', $this->_pluginPaths);
ClassRegistry::flush();
}
/**
* testLoadComponents method
*
Expand Down Expand Up @@ -395,7 +405,9 @@ function testMultipleComponentInitialize() {
* @return void
*/
function testComponentsWithParams() {
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), 'Components with Params test will be skipped as it needs a non-existent AppController. As the an AppController class exists, this cannot be run.');
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
return;
}

$Controller =& new ComponentTestController();
$Controller->components = array('ParamTest' => array('test' => 'value', 'flag'), 'Apple');
Expand Down Expand Up @@ -475,11 +487,14 @@ function testSomethingReferencingEmailComponent() {
));
}
/**
* test that SessionComponent doesn't get added if its already in the components array.
* Test that SessionComponent doesn't get added if its already in the components array.
*
* @return void
**/
* @access public
*/
function testDoubleLoadingOfSessionComponent() {
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController');

$Controller =& new ComponentTestController();
$Controller->uses = array();
$Controller->components = array('Session');
Expand Down

0 comments on commit fd7d671

Please sign in to comment.