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

Adding NoCrossContamination group
Shortening group class names
Renaming lib_controller group
Updating test imports to include the core AppController by default
Some cosmetics




git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8123 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
davidpersson 2009-03-21 23:55:39 +00:00
parent fc7773fe2d
commit fd7d6718a1
51 changed files with 536 additions and 239 deletions

View file

@ -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'));

View file

@ -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

View file

@ -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
*

View file

@ -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));

View file

@ -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');
}
/**

View file

@ -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

View file

@ -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;
}

View file

@ -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');
}
/**

View file

@ -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');

View file

@ -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

View file

@ -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

View file

@ -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');

View file

@ -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
*

View file

@ -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);

View file

@ -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');
}
/**

View file

@ -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

View file

@ -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

View file

@ -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();

View file

@ -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();

View file

@ -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);

View file

@ -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();

View file

@ -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);

View file

@ -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');
}
}
?>

View file

@ -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);

View file

@ -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
*

View file

@ -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

View file

@ -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

View file

@ -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
*

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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
*

View file

@ -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');
}
}
?>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* AllCacheEnginesGroupTest file
* CacheGroupTest file
*
* Long description for file
*
@ -25,14 +25,14 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* AllCacheEnginesGroupTest class
* CacheGroupTest class
*
* This test group will run all the Cache class test and all core cache engine tests
*
* @package cake
* @subpackage cake.tests.groups
*/
class AllCacheEnginesGroupTest extends GroupTest {
class CacheGroupTest extends GroupTest {
/**
* label property
*
@ -41,12 +41,12 @@ class AllCacheEnginesGroupTest extends GroupTest {
*/
var $label = 'Cache and all CacheEngines';
/**
* AllCacheEnginesGroupTest method
* CacheGroupTest method
*
* @access public
* @return void
*/
function AllCacheEnginesGroupTest() {
function CacheGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cache');
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cache');
}

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* AllCoreComponentsGroupTest file
* ComponentsGroupTest file
*
* Long description for file
*
@ -25,14 +25,14 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* AllCoreComponentsGroupTest class
* ComponentsGroupTest class
*
* This test group will run all tests in the cases/libs/controller/components directory.
*
* @package cake
* @subpackage cake.tests.groups
*/
class AllCoreComponentsGroupTest extends GroupTest {
class ComponentsGroupTest extends GroupTest {
/**
* label property
*
@ -41,12 +41,12 @@ class AllCoreComponentsGroupTest extends GroupTest {
*/
var $label = 'All Components';
/**
* AllCoreComponentsGroupTest method
* CoreComponentsGroupTest method
*
* @access public
* @return void
*/
function AllCoreComponentsGroupTest() {
function ComponentsGroupTest() {
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components');
}
}

View file

@ -25,14 +25,14 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* AllConsoleGroupTest class
* ConsoleGroupTest class
*
* This test group will run all console tests
*
* @package cake
* @subpackage cake.tests.groups
*/
class AllConsoleGroupTest extends GroupTest {
class ConsoleGroupTest extends GroupTest {
/**
* label property
*
@ -41,12 +41,12 @@ class AllConsoleGroupTest extends GroupTest {
*/
var $label = 'ShellDispatcher, Shell and all Tasks';
/**
* AllConsoleGroupTest method
* ConsoleGroupTest method
*
* @access public
* @return void
*/
function AllConsoleGroupTest() {
function ConsoleGroupTest() {
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'console');
}
}

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* LibControllerGroupTest file
* ControllerGroupTest file
*
* Long description for file
*
@ -25,12 +25,12 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* LibControllerGroupTest
* ControllerGroupTest
*
* @package cake
* @subpackage cake.tests.groups
*/
class LibControllerGroupTest extends GroupTest {
class ControllerGroupTest extends GroupTest {
/**
* label property
*
@ -44,7 +44,7 @@ class LibControllerGroupTest extends GroupTest {
* @access public
* @return void
*/
function LibControllerGroupTest() {
function ControllerGroupTest() {
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'controller');
}
}

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* AllCoreHelpersGroupTest file
* HelpersGroupTest file
*
* Long description for file
*
@ -25,14 +25,14 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* AllCoreHelpersGroupTest class
* HelpersGroupTest class
*
* This test group will run all test in the cases/libs/view/helpers directory.
*
* @package cake
* @subpackage cake.tests.groups
*/
class AllCoreHelpersGroupTest extends GroupTest {
class HelpersGroupTest extends GroupTest {
/**
* label property
*
@ -41,12 +41,12 @@ class AllCoreHelpersGroupTest extends GroupTest {
*/
var $label = 'All Helpers';
/**
* AllCoreHelpersGroupTest method
* HelpersGroupTest method
*
* @access public
* @return void
*/
function AllCoreHelpersGroupTest() {
function HelpersGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helper');
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers');
}

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* AllCoreLibGroupTest file
* LibGroupTest file
*
* Long description for file
*
@ -25,14 +25,14 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* AllCoreLibGroupTest class
* LibGroupTest class
*
* This test group will run all test in the cases/libs directory.
*
* @package cake
* @subpackage cake.tests.groups
*/
class AllCoreLibGroupTest extends GroupTest {
class LibGroupTest extends GroupTest {
/**
* label property
*
@ -41,12 +41,12 @@ class AllCoreLibGroupTest extends GroupTest {
*/
var $label = 'All Libs';
/**
* AllCoreLibGroupTest method
* LibGroupTest method
*
* @access public
* @return void
*/
function AllCoreLibGroupTest() {
function LibGroupTest() {
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs');
}
}

View file

@ -0,0 +1,71 @@
<?php
/* SVN FILE: $Id$ */
/**
* NoCrossContaminationGroupTest file
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* 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);
}
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* AllCoreWithoutDatabaseGroupTest file
* NoDatabaseGroupTest file
*
* Long description for file
*
@ -25,14 +25,14 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* AllCoreWithOutDatabaseGroupTest class
* NoDatabaseGroupTest class
*
* This test group will run all test in the cases/libs directory.
*
* @package cake
* @subpackage cake.tests.groups
*/
class AllCoreWithoutDatabaseGroupTest extends GroupTest {
class NoDatabaseGroupTest extends GroupTest {
/**
* label property
*
@ -41,12 +41,12 @@ class AllCoreWithoutDatabaseGroupTest extends GroupTest {
*/
var $label = 'All Libs not requiring a database connection';
/**
* AllCoreWithOutDatabaseGroupTest method
* NoDatabaseGroupTest method
*
* @access public
* @return void
*/
function AllCoreWithoutDatabaseGroupTest() {
function NoDatabaseGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'dispatcher');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'router');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'inflector');

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* AllCoreViewsGroupTest file
* ViewsGroupTest file
*
* Long description for file
*
@ -25,14 +25,14 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* AllCoreViewsGroupTest class
* ViewsGroupTest class
*
* This test group will run view class tests (view, theme)
*
* @package cake
* @subpackage cake.tests.groups
*/
class AllCoreViewsGroupTest extends GroupTest {
class ViewsGroupTest extends GroupTest {
/**
* label property
*
@ -41,12 +41,12 @@ class AllCoreViewsGroupTest extends GroupTest {
*/
var $label = 'View and ThemeView';
/**
* AllCoreViewsGroupTest method
* ViewsGroupTest method
*
* @access public
* @return void
*/
function AllCoreViewsGroupTest() {
function ViewsGroupTest() {
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'view');
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'theme');
}

View file

@ -41,7 +41,7 @@ class XmlGroupTest extends GroupTest {
*/
var $label = 'Xml based classes (Xml, XmlHelper and RssHelper)';
/**
* AllCoreViewsGroupTest method
* XmlGroupTest method
*
* @access public
* @return void

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* CakeTestCase file
*
* Long description for file
*
@ -31,20 +31,40 @@ require_once CAKE_TESTS_LIB . 'cake_test_model.php';
require_once CAKE_TESTS_LIB . 'cake_test_fixture.php';
App::import('Vendor', 'simpletest' . DS . 'unit_tester');
/**
* Short description for class.
* CakeTestDispatcher
*
* @package cake
* @subpackage cake.cake.tests.lib
*/
class CakeTestDispatcher extends Dispatcher {
/**
* controller property
*
* @var Controller
* @access public
*/
var $controller;
var $testCase;
/**
* testCase method
*
* @param CakeTestCase $testCase
* @return void
* @access public
*/
function testCase(&$testCase) {
$this->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;
}
}
}
?>
?>