mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Moving common setup and teardown functionality in to CakeTestCase.
Removing repeated setup/teardown logic from test cases. Switching tests to use setup/teardown instead of startTest/endTest.
This commit is contained in:
parent
24dd0af601
commit
92b57d81ee
34 changed files with 198 additions and 269 deletions
|
@ -165,6 +165,7 @@ class ShellDispatcherTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
App::build(array(
|
||||
'plugins' => array(
|
||||
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
|
||||
|
@ -176,15 +177,6 @@ class ShellDispatcherTest extends CakeTestCase {
|
|||
), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown() {
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
* testParseParams method
|
||||
*
|
||||
|
|
|
@ -51,13 +51,12 @@ class AclShellTest extends CakeTestCase {
|
|||
public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setup method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
$this->_aclDb = Configure::read('Acl.database');
|
||||
$this->_aclClass = Configure::read('Acl.classname');
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
Configure::write('Acl.database', 'test');
|
||||
Configure::write('Acl.classname', 'DbAcl');
|
||||
|
@ -77,17 +76,6 @@ class AclShellTest extends CakeTestCase {
|
|||
$this->Task->params['datasource'] = 'test';
|
||||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
ClassRegistry::flush();
|
||||
Configure::write('Acl.database', $this->_aclDb);
|
||||
Configure::write('Acl.classname', $this->_aclClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that model.foreign_key output works when looking at acl rows
|
||||
*
|
||||
|
|
|
@ -43,11 +43,12 @@ if (!class_exists('ApiShell')) {
|
|||
class ApiShellTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock(
|
||||
'ShellDispatcher',
|
||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch', 'clear')
|
||||
|
@ -59,15 +60,6 @@ class ApiShellTest extends CakeTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that method names are detected properly including those with no arguments.
|
||||
*
|
||||
|
|
|
@ -54,11 +54,12 @@ class BakeShellTest extends CakeTestCase {
|
|||
public $fixtures = array('core.user');
|
||||
|
||||
/**
|
||||
* start test
|
||||
* setup test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock(
|
||||
'ShellDispatcher',
|
||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
|
||||
|
@ -72,11 +73,12 @@ class BakeShellTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* teardown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Dispatch, $this->Shell);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,11 +64,12 @@ class TEST_DATABASE_CONFIG {
|
|||
class DbConfigTaskTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setup method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
|
@ -87,9 +88,9 @@ class DbConfigTaskTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Task, $this->Dispatcher);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,11 +50,12 @@ class FixtureTaskTest extends CakeTestCase {
|
|||
public $fixtures = array('core.article', 'core.comment', 'core.datatype', 'core.binary_test');
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
|
@ -72,13 +73,13 @@ class FixtureTaskTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Task, $this->Dispatcher);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,11 +53,12 @@ class ModelTaskTest extends CakeTestCase {
|
|||
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag', 'core.category_thread');
|
||||
|
||||
/**
|
||||
* starTest method
|
||||
* setUp method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
|
@ -97,13 +98,13 @@ class ModelTaskTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* teardown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Task, $this->Dispatcher);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,16 +44,14 @@ require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php';
|
|||
*/
|
||||
class PluginTaskTest extends CakeTestCase {
|
||||
|
||||
public static $_paths = array();
|
||||
|
||||
public static $_testPath = array();
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setup method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
|
@ -62,35 +60,20 @@ class PluginTaskTest extends CakeTestCase {
|
|||
array(&$this->Dispatcher)
|
||||
);
|
||||
$this->Task->path = TMP . 'tests' . DS;
|
||||
}
|
||||
|
||||
/**
|
||||
* startCase methods
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setUpBeforeClass() {
|
||||
self::$_paths = $paths = App::path('plugins');
|
||||
self::$_testPath = array_push($paths, TMP . 'tests' . DS);
|
||||
|
||||
$this->_paths = $paths = App::path('plugins');
|
||||
$this->_testPath = array_push($paths, TMP . 'tests' . DS);
|
||||
App::build(array('plugins' => $paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* endCase
|
||||
* teardown
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function tearDownAfterClass() {
|
||||
App::build(array('plugins' => self::$_paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
ClassRegistry::flush();
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
App::build(array('plugins' => $this->_paths));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,7 +82,7 @@ class PluginTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testBakeFoldersAndFiles() {
|
||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue(self::$_testPath));
|
||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
|
||||
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
|
||||
|
||||
$path = $this->Task->path . 'bake_test_plugin';
|
||||
|
@ -219,7 +202,7 @@ class PluginTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function testExecuteWithOneArg() {
|
||||
$this->Task->expects($this->at(0))->method('in')
|
||||
->will($this->returnValue(self::$_testPath));
|
||||
->will($this->returnValue($this->_testPath));
|
||||
$this->Task->expects($this->at(1))->method('in')
|
||||
->will($this->returnValue('y'));
|
||||
|
||||
|
@ -250,7 +233,7 @@ class PluginTaskTest extends CakeTestCase {
|
|||
public function testExecuteWithTwoArgs() {
|
||||
$this->Task->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
|
||||
|
||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue(self::$_testPath));
|
||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
|
||||
|
||||
$this->Task->Model->expects($this->once())->method('loadTasks');
|
||||
$this->Task->Model->expects($this->once())->method('execute');
|
||||
|
|
|
@ -45,11 +45,12 @@ require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php'
|
|||
class ProjectTaskTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setup method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
|
@ -62,12 +63,12 @@ class ProjectTaskTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* teardown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
ClassRegistry::flush();
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
$Folder = new Folder($this->Task->path . 'bake_test_app');
|
||||
$Folder->delete();
|
||||
|
|
|
@ -224,13 +224,14 @@ class ViewTaskTest extends CakeTestCase {
|
|||
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* Ensure that the default theme is used
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startTest() {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
|
@ -245,18 +246,16 @@ class ViewTaskTest extends CakeTestCase {
|
|||
$this->Dispatcher->shellPaths = App::path('shells');
|
||||
$this->Task->path = TMP;
|
||||
$this->Task->Template->params['theme'] = 'default';
|
||||
|
||||
$this->_routing = Configure::read('Routing');
|
||||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function endTest() {
|
||||
ClassRegistry::flush();
|
||||
Configure::write('Routing', $this->_routing);
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Task, $this->Dispatch);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,8 @@ class CakeLogTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$streams = CakeLog::configured();
|
||||
foreach ($streams as $stream) {
|
||||
CakeLog::drop($stream);
|
||||
|
|
|
@ -28,25 +28,25 @@ class CakeRequestTestCase extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->_server = $_SERVER;
|
||||
$this->_get = $_GET;
|
||||
$this->_post = $_POST;
|
||||
$this->_files = $_FILES;
|
||||
$this->_app = Configure::read('App');
|
||||
}
|
||||
|
||||
/**
|
||||
* end test
|
||||
* tearDown
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
$_SERVER = $this->_server;
|
||||
$_GET = $this->_get;
|
||||
$_POST = $this->_post;
|
||||
$_FILES = $this->_files;
|
||||
Configure::write('App', $this->_app);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,6 @@ App::import('Core', 'CakeResponse');
|
|||
|
||||
class CakeResponseTestCase extends CakeTestCase {
|
||||
|
||||
|
||||
/**
|
||||
* Tests the request object constructor
|
||||
*
|
||||
|
|
|
@ -189,12 +189,12 @@ class DbAclTwoTest extends DbAcl {
|
|||
*/
|
||||
class AclComponentTest extends CakeTestCase {
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
if (!class_exists('MockAclImplementation', false)) {
|
||||
$this->getMock('AclInterface', array(), array(), 'MockAclImplementation');
|
||||
}
|
||||
|
@ -206,10 +206,10 @@ class AclComponentTest extends CakeTestCase {
|
|||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Acl);
|
||||
}
|
||||
|
||||
|
@ -347,14 +347,12 @@ class DbAclTest extends CakeTestCase {
|
|||
public $fixtures = array('core.aro_two', 'core.aco_two', 'core.aros_aco_two');
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
$this->_settings = Configure::read('Acl');
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
Configure::write('Acl.classname', 'DbAclTwoTest');
|
||||
Configure::write('Acl.database', 'test');
|
||||
$Collection = new ComponentCollection();
|
||||
|
@ -367,9 +365,9 @@ class DbAclTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Acl);
|
||||
Configure::write('Acl', $this->_settings);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -473,21 +473,19 @@ class AuthTest extends CakeTestCase {
|
|||
public $initialized = false;
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->_server = $_SERVER;
|
||||
$this->_env = $_ENV;
|
||||
|
||||
$this->_securitySalt = Configure::read('Security.salt');
|
||||
$this->_securityCipher = Configure::read('Security.cipherSeed');
|
||||
Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
||||
Configure::write('Security.cipherSeed', 770011223369876);
|
||||
|
||||
$this->_acl = Configure::read('Acl');
|
||||
Configure::write('Acl.database', 'test');
|
||||
Configure::write('Acl.classname', 'DbAcl');
|
||||
|
||||
|
@ -505,27 +503,21 @@ class AuthTest extends CakeTestCase {
|
|||
$this->Controller->Session->delete('Auth');
|
||||
$this->Controller->Session->delete('Message.auth');
|
||||
|
||||
Router::reload();
|
||||
|
||||
$this->initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* tearDown method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
$_SERVER = $this->_server;
|
||||
$_ENV = $this->_env;
|
||||
Configure::write('Acl', $this->_acl);
|
||||
Configure::write('Security.salt', $this->_securitySalt);
|
||||
Configure::write('Security.cipherSeed', $this->_securityCipher);
|
||||
|
||||
$this->Controller->Session->delete('Auth');
|
||||
$this->Controller->Session->delete('Message.auth');
|
||||
ClassRegistry::flush();
|
||||
unset($this->Controller, $this->AuthUser);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,25 +143,26 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$request = new CakeRequest('posts/index', false);
|
||||
$request->addParams(array('controller' => 'posts', 'action' => 'index'));
|
||||
$this->Controller = new SecurityTestController($request);
|
||||
$this->Controller->Components->init($this->Controller);
|
||||
$this->Controller->Security = $this->Controller->TestSecurity;
|
||||
$this->Controller->Security->blackHoleCallback = 'fail';
|
||||
$this->oldSalt = Configure::read('Security.salt');
|
||||
|
||||
Configure::write('Security.salt', 'foo!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear-down method. Resets environment state.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
Configure::write('Security.salt', $this->oldSalt);
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
$this->Controller->Session->delete('_Token');
|
||||
unset($this->Controller->Security);
|
||||
unset($this->Controller->Component);
|
||||
|
|
|
@ -275,12 +275,13 @@ class ScaffoldViewTest extends CakeTestCase {
|
|||
public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag');
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->request = new CakeRequest(null, false);
|
||||
$this->Controller = new ScaffoldMockController($this->request);
|
||||
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
|
@ -292,15 +293,13 @@ class ScaffoldViewTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* teardown method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Controller);
|
||||
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -687,24 +686,24 @@ class ScaffoldTest extends CakeTestCase {
|
|||
*/
|
||||
public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag');
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$request = new CakeRequest(null, false);
|
||||
$this->Controller = new ScaffoldMockController($request);
|
||||
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* tearDown method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Controller);
|
||||
}
|
||||
|
||||
|
|
|
@ -519,23 +519,22 @@ class CakeSchemaTest extends CakeTestCase {
|
|||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->Schema = new TestAppSchema();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
@unlink(TMP . 'tests' . DS .'schema.php');
|
||||
unset($this->Schema);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1283,12 +1283,13 @@ class DboSourceTest extends CakeTestCase {
|
|||
);
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->__config = $this->db->config;
|
||||
|
||||
if (!class_exists('DboTest')) {
|
||||
|
@ -1325,8 +1326,7 @@ class DboSourceTest extends CakeTestCase {
|
|||
$this->testDb->cacheSources = false;
|
||||
$this->testDb->startQuote = '`';
|
||||
$this->testDb->endQuote = '`';
|
||||
Configure::write('debug', 1);
|
||||
$this->debug = Configure::read('debug');
|
||||
|
||||
$this->Model = new TestModel();
|
||||
}
|
||||
|
||||
|
@ -1336,11 +1336,9 @@ class DboSourceTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Model);
|
||||
Configure::write('debug', $this->debug);
|
||||
ClassRegistry::flush();
|
||||
unset($this->debug);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,24 +10,14 @@ App::import('Core', 'Router');
|
|||
**/
|
||||
class CakeRouteTestCase extends CakeTestCase {
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
$this->_routing = Configure::read('Routing');
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
Configure::write('Routing', array('admin' => null, 'prefixes' => array()));
|
||||
Router::reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* end the test and reset the environment
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function endTest() {
|
||||
Configure::write('Routing', $this->_routing);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,26 +7,16 @@ App::import('Core', 'route/PluginShortRoute');
|
|||
*/
|
||||
class PluginShortRouteTestCase extends CakeTestCase {
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
$this->_routing = Configure::read('Routing');
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
Configure::write('Routing', array('admin' => null, 'prefixes' => array()));
|
||||
Router::reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* end the test and reset the environment
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function endTest() {
|
||||
Configure::write('Routing', $this->_routing);
|
||||
}
|
||||
|
||||
/**
|
||||
* test the parsing of routes.
|
||||
*
|
||||
|
|
|
@ -38,18 +38,8 @@ class RouterTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
$this->_routing = Configure::read('Routing');
|
||||
parent::setUp();
|
||||
Configure::write('Routing', array('admin' => null, 'prefixes' => array()));
|
||||
Router::reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* end the test and reset the environment
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
Configure::write('Routing', $this->_routing);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,7 +57,8 @@ class CacheSessionTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function setup() {
|
||||
function setUp() {
|
||||
parent::setUp()
|
||||
$this->storage = new CacheSession();
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,8 @@ class CacheSessionTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function teardown() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->storage);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ class TestManagerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->_countFiles = 0;
|
||||
$this->TestManager = new TestTestManager();
|
||||
$this->testSuiteStub = $this->getMock('CakeTestSuite');
|
||||
|
|
|
@ -63,12 +63,14 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* @var string
|
||||
*/
|
||||
public $cDataStart = 'preg:/^\/\/<!\[CDATA\[[\n\r]*/';
|
||||
|
||||
/**
|
||||
* Regexp for CDATA end block
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $cDataEnd = 'preg:/[^\]]*\]\]\>[\s\r\n]*/';
|
||||
|
||||
/**
|
||||
* html property
|
||||
*
|
||||
|
@ -77,57 +79,26 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
*/
|
||||
public $Html = null;
|
||||
|
||||
/**
|
||||
* Backup of app encoding configuration setting
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $_appEncoding;
|
||||
|
||||
/**
|
||||
* Backup of asset configuration settings
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $_asset;
|
||||
|
||||
/**
|
||||
* Backup of debug configuration setting
|
||||
*
|
||||
* @var integer
|
||||
* @access protected
|
||||
*/
|
||||
protected $_debug;
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->View = $this->getMock('View', array('addScript'), array(new TheHtmlTestController()));
|
||||
$this->Html = new HtmlHelper($this->View);
|
||||
$this->Html->request = new CakeRequest(null, false);
|
||||
$this->Html->request->webroot = '';
|
||||
$this->_appEncoding = Configure::read('App.encoding');
|
||||
$this->_asset = Configure::read('Asset');
|
||||
$this->_debug = Configure::read('debug');
|
||||
}
|
||||
|
||||
/**
|
||||
* endTest method
|
||||
* tearDown method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
Configure::write('App.encoding', $this->_appEncoding);
|
||||
Configure::write('Asset', $this->_asset);
|
||||
Configure::write('debug', $this->_debug);
|
||||
ClassRegistry::flush();
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Html, $this->View);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,22 +22,24 @@ App::import('Helper', array('Html', 'Js', 'JqueryEngine'));
|
|||
|
||||
class JqueryEngineHelperTest extends CakeTestCase {
|
||||
/**
|
||||
* startTest
|
||||
* setUp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$controller = null;
|
||||
$View = new View($controller);
|
||||
$this->Jquery = new JqueryEngineHelper($View);
|
||||
}
|
||||
|
||||
/**
|
||||
* end test
|
||||
* tearDown
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Jquery);
|
||||
}
|
||||
|
||||
|
|
|
@ -685,24 +685,23 @@ class JsHelperTest extends CakeTestCase {
|
|||
*/
|
||||
class JsBaseEngineTest extends CakeTestCase {
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$controller = null;
|
||||
$this->View = new View($controller);
|
||||
$this->JsEngine = new OptionEngineHelper($this->View);
|
||||
}
|
||||
/**
|
||||
* endTest method
|
||||
* tearDown method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
ClassRegistry::removeObject('view');
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->JsEngine);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,21 +24,25 @@ App::import('Helper', array('Html', 'Js', 'MootoolsEngine'));
|
|||
|
||||
class MooEngineHelperTest extends CakeTestCase {
|
||||
/**
|
||||
* startTest
|
||||
* setUp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
$this->Moo =& new MootoolsEngineHelper();
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->Moo = new MootoolsEngineHelper();
|
||||
}
|
||||
|
||||
/**
|
||||
* end test
|
||||
* tearDown
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Moo);
|
||||
}
|
||||
|
||||
/**
|
||||
* test selector method
|
||||
*
|
||||
|
|
|
@ -31,17 +31,16 @@ class NumberHelperTest extends CakeTestCase {
|
|||
* helper property
|
||||
*
|
||||
* @var mixed null
|
||||
* @access public
|
||||
*/
|
||||
public $helper = null;
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$view = $this->getMock('View', array(), array(), '', false);
|
||||
$this->Number = new NumberHelper($view);
|
||||
}
|
||||
|
@ -52,7 +51,8 @@ class NumberHelperTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Number);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,20 +22,22 @@ App::import('Helper', array('Html', 'Js', 'PrototypeEngine'));
|
|||
|
||||
class PrototypeEngineHelperTest extends CakeTestCase {
|
||||
/**
|
||||
* startTest
|
||||
* setUp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
$this->Proto =& new PrototypeEngineHelper();
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->Proto = new PrototypeEngineHelper();
|
||||
}
|
||||
|
||||
/**
|
||||
* end test
|
||||
* tearDown
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Proto);
|
||||
}
|
||||
|
||||
|
|
|
@ -124,13 +124,12 @@ class TestMediaView extends MediaView {
|
|||
class MediaViewTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* startTest method
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function startTest() {
|
||||
Router::reload();
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->Controller =& new Controller();
|
||||
$this->MediaController =& new MediaController();
|
||||
$this->MediaController->viewPath = 'posts';
|
||||
|
@ -144,11 +143,11 @@ class MediaViewTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->MediaView);
|
||||
unset($this->MediaController);
|
||||
unset($this->Controller);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -224,7 +224,7 @@ class ViewTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
Router::reload();
|
||||
parent::setUp();
|
||||
|
||||
$request = $this->getMock('CakeRequest');
|
||||
$this->Controller = new Controller($request);
|
||||
|
@ -239,8 +239,7 @@ class ViewTest extends CakeTestCase {
|
|||
TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS
|
||||
)
|
||||
), true);
|
||||
|
||||
$this->_debug = Configure::read('debug');
|
||||
|
||||
Configure::write('debug', 2);
|
||||
}
|
||||
|
||||
|
@ -251,12 +250,10 @@ class ViewTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->View);
|
||||
unset($this->PostsController);
|
||||
unset($this->Controller);
|
||||
|
||||
App::build();
|
||||
Configure::write('debug', $this->_debug);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,7 +52,8 @@ class XmlTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
$manager =& new XmlManager();
|
||||
parent::setUp();
|
||||
$manager = new XmlManager();
|
||||
$manager->namespaces = array();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,13 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
*/
|
||||
private $fixtures = array();
|
||||
|
||||
/**
|
||||
* Configure values to restore at end of test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_configure = array();
|
||||
|
||||
/**
|
||||
* Runs the test case and collects the results in a TestResult object.
|
||||
* If no TestResult object is passed a new one will be created.
|
||||
|
@ -112,6 +119,33 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
return $shouldSkip;
|
||||
}
|
||||
|
||||
/**
|
||||
* setup the test case, backup the static object values so they can be restored.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->_configure = Configure::read();
|
||||
if (class_exists('Router', false)) {
|
||||
Router::reload();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* teardown any static object changes and restore them.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
App::build();
|
||||
if (class_exists('ClassRegistry', false)) {
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
Configure::write($this->_configure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Announces the start of a test.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue