diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index 141473cde..3526a7ca2 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.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 @@ class BasicsTest extends CakeTestCase { * @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')); diff --git a/cake/tests/cases/console/cake.test.php b/cake/tests/cases/console/cake.test.php index e5e0af1e6..9ec2e57dd 100644 --- a/cake/tests/cases/console/cake.test.php +++ b/cake/tests/cases/console/cake.test.php @@ -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 @@ class ShellDispatcherTest extends UnitTestCase { * @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 diff --git a/cake/tests/cases/console/libs/shell.test.php b/cake/tests/cases/console/libs/shell.test.php index e19dbd7cb..bfd15a95b 100644 --- a/cake/tests/cases/console/libs/shell.test.php +++ b/cake/tests/cases/console/libs/shell.test.php @@ -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 * diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 09a17b84e..0fcbfb3fb 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -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 @@ class DispatcherTest extends CakeTestCase { */ 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 @@ class DispatcherTest extends CakeTestCase { $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 @@ class DispatcherTest extends CakeTestCase { ) ); $this->assertEqual($result['data'], $expected); - - $_FILES = array(); } /** * testGetUrl method @@ -1614,6 +1636,7 @@ class DispatcherTest extends CakeTestCase { * @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)); diff --git a/cake/tests/cases/libs/cache/apc.test.php b/cake/tests/cases/libs/cache/apc.test.php index dcee499f6..5dd30c502 100644 --- a/cake/tests/cases/libs/cache/apc.test.php +++ b/cake/tests/cases/libs/cache/apc.test.php @@ -45,7 +45,7 @@ class ApcEngineTest extends UnitTestCase { 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 @@ class ApcEngineTest extends UnitTestCase { * @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 @@ class ApcEngineTest extends UnitTestCase { * @return void */ function tearDown() { + Configure::write('Cache.disable', $this->_cacheDisable); Cache::config('default'); } /** diff --git a/cake/tests/cases/libs/cache/file.test.php b/cake/tests/cases/libs/cache/file.test.php index cc8e0fbc6..89ee671bc 100644 --- a/cake/tests/cases/libs/cache/file.test.php +++ b/cake/tests/cases/libs/cache/file.test.php @@ -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 diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/cake/tests/cases/libs/cache/memcache.test.php index 09d454739..8a48df86c 100644 --- a/cake/tests/cases/libs/cache/memcache.test.php +++ b/cake/tests/cases/libs/cache/memcache.test.php @@ -26,7 +26,8 @@ */ if (!class_exists('Cache')) { require LIBS . 'cache.php'; -}/** +} +/** * MemcacheEngineTest class * * @package cake @@ -50,7 +51,7 @@ class MemcacheEngineTest extends CakeTestCase { 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 @@ class MemcacheEngineTest extends CakeTestCase { * @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 @@ class MemcacheEngineTest extends CakeTestCase { * @return void */ function tearDown() { + Configure::write('Cache.disable', $this->_cacheDisable); Cache::config('default'); } /** @@ -107,7 +111,7 @@ class MemcacheEngineTest extends CakeTestCase { } } - 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; } diff --git a/cake/tests/cases/libs/cache/xcache.test.php b/cake/tests/cases/libs/cache/xcache.test.php index 9a50a8757..842cbfa7b 100644 --- a/cake/tests/cases/libs/cache/xcache.test.php +++ b/cake/tests/cases/libs/cache/xcache.test.php @@ -45,7 +45,7 @@ class XcacheEngineTest extends UnitTestCase { 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 @@ class XcacheEngineTest extends UnitTestCase { * @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 @@ class XcacheEngineTest extends UnitTestCase { * @return void */ function tearDown() { + Configure::write('Cache.disable', $this->_cacheDisable); Cache::config('default'); } /** diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/cake/tests/cases/libs/cake_test_case.test.php index bd1550bf6..399106bc6 100644 --- a/cake/tests/cases/libs/cake_test_case.test.php +++ b/cake/tests/cases/libs/cake_test_case.test.php @@ -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'); diff --git a/cake/tests/cases/libs/code_coverage_manager.test.php b/cake/tests/cases/libs/code_coverage_manager.test.php index 842f83d0e..b7d67d05b 100644 --- a/cake/tests/cases/libs/code_coverage_manager.test.php +++ b/cake/tests/cases/libs/code_coverage_manager.test.php @@ -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 diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index f5da1d324..21fe13c30 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -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 @@ 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', 2); - parent::tearDown(); + Configure::write('debug', $this->_debug); + Configure::write('Cache.disable', $this->_cacheDisable); } /** * testListObjects method diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index 25b0d6fb6..cd99ec02c 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -62,9 +62,8 @@ if (!class_exists('AppController')) { * @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,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 * @@ -395,7 +405,9 @@ class ComponentTest extends CakeTestCase { * @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 @@ class ComponentTest extends CakeTestCase { )); } /** - * 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'); diff --git a/cake/tests/cases/libs/controller/components/acl.test.php b/cake/tests/cases/libs/controller/components/acl.test.php index e651ebe0d..755d7ae19 100644 --- a/cake/tests/cases/libs/controller/components/acl.test.php +++ b/cake/tests/cases/libs/controller/components/acl.test.php @@ -27,7 +27,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { define('CAKEPHP_UNIT_TEST_EXECUTION', 1); } -App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl')); +App::import(array('controller' .DS . 'components' . DS . 'acl', 'model' . DS . 'db_acl')); /** * AclNodeTwoTestBase class * diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 76d4c97b0..f10eae7a7 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -25,10 +25,8 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ App::import(array('controller' . DS . 'components' . DS .'auth', 'controller' . DS . 'components' . DS .'acl')); -App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl')); +App::import(array('controller' . DS . 'components' . DS . 'acl', 'model' . DS . 'db_acl')); App::import('Core', 'Xml'); - -Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi'); /** * TestAuthComponent class * @@ -437,6 +435,13 @@ class AuthTest extends CakeTestCase { * @return void */ function startTest() { + $this->_server = $_SERVER; + $this->_env = $_ENV; + + $this->_securitySalt = Configure::read('Security.salt'); + Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi'); + + $this->_acl = Configure::read('Acl'); Configure::write('Acl.database', 'test_suite'); Configure::write('Acl.classname', 'DbAcl'); @@ -444,17 +449,28 @@ class AuthTest extends CakeTestCase { $this->Controller->Component->init($this->Controller); ClassRegistry::addObject('view', new View($this->Controller)); + $this->Controller->Session->del('Auth'); $this->Controller->Session->del('Message.auth'); + + Router::reload(); + $this->initialized = true; } /** - * tearDown method + * endTest method * * @access public * @return void */ - function tearDown() { + function endTest() { + $_SERVER = $this->_server; + $_ENV = $this->_env; + Configure::write('Acl', $this->_acl); + Configure::write('Security.salt', $this->_securitySalt); + $this->Controller->Session->del('Auth'); + $this->Controller->Session->del('Message.auth'); + ClassRegistry::flush(); unset($this->Controller, $this->AuthUser); } /** @@ -578,7 +594,6 @@ class AuthTest extends CakeTestCase { $this->assertFalse($result); $this->assertTrue($this->Controller->Session->check('Message.auth')); - $this->Controller->params = Router::parse('auth_test/camelCase'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result); diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index bf42ad877..cfe806c06 100644 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -24,7 +24,6 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ -Configure::write('App.encoding', 'UTF-8'); App::import('Component', 'Email'); /** * EmailTestController class @@ -90,6 +89,9 @@ class EmailComponentTest extends CakeTestCase { * @return void */ function setUp() { + $this->_appEncoding = Configure::read('App.encoding'); + Configure::write('App.encoding', 'UTF-8'); + $this->Controller =& new EmailTestController(); restore_error_handler(); @@ -98,9 +100,24 @@ class EmailComponentTest extends CakeTestCase { $this->Controller->Email->initialize($this->Controller, array()); ClassRegistry::addObject('view', new View($this->Controller)); + + $this->_viewPaths = Configure::read('viewPaths'); Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); } +/** + * tearDown method + * + * @access public + * @return void + */ + function tearDown() { + Configure::write('App.encoding', $this->_appEncoding); + Configure::write('viewPaths', $this->_viewPaths); + $this->Controller->Session->del('Message'); + restore_error_handler(); + ClassRegistry::flush(); + } /** * testBadSmtpSend method * @@ -119,7 +136,7 @@ class EmailComponentTest extends CakeTestCase { * @return void */ function testSmtpSend() { - if (!$this->skipIf(!@fsockopen('localhost', 25), 'No SMTP server running on localhost')) { + if (!$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } $this->Controller->Email->reset(); @@ -167,7 +184,7 @@ TEMPDOC; * @return void */ function testAuthenticatedSmtpSend() { - $this->skipIf(!@fsockopen('localhost', 25), 'No SMTP server running on localhost'); + $this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost'); $this->Controller->Email->reset(); $this->Controller->Email->to = 'postmaster@localhost'; @@ -181,7 +198,7 @@ TEMPDOC; $this->Controller->Email->delivery = 'smtp'; $result = $this->Controller->Email->send('This is the body of the message'); $code = substr($this->Controller->Email->smtpError, 0, 3); - $this->skipIf(!$code, 'Authentication not enabled on server'); + $this->skipIf(!$code, '%s Authentication not enabled on server'); $this->assertTrue(!$result && $code == '535'); } /** diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index 8314a18a2..0ef3dc24c 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -141,7 +141,6 @@ class SecurityComponentTest extends CakeTestCase { $this->Controller->Component->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!'); } @@ -152,10 +151,11 @@ class SecurityComponentTest extends CakeTestCase { * @return void */ function tearDown() { + Configure::write('Security.salt', $this->oldSalt); + $this->Controller->Session->del('_Token'); unset($this->Controller->Security); unset($this->Controller->Component); unset($this->Controller); - Configure::write('Security.salt', $this->oldSalt); } /** * testStartup method diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/cake/tests/cases/libs/controller/components/session.test.php index 1fe1f61e6..b79f043c9 100644 --- a/cake/tests/cases/libs/controller/components/session.test.php +++ b/cake/tests/cases/libs/controller/components/session.test.php @@ -81,6 +81,24 @@ class OrangeSessionTestController extends Controller { * @subpackage cake.tests.cases.libs.controller.components */ class SessionComponentTest extends CakeTestCase { +/** + * setUp method + * + * @access public + * @return void + */ + function setUp() { + $this->_session = Configure::read('Session'); + } +/** + * tearDown method + * + * @access public + * @return void + */ + function tearDown() { + Configure::write('Session', $this->_session); + } /** * testSessionAutoStart method * @@ -322,6 +340,8 @@ class SessionComponentTest extends CakeTestCase { $Session->setFlash('This is a test message', 'non_existing_layout'); $this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'layout' => 'default', 'params' => array())); + + $Session->del('Message'); } /** * testSessionId method diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 5e16708a8..753717ec8 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -63,7 +63,7 @@ if (!class_exists('AppController')) { */ var $components = array('Cookie'); } -} else if (!defined('APP_CONTROLLER_EXISTS')) { +} elseif (!defined('APP_CONTROLLER_EXISTS')) { define('APP_CONTROLLER_EXISTS', true); } /** @@ -867,7 +867,9 @@ class ControllerTest extends CakeTestCase { * @return void */ function testMergeVars() { - $this->skipIf(defined('APP_CONTROLLER_EXISTS'), 'MergeVars 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; + } $TestController =& new TestController(); $TestController->constructClasses(); diff --git a/cake/tests/cases/libs/controller/pages_controller.test.php b/cake/tests/cases/libs/controller/pages_controller.test.php index 6bb17a18e..66980e744 100644 --- a/cake/tests/cases/libs/controller/pages_controller.test.php +++ b/cake/tests/cases/libs/controller/pages_controller.test.php @@ -24,7 +24,12 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ -App::import('Core', array('Controller', 'AppController', 'PagesController')); +if (!class_exists('AppController')) { + require_once LIBS . 'controller' . DS . 'app_controller.php'; +} elseif (!defined('APP_CONTROLLER_EXISTS')) { + define('APP_CONTROLLER_EXISTS', true); +} +App::import('Core', array('Controller', 'PagesController')); /** * PagesControllerTest class * @@ -32,6 +37,24 @@ App::import('Core', array('Controller', 'AppController', 'PagesController')); * @subpackage cake.tests.cases.libs.controller */ class PagesControllerTest extends CakeTestCase { +/** + * setUp method + * + * @access public + * @return void + */ + function setUp() { + $this->_viewPaths = Configure::read('viewPaths'); + } +/** + * tearDown method + * + * @access public + * @return void + */ + function tearDown() { + Configure::write('viewPaths', $this->_viewPaths); + } /** * testDisplay method * @@ -39,6 +62,10 @@ class PagesControllerTest extends CakeTestCase { * @return void */ function testDisplay() { + if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) { + return; + } + Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)); $Pages =& new PagesController(); diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php index 57f8b03dc..3efbb9465 100644 --- a/cake/tests/cases/libs/debugger.test.php +++ b/cake/tests/cases/libs/debugger.test.php @@ -218,15 +218,14 @@ class DebuggerTest extends CakeTestCase { Debugger::log('cool'); $result = file_get_contents(LOGS . 'debug.log'); - $this->assertPattern('/DebuggerTest::testLog/', $result); + $this->assertPattern('/DebuggerTest\:\:testLog/', $result); $this->assertPattern('/"cool"/', $result); unlink(TMP . 'logs' . DS . 'debug.log'); Debugger::log(array('whatever', 'here')); $result = file_get_contents(TMP . 'logs' . DS . 'debug.log'); - - $this->assertPattern('/DebuggerTest::testLog/', $result); + $this->assertPattern('/DebuggerTest\:\:testLog/', $result); $this->assertPattern('/array/', $result); $this->assertPattern('/"whatever",/', $result); $this->assertPattern('/"here"/', $result); diff --git a/cake/tests/cases/libs/error.test.php b/cake/tests/cases/libs/error.test.php index ef09072c0..e3d233e1e 100644 --- a/cake/tests/cases/libs/error.test.php +++ b/cake/tests/cases/libs/error.test.php @@ -95,48 +95,50 @@ class AuthBlueberryUser extends CakeTestModel { var $useTable = false; } if (!class_exists('AppController')) { -/** - * AppController class - * - * @package cake - * @subpackage cake.tests.cases.libs - */ -class AppController extends Controller { -/** - * components property - * - * @access public - * @return void - */ - var $components = array('Blueberry'); -/** - * beforeRender method - * - * @access public - * @return void - */ - function beforeRender() { - echo $this->Blueberry->testName; + /** + * AppController class + * + * @package cake + * @subpackage cake.tests.cases.libs + */ + class AppController extends Controller { + /** + * components property + * + * @access public + * @return void + */ + var $components = array('Blueberry'); + /** + * beforeRender method + * + * @access public + * @return void + */ + function beforeRender() { + echo $this->Blueberry->testName; + } + /** + * header method + * + * @access public + * @return void + */ + function header($header) { + echo $header; + } + /** + * _stop method + * + * @access public + * @return void + */ + function _stop($status = 0) { + echo 'Stopped with status: ' . $status; + } } -/** - * header method - * - * @access public - * @return void - */ - function header($header) { - echo $header; - } -/** - * _stop method - * - * @access public - * @return void - */ - function _stop($status = 0) { - echo 'Stopped with status: ' . $status; - } -} +} elseif (!defined('APP_CONTROLLER_EXISTS')){ + define('APP_CONTROLLER_EXISTS', true); } App::import('Core', array('Error', 'Controller')); /** @@ -224,7 +226,7 @@ class ErrorHandlerTest extends CakeTestCase { * @return void */ function skip() { - $this->skipif ((PHP_SAPI == 'cli'), 'TestErrorHandlerTest cannot be run from console'); + $this->skipIf(PHP_SAPI === 'cli', '%s Cannot be run from console'); } /** * testError method @@ -277,6 +279,8 @@ class ErrorHandlerTest extends CakeTestCase { * @return void */ function testMissingController() { + $this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController'); + ob_start(); $TestErrorHandler = new TestErrorHandler('missingController', array('className' => 'PostsController')); $result = ob_get_clean(); diff --git a/cake/tests/cases/libs/file.test.php b/cake/tests/cases/libs/file.test.php index 2daff0f20..f0d64a7bf 100644 --- a/cake/tests/cases/libs/file.test.php +++ b/cake/tests/cases/libs/file.test.php @@ -95,7 +95,7 @@ class FileTest extends CakeTestCase { $result = $this->File->Folder(); $this->assertIsA($result, 'Folder'); - $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'File permissions tests not supported on Windows'); + $this->skipIf(DIRECTORY_SEPARATOR === '\\', '%s File permissions tests not supported on Windows'); $result = $this->File->perms(); $expecting = '0644'; $this->assertEqual($result, $expecting); diff --git a/cake/tests/cases/libs/flay.test.php b/cake/tests/cases/libs/flay.test.php index 2e8f8c639..79e55c95e 100644 --- a/cake/tests/cases/libs/flay.test.php +++ b/cake/tests/cases/libs/flay.test.php @@ -31,7 +31,7 @@ uses('flay'); * @package cake * @subpackage cake.tests.cases.libs */ -class FlayTest extends UnitTestCase { +class FlayTest extends CakeTestCase { /** * skip method * @@ -39,7 +39,7 @@ class FlayTest extends UnitTestCase { * @return void */ function skip() { - $this->skipif(true, 'FlayTest not implemented'); + $this->skipIf(true, '%s FlayTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/folder.test.php b/cake/tests/cases/libs/folder.test.php index d9edfc83f..2e9bc4567 100644 --- a/cake/tests/cases/libs/folder.test.php +++ b/cake/tests/cases/libs/folder.test.php @@ -161,7 +161,7 @@ class FolderTest extends CakeTestCase { * @access public */ function testChmod() { - $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Folder permissions tests not supported on Windows'); + $this->skipIf(DIRECTORY_SEPARATOR === '\\', '%s Folder permissions tests not supported on Windows'); $path = TEST_CAKE_CORE_INCLUDE_PATH . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel'; $Folder =& new Folder($path); diff --git a/cake/tests/cases/libs/i18n.test.php b/cake/tests/cases/libs/i18n.test.php index 89d87cc23..4a1183036 100644 --- a/cake/tests/cases/libs/i18n.test.php +++ b/cake/tests/cases/libs/i18n.test.php @@ -39,8 +39,18 @@ class I18nTest 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')); } +/** + * tearDown method + * + * @access public + * @return void + */ + function tearDown() { + Configure::write('localePaths', $this->_localePaths); + } /** * testDefaultStrings method * diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index 089fe5e9c..9aa007187 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -32,13 +32,6 @@ App::import('Core', 'Inflector'); * @subpackage cake.tests.cases.libs */ class InflectorTest extends CakeTestCase { -/** - * Inflector property - * - * @var mixed null - * @access public - */ - var $Inflector = null; /** * setUp method * @@ -46,7 +39,6 @@ class InflectorTest extends CakeTestCase { * @return void */ function setUp() { - $this->Inflector = Inflector::getInstance(); } /** * tearDown method @@ -55,7 +47,6 @@ class InflectorTest extends CakeTestCase { * @return void */ function tearDown() { - unset($this->Inflector); } /** * testInstantiation method @@ -64,7 +55,10 @@ class InflectorTest extends CakeTestCase { * @return void */ function testInstantiation() { - $this->assertEqual(new Inflector(), $this->Inflector); + $this->skipUnless(strpos(Debugger::trace(), 'GroupTest') === false, '%s Cannot be run from within a group test'); + + $Instance = Inflector::getInstance(); + $this->assertEqual(new Inflector(), $Instance); } /** * testInflectingSingulars method diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php index 72c65fb80..45f71fe16 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php @@ -164,7 +164,6 @@ if (!class_exists('Article')) { * @access public */ var $name = 'Article'; - } } /** @@ -196,7 +195,7 @@ class DboAdodbTest extends CakeTestCase { function skip() { $this->_initDb(); $db =& ConnectionManager::getDataSource('test_suite'); - $this->skipif($db->config['driver'] != 'adodb', 'Adodb connection not available'); + $this->skipIf($db->config['driver'] != 'adodb', '%s Adodb connection not available'); } /** * Sets up a Dbo class instance for testing diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php index ab5592200..d2c3411f7 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php @@ -219,7 +219,7 @@ class DboMssqlTest extends CakeTestCase { */ function skip() { $this->_initDb(); - $this->skipif ($this->db->config['driver'] != 'mssql', 'SQL Server connection not available'); + $this->skipUnless($this->db->config['driver'] == 'mssql', '%s SQL Server connection not available'); } /** * Sets up a Dbo class instance for testing @@ -240,7 +240,6 @@ class DboMssqlTest extends CakeTestCase { function tearDown() { unset($this->model); } - /** * testQuoting method * diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 3d94dc6af..691a86c1f 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -167,7 +167,7 @@ class DboMysqlTest extends CakeTestCase { */ function skip() { $this->_initDb(); - $this->skipif($this->db->config['driver'] != 'mysql', 'MySQL connection not available'); + $this->skipUnless($this->db->config['driver'] == 'mysql', '%s MySQL connection not available'); } /** * Sets up a Dbo class instance for testing diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php index 9031164dd..a2d86a574 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php @@ -168,7 +168,7 @@ class DboMysqliTest extends CakeTestCase { */ function skip() { $this->_initDb(); - $this->skipif($this->db->config['driver'] != 'mysqli', 'MySQLi connection not available'); + $this->skipUnless($this->db->config['driver'] == 'mysqli', '%s MySQLi connection not available'); } /** * Sets up a Dbo class instance for testing diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php index 314fcfce8..6b835890a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php @@ -55,9 +55,7 @@ class DboOracleTest extends CakeTestCase { */ function skip() { $this->_initDb(); - $this->skipif( - $this->db->config['driver'] != 'oracle', 'Oracle connection not available' - ); + $this->skipUnless($this->db->config['driver'] == 'oracle', '%s Oracle connection not available'); } /** * testLastErrorStatement method diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index bae7ad584..6c387da43 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -180,7 +180,7 @@ class DboPostgresTest extends CakeTestCase { */ function skip() { $this->_initDb(); - $this->skipif($this->db->config['driver'] != 'postgres', 'PostgreSQL connection not available'); + $this->skipUnless($this->db->config['driver'] == 'postgres', '%s PostgreSQL connection not available'); } /** * Set up test suite database connection diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php index adfad9dbc..882a91e9e 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php @@ -100,7 +100,7 @@ class DboSqliteTest extends CakeTestCase { */ function skip() { $this->_initDb(); - $this->skipif($this->db->config['driver'] != 'sqlite', 'SQLite connection not available'); + $this->skipUnless($this->db->config['driver'] == 'sqlite', '%s SQLite connection not available'); } /** * Set up test suite database connection diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index a4845b77f..270565701 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -1815,10 +1815,11 @@ class ModelTest extends CakeTestCase { /** * Test find(count) with Db::expression * + * @access public * @return void - **/ + */ function testFindCountWithDbExpressions() { - if ($this->skipif($this->db->config['driver'] == 'postgres', 'testFindCountWithExpressions is not compatible with Postgres')) { + if ($this->skipIf($this->db->config['driver'] == 'postgres', '%s testFindCountWithExpressions is not compatible with Postgres')) { return; } $this->loadFixtures('Project'); @@ -4795,7 +4796,7 @@ class ModelTest extends CakeTestCase { $this->assertFalse($expected); } // function testBasicValidation() { - // $TestModel =& new ValidationTest(); + // $TestModel =& new ValidationTest1(); // $TestModel->testing = true; // $TestModel->set(array('title' => '', 'published' => 1)); // $this->assertEqual($TestModel->invalidFields(), array('title' => 'This field cannot be left blank')); @@ -4936,7 +4937,7 @@ class ModelTest extends CakeTestCase { * @return void */ function testMultipleValidation() { - $TestModel =& new ValidationTest(); + $TestModel =& new ValidationTest1(); } /** * Tests validation parameter order in custom validation methods @@ -4945,7 +4946,7 @@ class ModelTest extends CakeTestCase { * @return void */ function testValidationParams() { - $TestModel =& new ValidationTest(); + $TestModel =& new ValidationTest1(); $TestModel->validate['title'] = array('rule' => 'customValidatorWithParams', 'required' => true); $TestModel->create(array('title' => 'foo')); $TestModel->invalidFields(); @@ -4972,7 +4973,7 @@ class ModelTest extends CakeTestCase { * @return void */ function testInvalidFieldsWithFieldListParams() { - $TestModel =& new ValidationTest(); + $TestModel =& new ValidationTest1(); $TestModel->validate = $validate = array( 'title' => array('rule' => 'customValidator', 'required' => true), 'name' => array('rule' => 'allowEmpty', 'required' => true), @@ -5007,10 +5008,10 @@ class ModelTest extends CakeTestCase { * @return void */ function testAllowSimulatedFields() { - $TestModel =& new ValidationTest(); + $TestModel =& new ValidationTest1(); $TestModel->create(array('title' => 'foo', 'bar' => 'baz')); - $expected = array('ValidationTest' => array('title' => 'foo', 'bar' => 'baz')); + $expected = array('ValidationTest1' => array('title' => 'foo', 'bar' => 'baz')); $this->assertEqual($TestModel->data, $expected); } /** @@ -5020,7 +5021,7 @@ class ModelTest extends CakeTestCase { * @return void */ function testInvalidAssociation() { - $TestModel =& new ValidationTest(); + $TestModel =& new ValidationTest1(); $this->assertNull($TestModel->getAssociated('Foo')); } /** @@ -5533,7 +5534,7 @@ class ModelTest extends CakeTestCase { function testZeroDefaultFieldValue() { $this->skipIf( $this->db->config['driver'] == 'sqlite', - 'SQLite uses loose typing, this operation is unsupported' + '%s SQLite uses loose typing, this operation is unsupported' ); $this->loadFixtures('DataTest'); $TestModel =& new DataTest(); @@ -6162,7 +6163,7 @@ class ModelTest extends CakeTestCase { function testGroupBy() { $db = ConnectionManager::getDataSource('test_suite'); $isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle')); - if ($this->skipif($isStrictGroupBy, 'Postgresql and Oracle have strict GROUP BY and are incompatible with this test.')) { + if ($this->skipIf($isStrictGroupBy, '%s Postgresql and Oracle have strict GROUP BY and are incompatible with this test.')) { return; } diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php index 8f1423e9c..839e9f6ab 100644 --- a/cake/tests/cases/libs/model/models.php +++ b/cake/tests/cases/libs/model/models.php @@ -1804,19 +1804,19 @@ class TheVoid extends CakeTestModel { var $useTable = false; } /** - * ValidationTest class + * ValidationTest1 class * * @package cake * @subpackage cake.tests.cases.libs.model */ -class ValidationTest extends CakeTestModel { +class ValidationTest1 extends CakeTestModel { /** * name property * * @var string 'ValidationTest' * @access public */ - var $name = 'ValidationTest'; + var $name = 'ValidationTest1'; /** * useTable property * diff --git a/cake/tests/cases/libs/overloadable.test.php b/cake/tests/cases/libs/overloadable.test.php index 5c0363ad5..ed06e8cc7 100644 --- a/cake/tests/cases/libs/overloadable.test.php +++ b/cake/tests/cases/libs/overloadable.test.php @@ -39,7 +39,7 @@ class OverloadableTest extends CakeTestCase { * @return void */ function skip() { - $this->skipif(true, 'OverloadableTest not implemented'); + $this->skipIf(true, ' %s OverloadableTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/security.test.php b/cake/tests/cases/libs/security.test.php index 4c2e97019..f00af06b7 100644 --- a/cake/tests/cases/libs/security.test.php +++ b/cake/tests/cases/libs/security.test.php @@ -90,6 +90,9 @@ class SecurityTest extends CakeTestCase { * @return void */ function testHash() { + $Security = Security::getInstance(); + $_hashType = $Security->hashType; + $key = 'someKey'; $hash = 'someHash'; @@ -126,6 +129,8 @@ class SecurityTest extends CakeTestCase { $this->assertIdentical(strlen(Security::hash($key, 'sha256', false)), 64); $this->assertIdentical(strlen(Security::hash($key, 'sha256', true)), 64); } + + Security::setHash($_hashType); } /** * testCipher method diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 60b6a187b..98c3e6866 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -65,6 +65,16 @@ class ValidationTest extends CakeTestCase { */ function setUp() { $this->Validation =& Validation::getInstance(); + $this->_appEncoding = Configure::read('App.encoding'); + } +/** + * tearDown method + * + * @access public + * @return void + */ + function tearDown() { + Configure::write('App.encoding', $this->_appEncoding); } /** * testNotEmpty method diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index 57f3a9c9b..efdbdafcc 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -72,6 +72,7 @@ class HtmlHelperTest extends CakeTestCase { $this->Html =& new HtmlHelper(); $view =& new View(new TheHtmlTestController()); ClassRegistry::addObject('view', $view); + $this->_appEncoding = Configure::read('App.encoding'); } /** * tearDown method @@ -80,7 +81,8 @@ class HtmlHelperTest extends CakeTestCase { * @return void */ function tearDown() { - unset($this->Html); + Configure::write('App.encoding', $this->_appEncoding); + ClassRegistry::flush(); } /** * testDocType method diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php index 6a56c1efc..d0307089b 100644 --- a/cake/tests/cases/libs/view/helpers/js.test.php +++ b/cake/tests/cases/libs/view/helpers/js.test.php @@ -48,7 +48,7 @@ class JsHelperTest extends UnitTestCase { * @return void */ function skip() { - $this->skipif (true, 'JsHelper test not implemented'); + $this->skipIf(true, '%s JsHelper test not implemented'); } /** * setUp method diff --git a/cake/tests/groups/cache.group.php b/cake/tests/groups/cache.group.php index fd7060909..85b40cc02 100644 --- a/cake/tests/groups/cache.group.php +++ b/cake/tests/groups/cache.group.php @@ -1,7 +1,7 @@ + * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake + * @subpackage cake.tests.groups + * @since CakePHP(tm) v 1.2.0.4206 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +/** + * NoCrossContaminationGroupTest class + * + * This test group will run all tests + * that are proper isolated to be run in sequence + * without affected each other + * + * @package cake + * @subpackage cake.tests.groups + */ +class NoCrossContaminationGroupTest extends GroupTest { +/** + * label property + * + * @var string + * @access public + */ + var $label = 'No Cross Contamination'; +/** + * blacklist property + * + * @var string + * @access public + */ + var $blacklist = array('cake_test_case.test.php', 'object.test.php'); +/** + * NoCrossContaminationGroupTest method + * + * @access public + * @return void + */ + function NoCrossContaminationGroupTest() { + App::import('Core', 'Folder'); + + $Folder = new Folder(CORE_TEST_CASES); + + foreach ($Folder->findRecursive('.*\.test\.php', true) as $file) { + if (in_array(basename($file), $this->blacklist)) { + continue; + } + TestManager::addTestFile($this, $file); + } + } +} +?> \ No newline at end of file diff --git a/cake/tests/groups/no_database.group.php b/cake/tests/groups/no_database.group.php index f8071959f..f23f6be7f 100644 --- a/cake/tests/groups/no_database.group.php +++ b/cake/tests/groups/no_database.group.php @@ -1,7 +1,7 @@ testCase =& $testCase; } - - function _invoke (&$controller, $params, $missingAction = false) { +/** + * invoke method + * + * @param Controller $controller + * @param array $params + * @param boolean $missingAction + * @return Controller + * @access proptected + */ + function _invoke(&$controller, $params, $missingAction = false) { $this->controller =& $controller; if (isset($this->testCase) && method_exists($this->testCase, 'startController')) { @@ -61,7 +81,7 @@ class CakeTestDispatcher extends Dispatcher { } } /** - * Short description for class. + * CakeTestCase class * * @package cake * @subpackage cake.cake.tests.lib @@ -71,11 +91,9 @@ class CakeTestCase extends UnitTestCase { * Methods used internally. * * @var array - * @access private + * @access public */ var $methods = array('start', 'end', 'startcase', 'endcase', 'starttest', 'endtest'); - var $__truncated = true; - var $__savedGetData = array(); /** * By default, all fixtures attached to this class will be truncated and reloaded after each test. * Set this to false to handle manually @@ -98,44 +116,64 @@ class CakeTestCase extends UnitTestCase { * @access protected */ var $_fixtureClassMap = array(); +/** + * truncated property + * + * @var boolean + * @access private + */ + var $__truncated = true; +/** + * savedGetData property + * + * @var array + * @access private + */ + var $__savedGetData = array(); /** * Called when a test case (group of methods) is about to start (to be overriden when needed.) * - * @param string $method Test method about to get executed. - * - * @access protected + * @param string $method Test method about to get executed. + * @return void + * @access public */ function startCase() { } /** * Called when a test case (group of methods) has been executed (to be overriden when needed.) * - * @param string $method Test method about that was executed. - * - * @access protected + * @param string $method Test method about that was executed. + * @return void + * @access public */ function endCase() { } /** * Called when a test case method is about to start (to be overriden when needed.) * - * @param string $method Test method about to get executed. - * - * @access protected + * @param string $method Test method about to get executed. + * @return void + * @access public */ function startTest($method) { } /** * Called when a test case method has been executed (to be overriden when needed.) * - * @param string $method Test method about that was executed. - * - * @access protected + * @param string $method Test method about that was executed. + * @return void + * @access public */ function endTest($method) { } /** * Overrides SimpleTestCase::assert to enable calling of skipIf() from within tests + * + * @param Expectation $expectation + * @param mixed $compare + * @param string $message + * @return boolean|null + * @access public */ function assert(&$expectation, $compare, $message = '%s') { if ($this->_should_skip) { @@ -145,6 +183,11 @@ class CakeTestCase extends UnitTestCase { } /** * Overrides SimpleTestCase::skipIf to provide a boolean return value + * + * @param boolean $shouldSkip + * @param string $message + * @return boolean + * @access public */ function skipIf($shouldSkip, $message = '%s') { parent::skipIf($shouldSkip, $message); @@ -155,6 +198,8 @@ class CakeTestCase extends UnitTestCase { * * @param Controller $controller Controller that's about to be invoked. * @param array $params Additional parameters as sent by testAction(). + * @return void + * @access public */ function startController(&$controller, $params = array()) { if (isset($params['fixturize']) && ((is_array($params['fixturize']) && !empty($params['fixturize'])) || $params['fixturize'] === true)) { @@ -219,8 +264,10 @@ class CakeTestCase extends UnitTestCase { /** * Callback issued when a controller's action has been invoked through testAction(). * - * @param Controller $controller Controller that has been invoked. - * * @param array $params Additional parameters as sent by testAction(). + * @param Controller $controller Controller that has been invoked. + * @param array $params Additional parameters as sent by testAction(). + * @return void + * @access public */ function endController(&$controller, $params = array()) { if (isset($this->db) && isset($this->_actionFixtures) && !empty($this->_actionFixtures) && $this->dropTables) { @@ -238,12 +285,12 @@ class CakeTestCase extends UnitTestCase { * 2. 'view': The rendered view, without the layout * 3. 'contents': The rendered view, within the layout. * 4. 'vars': the view vars - * + * * - 'fixturize' - Set to true if you want to copy model data from 'connection' to the test_suite connection * - 'data' - The data you want to insert into $this->data in the controller. * - 'connection' - Which connection to use in conjunction with fixturize (defaults to 'default') * - 'method' - What type of HTTP method to simulate (defaults to post) - * + * * @param string $url Cake URL to execute (e.g: /articles/view/455) * @param mixed $params Parameters (see above), or simply a string of what to return * @return mixed Whatever is returned depending of requested result @@ -333,7 +380,7 @@ class CakeTestCase extends UnitTestCase { * Announces the start of a test. * * @param string $method Test method just started. - * + * @return void * @access public */ function before($method) { @@ -363,6 +410,7 @@ class CakeTestCase extends UnitTestCase { /** * Runs as first test to create tables. * + * @return void * @access public */ function start() { @@ -389,6 +437,7 @@ class CakeTestCase extends UnitTestCase { /** * Runs as last test to drop tables. * + * @return void * @access public */ function end() { @@ -410,7 +459,7 @@ class CakeTestCase extends UnitTestCase { * Announces the end of a test. * * @param string $method Test method just finished. - * + * @return void * @access public */ function after($method) { @@ -436,8 +485,7 @@ class CakeTestCase extends UnitTestCase { * Gets a list of test names. Normally that will be all internal methods that start with the * name "test". This method should be overridden if you want a different rule. * - * @return array List of test names. - * + * @return array List of test names. * @access public */ function getTests() { @@ -452,6 +500,7 @@ class CakeTestCase extends UnitTestCase { * * @param string $fixture Each parameter is a model name that corresponds to a * fixture, i.e. 'Post', 'Author', etc. + * @return void * @access public * @see CakeTestCase::$autoFixtures */ @@ -499,6 +548,7 @@ class CakeTestCase extends UnitTestCase { * @param string $string An HTML/XHTML/XML string * @param array $expected An array, see above * @param string $message SimpleTest failure output string + * @return boolean * @access public */ function assertTags($string, $expected, $fullDebug = false) { @@ -619,36 +669,10 @@ class CakeTestCase extends UnitTestCase { } return $this->assert(new TrueExpectation(), true, '%s'); } -/** - * Generates all permutation of an array $items and returns them in a new array. - * - * @param array $items An array of items - * @return array - * @access public - */ - function __array_permute($items, $perms = array()) { - static $permuted; - if (empty($perms)) { - $permuted = array(); - } - - if (empty($items)) { - $permuted[] = $perms; - } else { - $numItems = count($items) - 1; - for ($i = $numItems; $i >= 0; --$i) { - $newItems = $items; - $newPerms = $perms; - list($tmp) = array_splice($newItems, $i, 1); - array_unshift($newPerms, $tmp); - $this->__array_permute($newItems, $newPerms); - } - return $permuted; - } - } /** * Initialize DB connection. * + * @return void * @access protected */ function _initDb() { @@ -683,7 +707,8 @@ class CakeTestCase extends UnitTestCase { /** * Load fixtures specified in var $fixtures. * - * @access private + * @return void + * @access protected */ function _loadFixtures() { if (!isset($this->fixtures) || empty($this->fixtures)) { @@ -753,5 +778,32 @@ class CakeTestCase extends UnitTestCase { unset($this->_fixtures); } } +/** + * Generates all permutation of an array $items and returns them in a new array. + * + * @param array $items An array of items + * @return array + * @access private + */ + function __array_permute($items, $perms = array()) { + static $permuted; + if (empty($perms)) { + $permuted = array(); + } + + if (empty($items)) { + $permuted[] = $perms; + } else { + $numItems = count($items) - 1; + for ($i = $numItems; $i >= 0; --$i) { + $newItems = $items; + $newPerms = $perms; + list($tmp) = array_splice($newItems, $i, 1); + array_unshift($newPerms, $tmp); + $this->__array_permute($newItems, $newPerms); + } + return $permuted; + } + } } -?> +?> \ No newline at end of file