Permalink
Browse files

Updating tests to not affect other ones when run from a group

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...
1 parent fc7773f commit fd7d6718a18a9480b8f82593fd719a580231c22c @davidpersson davidpersson committed Mar 21, 2009
Showing with 536 additions and 239 deletions.
  1. +13 −1 cake/tests/cases/basics.test.php
  2. +5 −6 cake/tests/cases/console/cake.test.php
  3. +4 −1 cake/tests/cases/console/libs/shell.test.php
  4. +29 −6 cake/tests/cases/dispatcher.test.php
  5. +5 −2 cake/tests/cases/libs/cache/apc.test.php
  6. +10 −7 cake/tests/cases/libs/cache/file.test.php
  7. +8 −4 cake/tests/cases/libs/cache/memcache.test.php
  8. +5 −2 cake/tests/cases/libs/cache/xcache.test.php
  9. +6 −1 cake/tests/cases/libs/cake_test_case.test.php
  10. +1 −1 cake/tests/cases/libs/code_coverage_manager.test.php
  11. +5 −3 cake/tests/cases/libs/configure.test.php
  12. +20 −5 cake/tests/cases/libs/controller/component.test.php
  13. +1 −1 cake/tests/cases/libs/controller/components/acl.test.php
  14. +21 −6 cake/tests/cases/libs/controller/components/auth.test.php
  15. +21 −4 cake/tests/cases/libs/controller/components/email.test.php
  16. +2 −2 cake/tests/cases/libs/controller/components/security.test.php
  17. +20 −0 cake/tests/cases/libs/controller/components/session.test.php
  18. +4 −2 cake/tests/cases/libs/controller/controller.test.php
  19. +28 −1 cake/tests/cases/libs/controller/pages_controller.test.php
  20. +2 −3 cake/tests/cases/libs/debugger.test.php
  21. +46 −42 cake/tests/cases/libs/error.test.php
  22. +1 −1 cake/tests/cases/libs/file.test.php
  23. +2 −2 cake/tests/cases/libs/flay.test.php
  24. +1 −1 cake/tests/cases/libs/folder.test.php
  25. +10 −0 cake/tests/cases/libs/i18n.test.php
  26. +4 −10 cake/tests/cases/libs/inflector.test.php
  27. +1 −2 cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php
  28. +1 −2 cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
  29. +1 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
  30. +1 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
  31. +1 −3 cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php
  32. +1 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
  33. +1 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
  34. +12 −11 cake/tests/cases/libs/model/model.test.php
  35. +3 −3 cake/tests/cases/libs/model/models.php
  36. +1 −1 cake/tests/cases/libs/overloadable.test.php
  37. +5 −0 cake/tests/cases/libs/security.test.php
  38. +10 −0 cake/tests/cases/libs/validation.test.php
  39. +3 −1 cake/tests/cases/libs/view/helpers/html.test.php
  40. +1 −1 cake/tests/cases/libs/view/helpers/js.test.php
  41. +5 −5 cake/tests/groups/cache.group.php
  42. +5 −5 cake/tests/groups/components.group.php
  43. +4 −4 cake/tests/groups/console.group.php
  44. +4 −4 cake/tests/groups/{lib_controller.group.php → controller.group.php}
  45. +5 −5 cake/tests/groups/helpers.group.php
  46. +5 −5 cake/tests/groups/lib.group.php
  47. +71 −0 cake/tests/groups/no_cross_contamination.group.php
  48. +5 −5 cake/tests/groups/no_database.group.php
  49. +5 −5 cake/tests/groups/view.group.php
  50. +1 −1 cake/tests/groups/xml.group.php
  51. +110 −58 cake/tests/lib/cake_test_case.php
@@ -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
@@ -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'));
@@ -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
));
@@ -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
@@ -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
*
@@ -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
*
@@ -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
@@ -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
@@ -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
@@ -854,8 +878,6 @@ function testFileUploadArrayStructure() {
)
);
$this->assertEqual($result['data'], $expected);
-
- $_FILES = array();
}
/**
* testGetUrl method
@@ -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));
@@ -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
@@ -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
@@ -63,6 +65,7 @@ function setUp() {
* @return void
*/
function tearDown() {
+ Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
@@ -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
@@ -26,7 +26,8 @@
*/
if (!class_exists('Cache')) {
require LIBS . 'cache.php';
-}/**
+}
+/**
* MemcacheEngineTest class
*
* @package cake
@@ -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
@@ -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
@@ -68,6 +71,7 @@ function setUp() {
* @return void
*/
function tearDown() {
+ Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
@@ -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;
}
@@ -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
@@ -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
@@ -63,6 +65,7 @@ function setUp() {
* @return void
*/
function tearDown() {
+ Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
@@ -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');
@@ -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
@@ -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
@@ -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
@@ -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);
}
/**
@@ -281,11 +280,22 @@ 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
*
* @access public
@@ -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');
@@ -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');
Oops, something went wrong.

0 comments on commit fd7d671

Please sign in to comment.