Skip to content

Commit

Permalink
Merge pull request #355 from shama/patch-casing
Browse files Browse the repository at this point in the history
Consistently setting setUp() and tearDown() on test cases
  • Loading branch information
markstory committed Dec 5, 2011
2 parents 3b8990f + 5388237 commit a32eabe
Show file tree
Hide file tree
Showing 35 changed files with 89 additions and 67 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php
Expand Up @@ -45,7 +45,7 @@ public function setUp() {
} }


/** /**
* teardown method * tearDown method
* *
* @return void * @return void
*/ */
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Configure/IniReaderTest.php
Expand Up @@ -32,8 +32,8 @@ class IniReaderTest extends CakeTestCase {
* *
* @return void * @return void
*/ */
public function setup() { public function setUp() {
parent::setup(); parent::setUp();
$this->path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS; $this->path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
} }


Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Test/Case/Console/Command/AclShellTest.php
Expand Up @@ -37,11 +37,12 @@ class AclShellTest extends CakeTestCase {
public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco'); public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');


/** /**
* setup method * setUp method
* *
* @return void * @return void
*/ */
public function setUp() { public function setUp() {
parent::setUp();
Configure::write('Acl.database', 'test'); Configure::write('Acl.database', 'test');
Configure::write('Acl.classname', 'DbAcl'); Configure::write('Acl.classname', 'DbAcl');


Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/BakeShellTest.php
Expand Up @@ -59,7 +59,7 @@ public function setUp() {
} }


/** /**
* teardown method * tearDown method
* *
* @return void * @return void
*/ */
Expand Down
Expand Up @@ -60,7 +60,7 @@ public function setUp() {
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/SchemaShellTest.php
Expand Up @@ -97,7 +97,7 @@ class SchemaShellTest extends CakeTestCase {
); );


/** /**
* setup method * setUp method
* *
* @return void * @return void
*/ */
Expand Down
Expand Up @@ -64,6 +64,7 @@ class ControllerTaskTest extends CakeTestCase {
* @return void * @return void
*/ */
public function setUp() { public function setUp() {
parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false); $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ControllerTask', $this->Task = $this->getMock('ControllerTask',
Expand All @@ -86,14 +87,15 @@ public function setUp() {
} }


/** /**
* teardown method * tearDown method
* *
* @return void * @return void
*/ */
public function teardown() { public function tearDown() {
unset($this->Task); unset($this->Task);
ClassRegistry::flush(); ClassRegistry::flush();
App::build(); App::build();
parent::tearDown();
} }


/** /**
Expand Down
Expand Up @@ -31,7 +31,7 @@
class DbConfigTaskTest extends CakeTestCase { class DbConfigTaskTest extends CakeTestCase {


/** /**
* setup method * setUp method
* *
* @return void * @return void
*/ */
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -95,7 +95,7 @@ protected function _setupOtherMocks() {
} }


/** /**
* teardown method * tearDown method
* *
* @return void * @return void
*/ */
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php
Expand Up @@ -36,7 +36,7 @@
class PluginTaskTest extends CakeTestCase { class PluginTaskTest extends CakeTestCase {


/** /**
* setup method * setUp method
* *
* @return void * @return void
*/ */
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php
Expand Up @@ -35,7 +35,7 @@
class ProjectTaskTest extends CakeTestCase { class ProjectTaskTest extends CakeTestCase {


/** /**
* setup method * setUp method
* *
* @return void * @return void
*/ */
Expand All @@ -52,7 +52,7 @@ public function setUp() {
} }


/** /**
* teardown method * tearDown method
* *
* @return void * @return void
*/ */
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Console/Command/Task/TemplateTaskTest.php
Expand Up @@ -33,11 +33,11 @@
class TemplateTaskTest extends CakeTestCase { class TemplateTaskTest extends CakeTestCase {


/** /**
* setup method * setUp method
* *
* @return void * @return void
*/ */
public function setup() { public function setUp() {
parent::setUp(); parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false); $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false);
Expand All @@ -49,7 +49,7 @@ public function setup() {
} }


/** /**
* teardown method * tearDown method
* *
* @return void * @return void
*/ */
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php
Expand Up @@ -220,12 +220,12 @@ class TestTaskTest extends CakeTestCase {
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag'); public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');


/** /**
* setup method * setUp method
* *
* @return void * @return void
*/ */
public function setup() { public function setUp() {
parent::setup(); parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false); $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false);


Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php
Expand Up @@ -38,7 +38,7 @@ public function setUp() {
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
Expand Down
10 changes: 6 additions & 4 deletions lib/Cake/Test/Case/Console/TaskCollectionTest.php
Expand Up @@ -22,23 +22,25 @@


class TaskCollectionTest extends CakeTestCase { class TaskCollectionTest extends CakeTestCase {
/** /**
* setup * setUp
* *
* @return void * @return void
*/ */
public function setup() { public function setUp() {
parent::setUp();
$shell = $this->getMock('Shell', array(), array(), '', false); $shell = $this->getMock('Shell', array(), array(), '', false);
$dispatcher = $this->getMock('ShellDispatcher', array(), array(), '', false); $dispatcher = $this->getMock('ShellDispatcher', array(), array(), '', false);
$this->Tasks = new TaskCollection($shell, $dispatcher); $this->Tasks = new TaskCollection($shell, $dispatcher);
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
public function teardown() { public function tearDown() {
unset($this->Tasks); unset($this->Tasks);
parent::tearDown();
} }


/** /**
Expand Down
Expand Up @@ -26,7 +26,7 @@
class ActionsAuthorizeTest extends CakeTestCase { class ActionsAuthorizeTest extends CakeTestCase {


/** /**
* setup * setUp
* *
* @return void * @return void
*/ */
Expand Down
Expand Up @@ -57,7 +57,7 @@ public function setUp() {
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
Expand Down
Expand Up @@ -59,7 +59,7 @@ public function setUp() {
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
Expand Down
10 changes: 6 additions & 4 deletions lib/Cake/Test/Case/Controller/ComponentCollectionTest.php
Expand Up @@ -29,21 +29,23 @@ class CookieAliasComponent extends CookieComponent {


class ComponentCollectionTest extends CakeTestCase { class ComponentCollectionTest extends CakeTestCase {
/** /**
* setup * setUp
* *
* @return void * @return void
*/ */
public function setup() { public function setUp() {
parent::setUp();
$this->Components = new ComponentCollection(); $this->Components = new ComponentCollection();
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
public function teardown() { public function tearDown() {
unset($this->Components); unset($this->Components);
parent::tearDown();
} }


/** /**
Expand Down
6 changes: 4 additions & 2 deletions lib/Cake/Test/Case/Controller/ControllerTest.php
Expand Up @@ -381,19 +381,21 @@ class ControllerTest extends CakeTestCase {
* @return void * @return void
*/ */
public function setUp() { public function setUp() {
parent::setUp();
App::objects('plugin', null, false); App::objects('plugin', null, false);
App::build(); App::build();
Router::reload(); Router::reload();
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
public function teardown() { public function tearDown() {
CakePlugin::unload(); CakePlugin::unload();
App::build(); App::build();
parent::tearDown();
} }


/** /**
Expand Down
7 changes: 5 additions & 2 deletions lib/Cake/Test/Case/Error/ErrorHandlerTest.php
Expand Up @@ -29,12 +29,14 @@
class ErrorHandlerTest extends CakeTestCase { class ErrorHandlerTest extends CakeTestCase {


public $_restoreError = false; public $_restoreError = false;

/** /**
* setup create a request object to get out of router later. * setup create a request object to get out of router later.
* *
* @return void * @return void
*/ */
public function setUp() { public function setUp() {
parent::setUp();
App::build(array( App::build(array(
'View' => array( 'View' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
Expand All @@ -51,17 +53,18 @@ public function setUp() {
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
public function teardown() { public function tearDown() {
Configure::write('debug', $this->_debug); Configure::write('debug', $this->_debug);
Configure::write('Error', $this->_error); Configure::write('Error', $this->_error);
App::build(); App::build();
if ($this->_restoreError) { if ($this->_restoreError) {
restore_error_handler(); restore_error_handler();
} }
parent::tearDown();
} }


/** /**
Expand Down
7 changes: 5 additions & 2 deletions lib/Cake/Test/Case/Error/ExceptionRendererTest.php
Expand Up @@ -142,12 +142,14 @@ class MissingWidgetThingException extends NotFoundException { }
class ExceptionRendererTest extends CakeTestCase { class ExceptionRendererTest extends CakeTestCase {


public $_restoreError = false; public $_restoreError = false;

/** /**
* setup create a request object to get out of router later. * setup create a request object to get out of router later.
* *
* @return void * @return void
*/ */
public function setUp() { public function setUp() {
parent::setUp();
App::build(array( App::build(array(
'views' => array( 'views' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
Expand All @@ -164,17 +166,18 @@ public function setUp() {
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
public function teardown() { public function tearDown() {
Configure::write('debug', $this->_debug); Configure::write('debug', $this->_debug);
Configure::write('Error', $this->_error); Configure::write('Error', $this->_error);
App::build(); App::build();
if ($this->_restoreError) { if ($this->_restoreError) {
restore_error_handler(); restore_error_handler();
} }
parent::tearDown();
} }


/** /**
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php
Expand Up @@ -71,8 +71,8 @@ public static function teardownAfterClass() {
* *
* @return void * @return void
*/ */
public function setup() { public function setUp() {
parent::setup(); parent::setUp();
Configure::write('Session', array( Configure::write('Session', array(
'defaults' => 'php', 'defaults' => 'php',
'cookie' => 'cakephp', 'cookie' => 'cakephp',
Expand Down
Expand Up @@ -63,7 +63,7 @@ public function setUp() {
} }


/** /**
* teardown * tearDown
* *
* @return void * @return void
*/ */
Expand Down

0 comments on commit a32eabe

Please sign in to comment.