From 72c3059d94702e51555a10cad8c0707f85488b4a Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 15 Apr 2012 22:20:34 -0400 Subject: [PATCH] Add missing parent calls. Fixes piles of failing tests. --- lib/Cake/Test/Case/BasicsTest.php | 12 +----------- lib/Cake/Test/Case/Cache/CacheTest.php | 2 ++ .../Test/Case/Cache/Engine/ApcEngineTest.php | 2 ++ .../Case/Cache/Engine/MemcacheEngineTest.php | 2 ++ .../Case/Cache/Engine/WincacheEngineTest.php | 2 ++ .../Test/Case/Cache/Engine/XcacheEngineTest.php | 6 +++--- .../Test/Case/Console/Command/TestShellTest.php | 2 ++ lib/Cake/Test/Case/Console/ConsoleOutputTest.php | 1 + .../Case/Controller/Component/Acl/IniAclTest.php | 2 +- .../Case/Controller/Component/Acl/PhpAclTest.php | 1 + .../Component/Auth/BasicAuthenticateTest.php | 2 -- .../Component/Auth/CrudAuthorizeTest.php | 3 +-- .../Controller/Component/AuthComponentTest.php | 5 ----- .../Controller/Component/EmailComponentTest.php | 16 ++-------------- .../Component/RequestHandlerComponentTest.php | 2 -- .../Case/Controller/ComponentCollectionTest.php | 2 +- lib/Cake/Test/Case/Controller/ComponentTest.php | 11 +---------- lib/Cake/Test/Case/Controller/ControllerTest.php | 3 +-- lib/Cake/Test/Case/Core/AppTest.php | 1 + lib/Cake/Test/Case/Core/CakePluginTest.php | 4 ++-- lib/Cake/Test/Case/Core/ConfigureTest.php | 7 ++----- lib/Cake/Test/Case/Core/ObjectTest.php | 3 ++- lib/Cake/Test/Case/Error/ErrorHandlerTest.php | 2 +- .../Test/Case/Error/ExceptionRendererTest.php | 2 +- .../Test/Case/Model/Behavior/AclBehaviorTest.php | 3 ++- .../Model/Behavior/TranslateBehaviorTest.php | 9 --------- .../Test/Case/Utility/ObjectCollectionTest.php | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 9 +++++++-- 28 files changed, 42 insertions(+), 76 deletions(-) diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php index fd2dbba65..e0280e0e9 100644 --- a/lib/Cake/Test/Case/BasicsTest.php +++ b/lib/Cake/Test/Case/BasicsTest.php @@ -34,20 +34,10 @@ class BasicsTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); App::build(array( 'Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS) )); - $this->_language = Configure::read('Config.language'); - } - -/** - * tearDown method - * - * @return void - */ - public function tearDown() { - App::build(); - Configure::write('Config.language', $this->_language); } /** diff --git a/lib/Cake/Test/Case/Cache/CacheTest.php b/lib/Cake/Test/Case/Cache/CacheTest.php index a5360a4e2..93d146cfb 100644 --- a/lib/Cake/Test/Case/Cache/CacheTest.php +++ b/lib/Cake/Test/Case/Cache/CacheTest.php @@ -32,6 +32,7 @@ class CacheTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); $this->_cacheDisable = Configure::read('Cache.disable'); Configure::write('Cache.disable', false); @@ -45,6 +46,7 @@ class CacheTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); Configure::write('Cache.disable', $this->_cacheDisable); Cache::config('default', $this->_defaultCacheConfig['settings']); } diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php index 62ac9b692..9b1c9facb 100644 --- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php @@ -32,6 +32,7 @@ class ApcEngineTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); $this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.'); $this->_cacheDisable = Configure::read('Cache.disable'); @@ -45,6 +46,7 @@ class ApcEngineTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); Configure::write('Cache.disable', $this->_cacheDisable); Cache::drop('apc'); Cache::config('default'); diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php index c0430bd04..6ff16437b 100644 --- a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php @@ -51,6 +51,7 @@ class MemcacheEngineTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); $this->skipIf(!class_exists('Memcache'), 'Memcache is not installed or configured properly.'); $this->_cacheDisable = Configure::read('Cache.disable'); @@ -68,6 +69,7 @@ class MemcacheEngineTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); Configure::write('Cache.disable', $this->_cacheDisable); Cache::drop('memcache'); Cache::config('default'); diff --git a/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php index c4da341fa..b952868e7 100644 --- a/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php @@ -32,6 +32,7 @@ class WincacheEngineTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); $this->skipIf(!function_exists('wincache_ucache_set'), 'Wincache is not installed or configured properly.'); $this->_cacheDisable = Configure::read('Cache.disable'); Configure::write('Cache.disable', false); @@ -44,6 +45,7 @@ class WincacheEngineTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); Configure::write('Cache.disable', $this->_cacheDisable); Cache::drop('wincache'); Cache::config('default'); diff --git a/lib/Cake/Test/Case/Cache/Engine/XcacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/XcacheEngineTest.php index 9f6b09141..e6d4ff572 100644 --- a/lib/Cake/Test/Case/Cache/Engine/XcacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/XcacheEngineTest.php @@ -32,10 +32,10 @@ class XcacheEngineTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); if (!function_exists('xcache_set')) { $this->markTestSkipped('Xcache is not installed or configured properly'); } - $this->_cacheDisable = Configure::read('Cache.disable'); Configure::write('Cache.disable', false); Cache::config('xcache', array('engine' => 'Xcache', 'prefix' => 'cake_')); } @@ -46,8 +46,8 @@ class XcacheEngineTest extends CakeTestCase { * @return void */ public function tearDown() { - Configure::write('Cache.disable', $this->_cacheDisable); - Cache::config('default'); + parent::tearDown(); + Cache::drop('xcache'); } /** diff --git a/lib/Cake/Test/Case/Console/Command/TestShellTest.php b/lib/Cake/Test/Case/Console/Command/TestShellTest.php index 8fc619bde..5d08c584d 100644 --- a/lib/Cake/Test/Case/Console/Command/TestShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/TestShellTest.php @@ -40,6 +40,7 @@ class TestShellTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); @@ -57,6 +58,7 @@ class TestShellTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); unset($this->Dispatch, $this->Shell); } diff --git a/lib/Cake/Test/Case/Console/ConsoleOutputTest.php b/lib/Cake/Test/Case/Console/ConsoleOutputTest.php index 0f7e106a3..6baef3dbd 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOutputTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOutputTest.php @@ -38,6 +38,7 @@ class ConsoleOutputTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); unset($this->output); } diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php index de552b1f8..b94f1b64c 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php @@ -1,4 +1,4 @@ -PhpAcl = new PhpAcl(); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php index 44bf9ba6c..7984d34b3 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php @@ -53,7 +53,6 @@ class BasicAuthenticateTest extends CakeTestCase { $password = Security::hash('password', null, true); $User = ClassRegistry::init('User'); $User->updateAll(array('password' => $User->getDataSource()->value($password))); - $this->server = $_SERVER; $this->response = $this->getMock('CakeResponse'); } @@ -64,7 +63,6 @@ class BasicAuthenticateTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - $_SERVER = $this->server; } /** diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php index 1f4464571..859e4243b 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php @@ -31,9 +31,8 @@ class CrudAuthorizeTest extends CakeTestCase { * @return void */ public function setUp() { - Configure::write('Routing.prefixes', array()); - parent::setUp(); + Configure::write('Routing.prefixes', array()); $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); $this->Components = $this->getMock('ComponentCollection'); diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 82d96bf06..e2d1fcb84 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -306,9 +306,6 @@ class AuthComponentTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $this->_server = $_SERVER; - $this->_env = $_ENV; - Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi'); Configure::write('Security.cipherSeed', 770011223369876); @@ -339,8 +336,6 @@ class AuthComponentTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - $_SERVER = $this->_server; - $_ENV = $this->_env; TestAuthComponent::clearUser(); $this->Auth->Session->delete('Auth'); diff --git a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php index b1a272b82..2f60ca9ee 100644 --- a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php @@ -148,13 +148,12 @@ class EmailComponentTest extends CakeTestCase { * @return void */ public function setUp() { - $this->_appEncoding = Configure::read('App.encoding'); + parent::setUp(); + Configure::write('App.encoding', 'UTF-8'); $this->Controller = new EmailTestController(); - $this->Controller->Components->init($this->Controller); - $this->Controller->EmailTest->initialize($this->Controller, array()); self::$sentDate = date(DATE_RFC2822); @@ -164,17 +163,6 @@ class EmailComponentTest extends CakeTestCase { )); } -/** - * tearDown method - * - * @return void - */ - public function tearDown() { - Configure::write('App.encoding', $this->_appEncoding); - App::build(); - ClassRegistry::flush(); - } - /** * testSendFormats method * diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php index 2dc35d44f..4012e6ff4 100644 --- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php @@ -99,7 +99,6 @@ class RequestHandlerComponentTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $this->_server = $_SERVER; $this->_init(); } @@ -128,7 +127,6 @@ class RequestHandlerComponentTest extends CakeTestCase { if (!headers_sent()) { header('Content-type: text/html'); //reset content type. } - $_SERVER = $this->_server; call_user_func_array('Router::parseExtensions', $this->_extensions); } diff --git a/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php b/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php index e556263cc..87cc1d833 100644 --- a/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php +++ b/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php @@ -45,8 +45,8 @@ class ComponentCollectionTest extends CakeTestCase { * @return void */ public function tearDown() { - unset($this->Components); parent::tearDown(); + unset($this->Components); } /** diff --git a/lib/Cake/Test/Case/Controller/ComponentTest.php b/lib/Cake/Test/Case/Controller/ComponentTest.php index 482e304f7..3504013fe 100644 --- a/lib/Cake/Test/Case/Controller/ComponentTest.php +++ b/lib/Cake/Test/Case/Controller/ComponentTest.php @@ -220,22 +220,13 @@ class ComponentTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); $this->_pluginPaths = App::path('plugins'); App::build(array( 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) )); } -/** - * tearDown method - * - * @return void - */ - public function tearDown() { - App::build(); - ClassRegistry::flush(); - } - /** * test accessing inner components. * diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index cca2e2cd5..b77a35bf3 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -425,9 +425,8 @@ class ControllerTest extends CakeTestCase { * @return void */ public function tearDown() { - CakePlugin::unload(); - App::build(); parent::tearDown(); + CakePlugin::unload(); } /** diff --git a/lib/Cake/Test/Case/Core/AppTest.php b/lib/Cake/Test/Case/Core/AppTest.php index 029537ef2..3b6cef55e 100644 --- a/lib/Cake/Test/Case/Core/AppTest.php +++ b/lib/Cake/Test/Case/Core/AppTest.php @@ -30,6 +30,7 @@ class AppTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); CakePlugin::unload(); } diff --git a/lib/Cake/Test/Case/Core/CakePluginTest.php b/lib/Cake/Test/Case/Core/CakePluginTest.php index 87926a209..893e6715a 100644 --- a/lib/Cake/Test/Case/Core/CakePluginTest.php +++ b/lib/Cake/Test/Case/Core/CakePluginTest.php @@ -31,6 +31,7 @@ class CakePluginTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); App::build(array( 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) ), App::RESET); @@ -43,9 +44,8 @@ class CakePluginTest extends CakeTestCase { * @return void */ public function tearDown() { - App::build(); + parent::tearDown(); CakePlugin::unload(); - Configure::delete('CakePluginTest'); } /** diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index ec462d6f7..2d222b311 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -33,9 +33,7 @@ class ConfigureTest extends CakeTestCase { * @return void */ public function setUp() { - $this->_cacheDisable = Configure::read('Cache.disable'); - $this->_debug = Configure::read('debug'); - + parent::setUp(); Configure::write('Cache.disable', true); App::build(); App::objects('plugin', null, true); @@ -47,6 +45,7 @@ class ConfigureTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_core_paths')) { unlink(TMP . 'cache' . DS . 'persistent' . DS . 'cake_core_core_paths'); } @@ -65,8 +64,6 @@ class ConfigureTest extends CakeTestCase { if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'test.php')) { unlink(TMP . 'cache' . DS . 'persistent' . DS . 'test.php'); } - Configure::write('debug', $this->_debug); - Configure::write('Cache.disable', $this->_cacheDisable); Configure::drop('test'); } diff --git a/lib/Cake/Test/Case/Core/ObjectTest.php b/lib/Cake/Test/Case/Core/ObjectTest.php index 0258d0402..e2e5d8cc2 100644 --- a/lib/Cake/Test/Case/Core/ObjectTest.php +++ b/lib/Cake/Test/Case/Core/ObjectTest.php @@ -305,6 +305,7 @@ class ObjectTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); $this->object = new TestObject(); } @@ -314,7 +315,7 @@ class ObjectTest extends CakeTestCase { * @return void */ public function tearDown() { - App::build(); + parent::tearDown(); CakePlugin::unload(); unset($this->object); } diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index 246b2eb96..96c62d72b 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -56,10 +56,10 @@ class ErrorHandlerTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); if ($this->_restoreError) { restore_error_handler(); } - parent::tearDown(); } /** diff --git a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php index 479ce0698..103b33322 100644 --- a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php +++ b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php @@ -174,10 +174,10 @@ class ExceptionRendererTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); if ($this->_restoreError) { restore_error_handler(); } - parent::tearDown(); } /** diff --git a/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php index aae48caa5..f37bcaa38 100644 --- a/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php @@ -211,6 +211,7 @@ class AclBehaviorTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); Configure::write('Acl.database', 'test'); $this->Aco = new Aco(); @@ -223,7 +224,7 @@ class AclBehaviorTest extends CakeTestCase { * @return void */ public function tearDown() { - ClassRegistry::flush(); + parent::tearDown(); unset($this->Aro, $this->Aco); } diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index d517c948a..a28655cdc 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -49,15 +49,6 @@ class TranslateBehaviorTest extends CakeTestCase { 'core.translate_with_prefix' ); -/** - * tearDown method - * - * @return void - */ - public function tearDown() { - ClassRegistry::flush(); - } - /** * Test that count queries with conditions get the correct joins * diff --git a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php index 4db295de2..70a8e09d9 100644 --- a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php +++ b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php @@ -117,8 +117,8 @@ class ObjectCollectionTest extends CakeTestCase { * @return void */ public function tearDown() { - unset($this->Objects); parent::tearDown(); + unset($this->Objects); } /** diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index adff9e7f8..cc7faceb0 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -127,6 +127,9 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { if (empty($this->_configure)) { $this->_configure = Configure::read(); } + if (empty($this->_configure['App'])) { + fwrite(STDERR, get_class($this) . '::' . $this->getName() . " did not have any configure vars\n"); + } if (empty($this->_pathRestore)) { $this->_pathRestore = App::paths(); } @@ -146,8 +149,10 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { if (class_exists('ClassRegistry', false)) { ClassRegistry::flush(); } - Configure::clear(); - Configure::write($this->_configure); + if (!empty($this->_configure)) { + Configure::clear(); + Configure::write($this->_configure); + } if (isset($_GET['debug']) && $_GET['debug']) { ob_flush(); }