mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Starting initial refactoring of current code base.
Made changes to test suite to allow running test without headers already sent errors. Moved Component::initialize(), Controller::beforeFilter(); and Component::startup(); from Dipatcher::start() to Controller::constructClasses(); Removed Dispatcher::start(); Fixing model instances not being created Adding additional test to CookieComponent to increase coverage to 95% Optimizing Set::diff(); Fixing SessionComponent test and RequestHandlerComponent test Fixing CakeSession tests, removed deprecated code from CakeSession git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7162 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
70aa290f5b
commit
6807d4c333
19 changed files with 850 additions and 623 deletions
|
@ -153,4 +153,6 @@ if (isset($_GET['group'])) {
|
||||||
CakePHPTestGroupTestList();
|
CakePHPTestGroupTestList();
|
||||||
}
|
}
|
||||||
CakePHPTestSuiteFooter();
|
CakePHPTestSuiteFooter();
|
||||||
|
$output = ob_get_clean();
|
||||||
|
echo $output;
|
||||||
?>
|
?>
|
|
@ -153,4 +153,6 @@ if (isset($_GET['group'])) {
|
||||||
CakePHPTestGroupTestList();
|
CakePHPTestGroupTestList();
|
||||||
}
|
}
|
||||||
CakePHPTestSuiteFooter();
|
CakePHPTestSuiteFooter();
|
||||||
|
$output = ob_get_clean();
|
||||||
|
echo $output;
|
||||||
?>
|
?>
|
|
@ -86,11 +86,11 @@ class Dispatcher extends Object {
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
function __construct($url = null, $base = false) {
|
function __construct($url = null, $base = false) {
|
||||||
parent::__construct();
|
|
||||||
if ($base !== false) {
|
if ($base !== false) {
|
||||||
Configure::write('App.base', $base);
|
Configure::write('App.base', $base);
|
||||||
}
|
}
|
||||||
$this->base = Configure::read('App.base');
|
$this->base = Configure::read('App.base');
|
||||||
|
|
||||||
if ($url !== null) {
|
if ($url !== null) {
|
||||||
return $this->dispatch($url);
|
return $this->dispatch($url);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,7 @@ class Dispatcher extends Object {
|
||||||
*/
|
*/
|
||||||
function dispatch($url = null, $additionalParams = array()) {
|
function dispatch($url = null, $additionalParams = array()) {
|
||||||
$parse = true;
|
$parse = true;
|
||||||
|
|
||||||
if ($this->base === false) {
|
if ($this->base === false) {
|
||||||
$this->base = $this->baseUrl();
|
$this->base = $this->baseUrl();
|
||||||
}
|
}
|
||||||
|
@ -143,9 +144,7 @@ class Dispatcher extends Object {
|
||||||
'className' => Inflector::camelize($this->params['controller']) . 'Controller',
|
'className' => Inflector::camelize($this->params['controller']) . 'Controller',
|
||||||
'webroot' => $this->webroot,
|
'webroot' => $this->webroot,
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'base' => $this->base
|
'base' => $this->base)));
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
$missingAction = $missingView = $privateAction = false;
|
$missingAction = $missingView = $privateAction = false;
|
||||||
|
|
||||||
|
@ -162,7 +161,6 @@ class Dispatcher extends Object {
|
||||||
$privateAction = in_array($prefix, $prefixes);
|
$privateAction = in_array($prefix, $prefixes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$protected = array_map('strtolower', get_class_methods('controller'));
|
$protected = array_map('strtolower', get_class_methods('controller'));
|
||||||
$classMethods = array_map('strtolower', get_class_methods($controller));
|
$classMethods = array_map('strtolower', get_class_methods($controller));
|
||||||
|
|
||||||
|
@ -177,7 +175,6 @@ class Dispatcher extends Object {
|
||||||
if (in_array('return', array_keys($this->params)) && $this->params['return'] == 1) {
|
if (in_array('return', array_keys($this->params)) && $this->params['return'] == 1) {
|
||||||
$controller->autoRender = false;
|
$controller->autoRender = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$controller->base = $this->base;
|
$controller->base = $this->base;
|
||||||
$controller->here = $this->here;
|
$controller->here = $this->here;
|
||||||
$controller->webroot = $this->webroot;
|
$controller->webroot = $this->webroot;
|
||||||
|
@ -214,9 +211,8 @@ class Dispatcher extends Object {
|
||||||
$controller->{$var} = array_merge($controller->{$var}, $diff);
|
$controller->{$var} = array_merge($controller->{$var}, $diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Router::setRequestInfo(array($this->params, array('base' => $this->base, 'here' => $this->here, 'webroot' => $this->webroot)));
|
Router::setRequestInfo(array($this->params, array('base' => $this->base, 'here' => $this->here, 'webroot' => $this->webroot)));
|
||||||
$this->start($controller);
|
$controller->constructClasses();
|
||||||
|
|
||||||
if ($privateAction) {
|
if ($privateAction) {
|
||||||
return $this->cakeError('privateAction', array(
|
return $this->cakeError('privateAction', array(
|
||||||
|
@ -225,11 +221,8 @@ class Dispatcher extends Object {
|
||||||
'action' => $this->params['action'],
|
'action' => $this->params['action'],
|
||||||
'webroot' => $this->webroot,
|
'webroot' => $this->webroot,
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'base' => $this->base
|
'base' => $this->base)));
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_invoke($controller, $this->params, $missingAction);
|
return $this->_invoke($controller, $this->params, $missingAction);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -254,9 +247,7 @@ class Dispatcher extends Object {
|
||||||
'action' => $params['action'],
|
'action' => $params['action'],
|
||||||
'webroot' => $this->webroot,
|
'webroot' => $this->webroot,
|
||||||
'url' => $this->here,
|
'url' => $this->here,
|
||||||
'base' => $this->base
|
'base' => $this->base)));
|
||||||
)
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
$output = $controller->dispatchMethod($params['action'], $params['pass']);
|
$output = $controller->dispatchMethod($params['action'], $params['pass']);
|
||||||
}
|
}
|
||||||
|
@ -266,45 +257,13 @@ class Dispatcher extends Object {
|
||||||
} elseif (empty($controller->output)) {
|
} elseif (empty($controller->output)) {
|
||||||
$controller->output = $output;
|
$controller->output = $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
$controller->Component->shutdown($controller);
|
$controller->Component->shutdown($controller);
|
||||||
|
|
||||||
$controller->afterFilter();
|
$controller->afterFilter();
|
||||||
|
|
||||||
if (isset($params['return'])) {
|
if (isset($params['return'])) {
|
||||||
return $controller->output;
|
return $controller->output;
|
||||||
}
|
}
|
||||||
e($controller->output);
|
echo($controller->output);
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Starts up a controller (by calling its beforeFilter methods and
|
|
||||||
* starting its components)
|
|
||||||
*
|
|
||||||
* @param object $controller Controller to start
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
function start(&$controller) {
|
|
||||||
$controller->constructClasses();
|
|
||||||
|
|
||||||
$controller->Component->initialize($controller);
|
|
||||||
|
|
||||||
if (!empty($controller->beforeFilter)) {
|
|
||||||
trigger_error(sprintf(__('Dispatcher::start - Controller::$beforeFilter property usage is deprecated and will no longer be supported. Use Controller::beforeFilter().', true)), E_USER_WARNING);
|
|
||||||
|
|
||||||
if (is_array($controller->beforeFilter)) {
|
|
||||||
foreach ($controller->beforeFilter as $filter) {
|
|
||||||
if (is_callable(array($controller,$filter)) && $filter != 'beforeFilter') {
|
|
||||||
$controller->$filter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (is_callable(array($controller, $controller->beforeFilter)) && $controller->beforeFilter != 'beforeFilter') {
|
|
||||||
$controller->{$controller->beforeFilter}();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$controller->beforeFilter();
|
|
||||||
|
|
||||||
$controller->Component->startup($controller);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets the params when $url is passed as an array to Object::requestAction();
|
* Sets the params when $url is passed as an array to Object::requestAction();
|
||||||
|
@ -349,7 +308,6 @@ class Dispatcher extends Object {
|
||||||
unset($params['form']['_method']);
|
unset($params['form']['_method']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extract(Router::getNamedExpressions());
|
extract(Router::getNamedExpressions());
|
||||||
include CONFIGS . 'routes.php';
|
include CONFIGS . 'routes.php';
|
||||||
$params = array_merge(Router::parse($fromUrl), $params);
|
$params = array_merge(Router::parse($fromUrl), $params);
|
||||||
|
@ -400,7 +358,6 @@ class Dispatcher extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function baseUrl() {
|
function baseUrl() {
|
||||||
|
|
||||||
$dir = $webroot = null;
|
$dir = $webroot = null;
|
||||||
$config = Configure::read('App');
|
$config = Configure::read('App');
|
||||||
extract($config);
|
extract($config);
|
||||||
|
@ -431,11 +388,12 @@ class Dispatcher extends Object {
|
||||||
$this->webroot = $base .'/';
|
$this->webroot = $base .'/';
|
||||||
return $base;
|
return $base;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = null;
|
$file = null;
|
||||||
|
|
||||||
if ($baseUrl) {
|
if ($baseUrl) {
|
||||||
$file = '/' . basename($baseUrl);
|
$file = '/' . basename($baseUrl);
|
||||||
$base = dirname($baseUrl);
|
$base = dirname($baseUrl);
|
||||||
|
|
||||||
if (in_array($base, array(DS, '.'))) {
|
if (in_array($base, array(DS, '.'))) {
|
||||||
$base = '';
|
$base = '';
|
||||||
}
|
}
|
||||||
|
@ -570,11 +528,13 @@ class Dispatcher extends Object {
|
||||||
if (Configure::read('App.server') == 'IIS') {
|
if (Configure::read('App.server') == 'IIS') {
|
||||||
$uri = preg_replace('/^(?:\/)?(?:\/)?(?:\?)?(?:url=)?/', '', $uri);
|
$uri = preg_replace('/^(?:\/)?(?:\/)?(?:\?)?(?:url=)?/', '', $uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($uri)) {
|
if (!empty($uri)) {
|
||||||
if (key($_GET) && strpos(key($_GET), '?') !== false) {
|
if (key($_GET) && strpos(key($_GET), '?') !== false) {
|
||||||
unset($_GET[key($_GET)]);
|
unset($_GET[key($_GET)]);
|
||||||
}
|
}
|
||||||
$uri = preg_split('/\?/', $uri, 2);
|
$uri = preg_split('/\?/', $uri, 2);
|
||||||
|
|
||||||
if (isset($uri[1])) {
|
if (isset($uri[1])) {
|
||||||
parse_str($uri[1], $_GET);
|
parse_str($uri[1], $_GET);
|
||||||
}
|
}
|
||||||
|
@ -582,9 +542,11 @@ class Dispatcher extends Object {
|
||||||
} elseif (empty($uri) && is_string(env('QUERY_STRING'))) {
|
} elseif (empty($uri) && is_string(env('QUERY_STRING'))) {
|
||||||
$uri = env('QUERY_STRING');
|
$uri = env('QUERY_STRING');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($uri, 'index.php') !== false) {
|
if (strpos($uri, 'index.php') !== false) {
|
||||||
list(, $uri) = explode('index.php', $uri, 2);
|
list(, $uri) = explode('index.php', $uri, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($uri) || $uri == '/' || $uri == '//') {
|
if (empty($uri) || $uri == '/' || $uri == '//') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -603,6 +565,7 @@ class Dispatcher extends Object {
|
||||||
if ($uri == null) {
|
if ($uri == null) {
|
||||||
$uri = $this->uri();
|
$uri = $this->uri();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($base == null) {
|
if ($base == null) {
|
||||||
$base = $this->base;
|
$base = $this->base;
|
||||||
}
|
}
|
||||||
|
@ -620,12 +583,14 @@ class Dispatcher extends Object {
|
||||||
} else {
|
} else {
|
||||||
$elements = array();
|
$elements = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($elements[1])) {
|
if (!empty($elements[1])) {
|
||||||
$_GET['url'] = $elements[1];
|
$_GET['url'] = $elements[1];
|
||||||
$url = $elements[1];
|
$url = $elements[1];
|
||||||
} else {
|
} else {
|
||||||
$url = $_GET['url'] = '/';
|
$url = $_GET['url'] = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($url, '/') === 0 && $url != '/') {
|
if (strpos($url, '/') === 0 && $url != '/') {
|
||||||
$url = $_GET['url'] = substr($url, 1);
|
$url = $_GET['url'] = substr($url, 1);
|
||||||
}
|
}
|
||||||
|
@ -633,6 +598,7 @@ class Dispatcher extends Object {
|
||||||
} else {
|
} else {
|
||||||
$url = $_GET['url'];
|
$url = $_GET['url'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($url{0} == '/') {
|
if ($url{0} == '/') {
|
||||||
$url = substr($url, 1);
|
$url = substr($url, 1);
|
||||||
}
|
}
|
||||||
|
@ -652,9 +618,9 @@ class Dispatcher extends Object {
|
||||||
include WWW_ROOT . DS . Configure::read('Asset.filter.js');
|
include WWW_ROOT . DS . Configure::read('Asset.filter.js');
|
||||||
$this->_stop();
|
$this->_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
$assets = array('js' => 'text/javascript', 'css' => 'text/css');
|
$assets = array('js' => 'text/javascript', 'css' => 'text/css');
|
||||||
$isAsset = false;
|
$isAsset = false;
|
||||||
|
|
||||||
foreach ($assets as $type => $contentType) {
|
foreach ($assets as $type => $contentType) {
|
||||||
$pos = strpos($url, $type . '/');
|
$pos = strpos($url, $type . '/');
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
|
@ -670,9 +636,9 @@ class Dispatcher extends Object {
|
||||||
ob_start();
|
ob_start();
|
||||||
ob_start('ob_gzhandler');
|
ob_start('ob_gzhandler');
|
||||||
}
|
}
|
||||||
|
|
||||||
$assetFile = null;
|
$assetFile = null;
|
||||||
$paths = array();
|
$paths = array();
|
||||||
|
|
||||||
if ($pos > 0) {
|
if ($pos > 0) {
|
||||||
$plugin = substr($url, 0, $pos - 1);
|
$plugin = substr($url, 0, $pos - 1);
|
||||||
$url = str_replace($plugin . '/', '', $url);
|
$url = str_replace($plugin . '/', '', $url);
|
||||||
|
@ -682,7 +648,6 @@ class Dispatcher extends Object {
|
||||||
$paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS;
|
$paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$paths = array_merge($paths, Configure::read('vendorPaths'));
|
$paths = array_merge($paths, Configure::read('vendorPaths'));
|
||||||
|
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
|
@ -711,9 +676,11 @@ class Dispatcher extends Object {
|
||||||
|
|
||||||
if (Configure::read('Cache.check') === true) {
|
if (Configure::read('Cache.check') === true) {
|
||||||
$filename = CACHE . 'views' . DS . Inflector::slug($this->here) . '.php';
|
$filename = CACHE . 'views' . DS . Inflector::slug($this->here) . '.php';
|
||||||
|
|
||||||
if (!file_exists($filename)) {
|
if (!file_exists($filename)) {
|
||||||
$filename = CACHE . 'views' . DS . Inflector::slug($this->here) . '_index.php';
|
$filename = CACHE . 'views' . DS . Inflector::slug($this->here) . '_index.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
if (!class_exists('View')) {
|
if (!class_exists('View')) {
|
||||||
App::import('Core', 'View');
|
App::import('Core', 'View');
|
||||||
|
|
|
@ -159,30 +159,9 @@ class CookieComponent extends Object {
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to the instantiating controller object
|
* @param object $controller A reference to the instantiating controller object
|
||||||
* @access public
|
* @access public
|
||||||
* @deprecated use Controller::beforeFilter() to set the properties of the CookieComponent
|
|
||||||
*/
|
*/
|
||||||
function initialize(&$controller) {
|
function initialize(&$controller) {
|
||||||
$this->key = Configure::read('Security.salt');
|
$this->key = Configure::read('Security.salt');
|
||||||
if (is_object($controller)) {
|
|
||||||
if (isset($controller->cookieName)) {
|
|
||||||
$this->name = $controller->cookieName;
|
|
||||||
}
|
|
||||||
if (isset($controller->cookieTime)) {
|
|
||||||
$this->time = $controller->cookieTime;
|
|
||||||
}
|
|
||||||
if (isset($controller->cookieKey)) {
|
|
||||||
$this->key = $controller->cookieKey;
|
|
||||||
}
|
|
||||||
if (isset($controller->cookiePath)) {
|
|
||||||
$this->path = $controller->cookiePath;
|
|
||||||
}
|
|
||||||
if (isset($controller->cookieDomain)) {
|
|
||||||
$this->domain = $controller->cookieDomain;
|
|
||||||
}
|
|
||||||
if (isset($controller->cookieSecure)) {
|
|
||||||
$this->secure = $controller->cookieSecure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Start CookieComponent for use in the controller
|
* Start CookieComponent for use in the controller
|
||||||
|
|
|
@ -384,24 +384,26 @@ class Controller extends Object {
|
||||||
$this->__mergeVars();
|
$this->__mergeVars();
|
||||||
$this->Component->init($this);
|
$this->Component->init($this);
|
||||||
|
|
||||||
if ($this->uses === null || ($this->uses === array())) {
|
if ($this->uses !== null || ($this->uses !== array())) {
|
||||||
return false;
|
if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
|
||||||
}
|
$id = false;
|
||||||
if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
|
} else {
|
||||||
$id = false;
|
$id = $this->passedArgs['0'];
|
||||||
} else {
|
}
|
||||||
$id = $this->passedArgs['0'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->uses === false) {
|
if ($this->uses === false) {
|
||||||
$this->loadModel($this->modelClass, $id);
|
$this->loadModel($this->modelClass, $id);
|
||||||
} elseif ($this->uses) {
|
} elseif ($this->uses) {
|
||||||
$uses = is_array($this->uses) ? $this->uses : array($this->uses);
|
$uses = is_array($this->uses) ? $this->uses : array($this->uses);
|
||||||
$this->modelClass = $uses[0];
|
$this->modelClass = $uses[0];
|
||||||
foreach ($uses as $modelClass) {
|
foreach ($uses as $modelClass) {
|
||||||
$this->loadModel($modelClass);
|
$this->loadModel($modelClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->Component->initialize($this);
|
||||||
|
$this->beforeFilter();
|
||||||
|
$this->Component->startup($this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -401,5 +401,4 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
return $map;
|
return $map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -33,7 +33,7 @@
|
||||||
* Database name for cake sessions.
|
* Database name for cake sessions.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uses('set');
|
App::import('Core', 'Set');
|
||||||
/**
|
/**
|
||||||
* Session class for Cake.
|
* Session class for Cake.
|
||||||
*
|
*
|
||||||
|
@ -123,7 +123,7 @@ class CakeSession extends Object {
|
||||||
*/
|
*/
|
||||||
function __construct($base = null, $start = true) {
|
function __construct($base = null, $start = true) {
|
||||||
if (Configure::read('Session.save') === 'database' && !class_exists('ConnectionManager')) {
|
if (Configure::read('Session.save') === 'database' && !class_exists('ConnectionManager')) {
|
||||||
uses('model' . DS . 'connection_manager');
|
App::import('Core', 'ConnectionManager');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Configure::read('Session.checkAgent') === true || Configure::read('Session.checkAgent') === null) {
|
if (Configure::read('Session.checkAgent') === true || Configure::read('Session.checkAgent') === null) {
|
||||||
|
@ -147,7 +147,7 @@ class CakeSession extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!class_exists('Security')) {
|
if (!class_exists('Security')) {
|
||||||
uses('security');
|
App::import('Core', 'Security');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sessionTime = $this->time + (Security::inactiveMins() * Configure::read('Session.timeout'));
|
$this->sessionTime = $this->time + (Security::inactiveMins() * Configure::read('Session.timeout'));
|
||||||
|
@ -212,29 +212,6 @@ class CakeSession extends Object {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Temp method until we are able to remove the last eval().
|
|
||||||
* Builds an expression to fetch a session variable with specified name.
|
|
||||||
*
|
|
||||||
* @param string $name Name of variable (in dot notation)
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __sessionVarNames($name) {
|
|
||||||
if (is_string($name) && preg_match("/^[ 0-9a-zA-Z._-]*$/", $name)) {
|
|
||||||
if (strpos($name, ".")) {
|
|
||||||
$names = explode(".", $name);
|
|
||||||
} else {
|
|
||||||
$names = array($name);
|
|
||||||
}
|
|
||||||
$expression = "\$_SESSION";
|
|
||||||
foreach ($names as $item) {
|
|
||||||
$expression .= is_numeric($item) ? "[$item]" : "['$item']";
|
|
||||||
}
|
|
||||||
return $expression;
|
|
||||||
}
|
|
||||||
$this->__setError(3, "$name is not a string");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Removes a variable from session.
|
* Removes a variable from session.
|
||||||
*
|
*
|
||||||
|
|
|
@ -752,26 +752,28 @@ class Set extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function diff($val1, $val2 = null) {
|
function diff($val1, $val2 = null) {
|
||||||
if ($val2 == null && (is_a($this, 'set') || is_a($this, 'Set'))) {
|
if ($val2 == null && is_a($this, 'set')) {
|
||||||
$val2 = $val1;
|
$val2 = $val1;
|
||||||
$val1 = $this->get();
|
$val1 = $this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_object($val2) && (is_a($val2, 'set') || is_a($val2, 'Set'))) {
|
if (is_a($val2, 'set')) {
|
||||||
$val2 = $val2->get();
|
$val2 = $val2->get();
|
||||||
}
|
}
|
||||||
$out = array();
|
|
||||||
|
|
||||||
if (empty($val1)) {
|
if (empty($val1)) {
|
||||||
return (array)$val2;
|
return (array)$val2;
|
||||||
} elseif (empty($val2)) {
|
} elseif (empty($val2)) {
|
||||||
return (array)$val1;
|
return (array)$val1;
|
||||||
}
|
}
|
||||||
|
$out = array();
|
||||||
|
|
||||||
foreach ($val1 as $key => $val) {
|
foreach ($val1 as $key => $val) {
|
||||||
if (array_key_exists($key, $val2) && $val2[$key] != $val) {
|
$exists = array_key_exists($key, $val2);
|
||||||
|
|
||||||
|
if ($exists && $val2[$key] != $val) {
|
||||||
$out[$key] = $val;
|
$out[$key] = $val;
|
||||||
} elseif (!array_key_exists($key, $val2)) {
|
} elseif (!$exists) {
|
||||||
$out[$key] = $val;
|
$out[$key] = $val;
|
||||||
}
|
}
|
||||||
unset($val2[$key]);
|
unset($val2[$key]);
|
||||||
|
|
|
@ -32,8 +32,8 @@ if (!class_exists('AppController')) {
|
||||||
/**
|
/**
|
||||||
* AppController class
|
* AppController class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller
|
* @subpackage cake.tests.cases.libs.controller
|
||||||
*/
|
*/
|
||||||
class AppController extends Controller {
|
class AppController extends Controller {
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +69,6 @@ if (!class_exists('AppController')) {
|
||||||
} else {
|
} else {
|
||||||
define('AppControllerExists', true);
|
define('AppControllerExists', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ParamTestComponent
|
* ParamTestComponent
|
||||||
*
|
*
|
||||||
|
@ -83,14 +82,14 @@ class ParamTestComponent extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $name = 'ParamTest';
|
var $name = 'ParamTest';
|
||||||
/**
|
/**
|
||||||
* components property
|
* components property
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $components = array('Banana' => array('config' => 'value'));
|
var $components = array('Banana' => array('config' => 'value'));
|
||||||
/**
|
/**
|
||||||
* initialize method
|
* initialize method
|
||||||
*
|
*
|
||||||
* @param mixed $controller
|
* @param mixed $controller
|
||||||
|
@ -107,14 +106,12 @@ class ParamTestComponent extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
* @package cake.tests
|
* @package cake.tests
|
||||||
* @subpackage cake.tests.cases.libs.controller
|
* @subpackage cake.tests.cases.libs.controller
|
||||||
*/
|
*/
|
||||||
class ComponentTestController extends AppController {
|
class ComponentTestController extends AppController {
|
||||||
/**
|
/**
|
||||||
|
@ -135,8 +132,8 @@ class ComponentTestController extends AppController {
|
||||||
/**
|
/**
|
||||||
* AppleComponent class
|
* AppleComponent class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller
|
* @subpackage cake.tests.cases.libs.controller
|
||||||
*/
|
*/
|
||||||
class AppleComponent extends Object {
|
class AppleComponent extends Object {
|
||||||
/**
|
/**
|
||||||
|
@ -163,13 +160,12 @@ class AppleComponent extends Object {
|
||||||
function startup(&$controller) {
|
function startup(&$controller) {
|
||||||
$this->testName = $controller->name;
|
$this->testName = $controller->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* OrangeComponent class
|
* OrangeComponent class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller
|
* @subpackage cake.tests.cases.libs.controller
|
||||||
*/
|
*/
|
||||||
class OrangeComponent extends Object {
|
class OrangeComponent extends Object {
|
||||||
/**
|
/**
|
||||||
|
@ -194,8 +190,8 @@ class OrangeComponent extends Object {
|
||||||
/**
|
/**
|
||||||
* BananaComponent class
|
* BananaComponent class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller
|
* @subpackage cake.tests.cases.libs.controller
|
||||||
*/
|
*/
|
||||||
class BananaComponent extends Object {
|
class BananaComponent extends Object {
|
||||||
/**
|
/**
|
||||||
|
@ -205,9 +201,7 @@ class BananaComponent extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $testField = 'BananaField';
|
var $testField = 'BananaField';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MutuallyReferencingOneComponent class
|
* MutuallyReferencingOneComponent class
|
||||||
*
|
*
|
||||||
|
@ -217,7 +211,6 @@ class BananaComponent extends Object {
|
||||||
class MutuallyReferencingOneComponent extends Object {
|
class MutuallyReferencingOneComponent extends Object {
|
||||||
var $components = array('MutuallyReferencingTwo');
|
var $components = array('MutuallyReferencingTwo');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MutuallyReferencingTwoComponent class
|
* MutuallyReferencingTwoComponent class
|
||||||
*
|
*
|
||||||
|
@ -227,15 +220,11 @@ class MutuallyReferencingOneComponent extends Object {
|
||||||
class MutuallyReferencingTwoComponent extends Object {
|
class MutuallyReferencingTwoComponent extends Object {
|
||||||
var $components = array('MutuallyReferencingOne');
|
var $components = array('MutuallyReferencingOne');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ComponentTest class
|
* ComponentTest class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller
|
* @subpackage cake.tests.cases.libs.controller
|
||||||
*/
|
*/
|
||||||
class ComponentTest extends CakeTestCase {
|
class ComponentTest extends CakeTestCase {
|
||||||
/**
|
/**
|
||||||
|
@ -319,10 +308,6 @@ class ComponentTest extends CakeTestCase {
|
||||||
$Controller->constructClasses();
|
$Controller->constructClasses();
|
||||||
|
|
||||||
$this->assertTrue(is_a($Controller->Apple, 'AppleComponent'));
|
$this->assertTrue(is_a($Controller->Apple, 'AppleComponent'));
|
||||||
$this->assertEqual($Controller->Apple->testName, null);
|
|
||||||
|
|
||||||
$Controller->Component->startup($Controller);
|
|
||||||
|
|
||||||
$this->assertEqual($Controller->Apple->testName, 'ComponentTest');
|
$this->assertEqual($Controller->Apple->testName, 'ComponentTest');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -335,8 +320,6 @@ class ComponentTest extends CakeTestCase {
|
||||||
$Controller->components = array('Orange', 'Banana');
|
$Controller->components = array('Orange', 'Banana');
|
||||||
$Controller->constructClasses();
|
$Controller->constructClasses();
|
||||||
|
|
||||||
$Controller->Component->initialize($Controller);
|
|
||||||
|
|
||||||
$this->assertEqual($Controller->Banana->testField, 'OrangeField');
|
$this->assertEqual($Controller->Banana->testField, 'OrangeField');
|
||||||
$this->assertEqual($Controller->Orange->Banana->testField, 'OrangeField');
|
$this->assertEqual($Controller->Orange->Banana->testField, 'OrangeField');
|
||||||
}
|
}
|
||||||
|
@ -353,7 +336,6 @@ class ComponentTest extends CakeTestCase {
|
||||||
$Controller->components = array('ParamTest' => array('test' => 'value', 'flag'), 'Apple');
|
$Controller->components = array('ParamTest' => array('test' => 'value', 'flag'), 'Apple');
|
||||||
|
|
||||||
$Controller->constructClasses();
|
$Controller->constructClasses();
|
||||||
$Controller->Component->initialize($Controller);
|
|
||||||
|
|
||||||
$this->assertTrue(is_a($Controller->ParamTest, 'ParamTestComponent'));
|
$this->assertTrue(is_a($Controller->ParamTest, 'ParamTestComponent'));
|
||||||
$this->assertTrue(is_a($Controller->ParamTest->Banana, 'BananaComponent'));
|
$this->assertTrue(is_a($Controller->ParamTest->Banana, 'BananaComponent'));
|
||||||
|
@ -367,7 +349,6 @@ class ComponentTest extends CakeTestCase {
|
||||||
$Controller =& new ComponentTestController();
|
$Controller =& new ComponentTestController();
|
||||||
$Controller->components = array('ParamTest' => array('test' => 'value'), 'Orange' => array('ripeness' => 'perfect'));
|
$Controller->components = array('ParamTest' => array('test' => 'value'), 'Orange' => array('ripeness' => 'perfect'));
|
||||||
$Controller->constructClasses();
|
$Controller->constructClasses();
|
||||||
$Controller->Component->initialize($Controller);
|
|
||||||
|
|
||||||
$this->assertEqual($Controller->Orange->settings, array('colour' => 'blood orange', 'ripeness' => 'perfect'));
|
$this->assertEqual($Controller->Orange->settings, array('colour' => 'blood orange', 'ripeness' => 'perfect'));
|
||||||
$this->assertEqual($Controller->ParamTest->test, 'value');
|
$this->assertEqual($Controller->ParamTest->test, 'value');
|
||||||
|
@ -386,7 +367,6 @@ class ComponentTest extends CakeTestCase {
|
||||||
$this->assertTrue(is_a($Controller->MutuallyReferencingOne, 'MutuallyReferencingOneComponent'));
|
$this->assertTrue(is_a($Controller->MutuallyReferencingOne, 'MutuallyReferencingOneComponent'));
|
||||||
$this->assertTrue(is_a($Controller->MutuallyReferencingOne->MutuallyReferencingTwo, 'MutuallyReferencingTwoComponent'));
|
$this->assertTrue(is_a($Controller->MutuallyReferencingOne->MutuallyReferencingTwo, 'MutuallyReferencingTwoComponent'));
|
||||||
$this->assertTrue(is_a($Controller->MutuallyReferencingOne->MutuallyReferencingTwo->MutuallyReferencingOne, 'MutuallyReferencingOneComponent'));
|
$this->assertTrue(is_a($Controller->MutuallyReferencingOne->MutuallyReferencingTwo->MutuallyReferencingOne, 'MutuallyReferencingOneComponent'));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -34,8 +34,8 @@ App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
|
||||||
/**
|
/**
|
||||||
* AclNodeTwoTestBase class
|
* AclNodeTwoTestBase class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class AclNodeTwoTestBase extends AclNode {
|
class AclNodeTwoTestBase extends AclNode {
|
||||||
/**
|
/**
|
||||||
|
@ -56,8 +56,8 @@ class AclNodeTwoTestBase extends AclNode {
|
||||||
/**
|
/**
|
||||||
* AroTwoTest class
|
* AroTwoTest class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class AroTwoTest extends AclNodeTwoTestBase {
|
class AroTwoTest extends AclNodeTwoTestBase {
|
||||||
/**
|
/**
|
||||||
|
@ -85,8 +85,8 @@ class AroTwoTest extends AclNodeTwoTestBase {
|
||||||
/**
|
/**
|
||||||
* AcoTwoTest class
|
* AcoTwoTest class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class AcoTwoTest extends AclNodeTwoTestBase {
|
class AcoTwoTest extends AclNodeTwoTestBase {
|
||||||
/**
|
/**
|
||||||
|
@ -114,8 +114,8 @@ class AcoTwoTest extends AclNodeTwoTestBase {
|
||||||
/**
|
/**
|
||||||
* PermissionTwoTest class
|
* PermissionTwoTest class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class PermissionTwoTest extends CakeTestModel {
|
class PermissionTwoTest extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
|
@ -157,8 +157,8 @@ class PermissionTwoTest extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* DbAclTwoTest class
|
* DbAclTwoTest class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class DbAclTwoTest extends DbAcl {
|
class DbAclTwoTest extends DbAcl {
|
||||||
/**
|
/**
|
||||||
|
@ -177,8 +177,8 @@ class DbAclTwoTest extends DbAcl {
|
||||||
/**
|
/**
|
||||||
* IniAclTest class
|
* IniAclTest class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class IniAclTest extends IniAcl {
|
class IniAclTest extends IniAcl {
|
||||||
|
|
||||||
|
@ -187,8 +187,8 @@ class IniAclTest extends IniAcl {
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
* @package cake.tests
|
* @package cake.tests
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class AclComponentTest extends CakeTestCase {
|
class AclComponentTest extends CakeTestCase {
|
||||||
/**
|
/**
|
||||||
|
@ -282,23 +282,21 @@ class AclComponentTest extends CakeTestCase {
|
||||||
$this->assertTrue($this->Acl->allow('Micheal', 'ROOT/tpsReports', 'create'));
|
$this->assertTrue($this->Acl->allow('Micheal', 'ROOT/tpsReports', 'create'));
|
||||||
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'create'));
|
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'create'));
|
||||||
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'delete'));
|
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'delete'));
|
||||||
$this->assertTrue($this->Acl->allow('Micheal', 'printers', 'create'));
|
$this->assertTrue($this->Acl->allow('Micheal', 'printers', 'create'));
|
||||||
// Michael no longer has his delete permission for tpsReports!
|
// Michael no longer has his delete permission for tpsReports!
|
||||||
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'delete'));
|
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'delete'));
|
||||||
$this->assertTrue($this->Acl->check('Micheal', 'printers', 'create'));
|
$this->assertTrue($this->Acl->check('Micheal', 'printers', 'create'));
|
||||||
|
|
||||||
|
|
||||||
$this->assertFalse($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view'));
|
$this->assertFalse($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view'));
|
||||||
$this->assertTrue($this->Acl->allow('root/users/Samir', 'ROOT/tpsReports/view', '*'));
|
$this->assertTrue($this->Acl->allow('root/users/Samir', 'ROOT/tpsReports/view', '*'));
|
||||||
$this->assertTrue($this->Acl->check('Samir', 'view', 'read'));
|
$this->assertTrue($this->Acl->check('Samir', 'view', 'read'));
|
||||||
$this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view', 'update'));
|
$this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view', 'update'));
|
||||||
|
|
||||||
|
$this->assertFalse($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/update','*'));
|
||||||
$this->assertFalse($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/update','*'));
|
|
||||||
$this->assertTrue($this->Acl->allow('root/users/Samir', 'ROOT/tpsReports/update', '*'));
|
$this->assertTrue($this->Acl->allow('root/users/Samir', 'ROOT/tpsReports/update', '*'));
|
||||||
$this->assertTrue($this->Acl->check('Samir', 'update', 'read'));
|
$this->assertTrue($this->Acl->check('Samir', 'update', 'read'));
|
||||||
$this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/update', 'update'));
|
$this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/update', 'update'));
|
||||||
// Samir should still have his tpsReports/view permissions, but does not
|
// Samir should still have his tpsReports/view permissions, but does not
|
||||||
$this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view', 'update'));
|
$this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view', 'update'));
|
||||||
|
|
||||||
$this->expectError('DbAcl::allow() - Invalid node');
|
$this->expectError('DbAcl::allow() - Invalid node');
|
||||||
|
@ -313,7 +311,7 @@ class AclComponentTest extends CakeTestCase {
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testDbAclCheck() {
|
function testDbAclCheck() {
|
||||||
$this->assertTrue($this->Acl->check('Samir', 'print', 'read'));
|
$this->assertTrue($this->Acl->check('Samir', 'print', 'read'));
|
||||||
$this->assertTrue($this->Acl->check('Lumbergh', 'current', 'read'));
|
$this->assertTrue($this->Acl->check('Lumbergh', 'current', 'read'));
|
||||||
$this->assertFalse($this->Acl->check('Milton', 'smash', 'read'));
|
$this->assertFalse($this->Acl->check('Milton', 'smash', 'read'));
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @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 .'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'));
|
||||||
Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +53,6 @@ class TestAuthComponent extends AuthComponent {
|
||||||
$this->testStop = true;
|
$this->testStop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -228,8 +226,8 @@ class AuthTestController extends Controller {
|
||||||
/**
|
/**
|
||||||
* AjaxAuthController class
|
* AjaxAuthController class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class AjaxAuthController extends Controller {
|
class AjaxAuthController extends Controller {
|
||||||
/**
|
/**
|
||||||
|
@ -336,7 +334,6 @@ class AuthTest extends CakeTestCase {
|
||||||
if (isset($this->fixtures) && (!is_array($this->fixtures) || empty($this->fixtures))) {
|
if (isset($this->fixtures) && (!is_array($this->fixtures) || empty($this->fixtures))) {
|
||||||
unset($this->fixtures);
|
unset($this->fixtures);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create records
|
// Create records
|
||||||
if (isset($this->_fixtures) && isset($this->db)) {
|
if (isset($this->_fixtures) && isset($this->db)) {
|
||||||
foreach ($this->_fixtures as $fixture) {
|
foreach ($this->_fixtures as $fixture) {
|
||||||
|
@ -344,10 +341,9 @@ class AuthTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Controller =& new AuthTestController();
|
$this->Controller =& new AuthTestController();
|
||||||
|
|
||||||
$this->Controller->Component->init($this->Controller);
|
$this->Controller->Component->init($this->Controller);
|
||||||
|
|
||||||
ClassRegistry::addObject('view', new View($this->Controller));
|
ClassRegistry::addObject('view', new View($this->Controller));
|
||||||
$this->Controller->Session->del('Auth');
|
$this->Controller->Session->del('Auth');
|
||||||
$this->Controller->Session->del('Message.auth');
|
$this->Controller->Session->del('Message.auth');
|
||||||
|
|
|
@ -26,7 +26,19 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
uses('controller' . DS . 'components' . DS .'cookie');
|
App::import('Core', array('Component', 'Controller', 'Cookie'));
|
||||||
|
class CookieComponentTestController extends Controller {
|
||||||
|
var $components = array('Cookie');
|
||||||
|
|
||||||
|
function beforeFilter() {
|
||||||
|
$this->Cookie->name = 'CakeTestCookie';
|
||||||
|
$this->Cookie->time = 10;
|
||||||
|
$this->Cookie->path = '/';
|
||||||
|
$this->Cookie->domain = '';
|
||||||
|
$this->Cookie->secure = false;
|
||||||
|
$this->Cookie->key = 'somerandomhaskey';
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -34,14 +46,261 @@ uses('controller' . DS . 'components' . DS .'cookie');
|
||||||
* @subpackage cake.tests.cases.libs.controller.components
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
*/
|
*/
|
||||||
class CookieComponentTest extends CakeTestCase {
|
class CookieComponentTest extends CakeTestCase {
|
||||||
/**
|
var $Controller;
|
||||||
* skip method
|
|
||||||
*
|
function start() {
|
||||||
* @access public
|
$this->Controller = new CookieComponentTestController();
|
||||||
* @return void
|
$this->Controller->constructClasses();
|
||||||
*/
|
$this->Controller->Cookie->destroy();
|
||||||
function skip() {
|
}
|
||||||
$this->skipif (true, 'CookieComponentTest not implemented');
|
|
||||||
|
function testCookieName() {
|
||||||
|
$this->assertEqual($this->Controller->Cookie->name, 'CakeTestCookie');
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSettingEncryptedCookieData() {
|
||||||
|
$this->Controller->Cookie->write('Encrytped_array', array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!'));
|
||||||
|
$this->Controller->Cookie->write('Encrytped_multi_cookies.name', 'CakePHP');
|
||||||
|
$this->Controller->Cookie->write('Encrytped_multi_cookies.version', '1.2.0.x');
|
||||||
|
$this->Controller->Cookie->write('Encrytped_multi_cookies.tag', 'CakePHP Rocks!');
|
||||||
|
}
|
||||||
|
|
||||||
|
function testReadEncryptedCookieData() {
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSettingPlainCookieData() {
|
||||||
|
$this->Controller->Cookie->write('Plain_array', array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!'), false);
|
||||||
|
$this->Controller->Cookie->write('Plain_multi_cookies.name', 'CakePHP', false);
|
||||||
|
$this->Controller->Cookie->write('Plain_multi_cookies.version', '1.2.0.x', false);
|
||||||
|
$this->Controller->Cookie->write('Plain_multi_cookies.tag', 'CakePHP Rocks!', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testReadPlainCookieData() {
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testReadingCookieValue() {
|
||||||
|
$data = $this->Controller->Cookie->read();
|
||||||
|
$expected = array(
|
||||||
|
'Encrytped_array' => array(
|
||||||
|
'name' => 'CakePHP',
|
||||||
|
'version' => '1.2.0.x',
|
||||||
|
'tag' => 'CakePHP Rocks!'),
|
||||||
|
'Encrytped_multi_cookies' => array(
|
||||||
|
'name' => 'CakePHP',
|
||||||
|
'version' => '1.2.0.x',
|
||||||
|
'tag' => 'CakePHP Rocks!'),
|
||||||
|
'Plain_array' => array(
|
||||||
|
'name' => 'CakePHP',
|
||||||
|
'version' => '1.2.0.x',
|
||||||
|
'tag' => 'CakePHP Rocks!'),
|
||||||
|
'Plain_multi_cookies' => array(
|
||||||
|
'name' => 'CakePHP',
|
||||||
|
'version' => '1.2.0.x',
|
||||||
|
'tag' => 'CakePHP Rocks!'));
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testDeleteCookieValue() {
|
||||||
|
$this->Controller->Cookie->del('Encrytped_multi_cookies.name');
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies');
|
||||||
|
$expected = array('version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$this->Controller->Cookie->del('Encrytped_array');
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$this->Controller->Cookie->del('Plain_multi_cookies.name');
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies');
|
||||||
|
$expected = array('version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$this->Controller->Cookie->del('Plain_array');
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSettingCookiesWithArray() {
|
||||||
|
$this->Controller->Cookie->destroy();
|
||||||
|
|
||||||
|
$this->Controller->Cookie->write(array('Encrytped_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!')));
|
||||||
|
$this->Controller->Cookie->write(array('Encrytped_multi_cookies.name' => 'CakePHP'));
|
||||||
|
$this->Controller->Cookie->write(array('Encrytped_multi_cookies.version' => '1.2.0.x'));
|
||||||
|
$this->Controller->Cookie->write(array('Encrytped_multi_cookies.tag' => 'CakePHP Rocks!'));
|
||||||
|
|
||||||
|
$this->Controller->Cookie->write(array('Plain_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!')), null, false);
|
||||||
|
$this->Controller->Cookie->write(array('Plain_multi_cookies.name' => 'CakePHP'), null, false);
|
||||||
|
$this->Controller->Cookie->write(array('Plain_multi_cookies.version' => '1.2.0.x'), null, false);
|
||||||
|
$this->Controller->Cookie->write(array('Plain_multi_cookies.tag' => 'CakePHP Rocks!'), null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testReadingCookieArray() {
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array.name');
|
||||||
|
$expected = 'CakePHP';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array.version');
|
||||||
|
$expected = '1.2.0.x';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array.tag');
|
||||||
|
$expected = 'CakePHP Rocks!';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies.name');
|
||||||
|
$expected = 'CakePHP';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies.version');
|
||||||
|
$expected = '1.2.0.x';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies.tag');
|
||||||
|
$expected = 'CakePHP Rocks!';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array.name');
|
||||||
|
$expected = 'CakePHP';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array.version');
|
||||||
|
$expected = '1.2.0.x';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array.tag');
|
||||||
|
$expected = 'CakePHP Rocks!';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies.name');
|
||||||
|
$expected = 'CakePHP';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies.version');
|
||||||
|
$expected = '1.2.0.x';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies.tag');
|
||||||
|
$expected = 'CakePHP Rocks!';
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testReadingCookieDataOnStartup() {
|
||||||
|
$this->Controller->Cookie->destroy();
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$_COOKIE['CakeTestCookie'] = array(
|
||||||
|
'Encrytped_array' => 'Q2FrZQ==.y5J8fefUM83X0rdlMjuYFca8ZMYASU/8hM75rHuvjVNHO2WQ+6wK9nkVxm4abxI=',
|
||||||
|
'Encrytped_multi_cookies' => array(
|
||||||
|
'name' => 'Q2FrZQ==.5pJ6fcvfAg==',
|
||||||
|
'version' => 'Q2FrZQ==.lN0jNqu5Kg==',
|
||||||
|
'tag' => 'Q2FrZQ==.5pJ6fcvfAobg7ZxebWw='),
|
||||||
|
'Plain_array' => 'name|CakePHP,version|1.2.0.x,tag|CakePHP Rocks!',
|
||||||
|
'Plain_multi_cookies' => array(
|
||||||
|
'name' => 'CakePHP',
|
||||||
|
'version' => '1.2.0.x',
|
||||||
|
'tag' => 'CakePHP Rocks!'));
|
||||||
|
$this->Controller->Cookie->startup();
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
$this->Controller->Cookie->destroy();
|
||||||
|
unset($_COOKIE['CakeTestCookie']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testReadingCookieDataWithoutStartup() {
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies');
|
||||||
|
$expected = array();
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$_COOKIE['CakeTestCookie'] = array(
|
||||||
|
'Encrytped_array' => 'Q2FrZQ==.y5J8fefUM83X0rdlMjuYFca8ZMYASU/8hM75rHuvjVNHO2WQ+6wK9nkVxm4abxI=',
|
||||||
|
'Encrytped_multi_cookies' => array(
|
||||||
|
'name' => 'Q2FrZQ==.5pJ6fcvfAg==',
|
||||||
|
'version' => 'Q2FrZQ==.lN0jNqu5Kg==',
|
||||||
|
'tag' => 'Q2FrZQ==.5pJ6fcvfAobg7ZxebWw='),
|
||||||
|
'Plain_array' => 'name|CakePHP,version|1.2.0.x,tag|CakePHP Rocks!',
|
||||||
|
'Plain_multi_cookies' => array(
|
||||||
|
'name' => 'CakePHP',
|
||||||
|
'version' => '1.2.0.x',
|
||||||
|
'tag' => 'CakePHP Rocks!'));
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_array');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Encrytped_multi_cookies');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_array');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
|
||||||
|
$data = $this->Controller->Cookie->read('Plain_multi_cookies');
|
||||||
|
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
|
||||||
|
$this->assertEqual($data, $expected);
|
||||||
|
$this->Controller->Cookie->destroy();
|
||||||
|
unset($_COOKIE['CakeTestCookie']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function end() {
|
||||||
|
$this->Controller->Cookie->destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -56,7 +56,38 @@ class RequestHandlerTestController extends Controller {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* RequestHandlerTestDisabledController class
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
|
*/
|
||||||
|
class RequestHandlerTestDisabledController extends Controller {
|
||||||
|
/**
|
||||||
|
* uses property
|
||||||
|
*
|
||||||
|
* @var mixed null
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $uses = null;
|
||||||
|
/**
|
||||||
|
* construct method
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @access private
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function __construct($params = array()) {
|
||||||
|
foreach ($params as $key => $val) {
|
||||||
|
$this->{$key} = $val;
|
||||||
|
}
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
function beforeFilter() {
|
||||||
|
$this->RequestHandler->enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -106,14 +137,10 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testDisabling() {
|
function testDisabling() {
|
||||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||||
$this->assertEqual($this->Controller->params, array());
|
$this->_init();
|
||||||
$this->RequestHandler->startup($this->Controller);
|
|
||||||
$this->assertEqual($this->Controller->params, array('isAjax' => true));
|
$this->assertEqual($this->Controller->params, array('isAjax' => true));
|
||||||
|
|
||||||
$this->_init();
|
$this->Controller = new RequestHandlerTestDisabledController(array('components' => array('RequestHandler')));
|
||||||
$this->assertEqual($this->Controller->params, array());
|
|
||||||
$this->RequestHandler->enabled = false;
|
|
||||||
$this->RequestHandler->startup($this->Controller);
|
|
||||||
$this->assertEqual($this->Controller->params, array());
|
$this->assertEqual($this->Controller->params, array());
|
||||||
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
uses('controller' . DS . 'controller', 'controller' . DS . 'components' . DS .'session');
|
App::import('Core', 'Controller');
|
||||||
|
App::import('Component', 'Session');
|
||||||
/**
|
/**
|
||||||
* SessionTestController class
|
* SessionTestController class
|
||||||
*
|
*
|
||||||
|
@ -53,8 +54,6 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$this->assertFalse($Session->__active);
|
$this->assertFalse($Session->__active);
|
||||||
$this->assertFalse($Session->__started);
|
$this->assertFalse($Session->__started);
|
||||||
$Session->startup(new SessionTestController());
|
$Session->startup(new SessionTestController());
|
||||||
// $this->assertFalse(isset($_SESSION));
|
|
||||||
unset($_SESSION);
|
|
||||||
|
|
||||||
Configure::write('Session.start', true);
|
Configure::write('Session.start', true);
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
|
@ -62,9 +61,8 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$this->assertFalse($Session->__started);
|
$this->assertFalse($Session->__started);
|
||||||
$Session->startup(new SessionTestController());
|
$Session->startup(new SessionTestController());
|
||||||
$this->assertTrue(isset($_SESSION));
|
$this->assertTrue(isset($_SESSION));
|
||||||
unset($_SESSION);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionInitialize method
|
* testSessionInitialize method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -82,10 +80,8 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$sessionController->params['bare'] = 1;
|
$sessionController->params['bare'] = 1;
|
||||||
$Session->initialize($sessionController);
|
$Session->initialize($sessionController);
|
||||||
$this->assertEqual($Session->__bare, 1);
|
$this->assertEqual($Session->__bare, 1);
|
||||||
|
|
||||||
unset($_SESSION);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionActivate method
|
* testSessionActivate method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -97,7 +93,6 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$this->assertTrue($Session->__active);
|
$this->assertTrue($Session->__active);
|
||||||
$this->assertNull($Session->activate());
|
$this->assertNull($Session->activate());
|
||||||
$this->assertTrue($Session->__active);
|
$this->assertTrue($Session->__active);
|
||||||
unset($_SESSION);
|
|
||||||
|
|
||||||
Configure::write('Session.start', false);
|
Configure::write('Session.start', false);
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
|
@ -105,9 +100,9 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$this->assertNull($Session->activate());
|
$this->assertNull($Session->activate());
|
||||||
$this->assertTrue($Session->__active);
|
$this->assertTrue($Session->__active);
|
||||||
Configure::write('Session.start', true);
|
Configure::write('Session.start', true);
|
||||||
unset($_SESSION);
|
$Session->destroy();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionValid method
|
* testSessionValid method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -116,17 +111,18 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
function testSessionValid() {
|
function testSessionValid() {
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
|
|
||||||
|
$this->assertTrue($Session->valid());
|
||||||
|
|
||||||
|
$Session->_userAgent = 'rweerw';
|
||||||
$this->assertFalse($Session->valid());
|
$this->assertFalse($Session->valid());
|
||||||
unset($_SESSION);
|
|
||||||
|
|
||||||
Configure::write('Session.start', false);
|
Configure::write('Session.start', false);
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$this->assertFalse($Session->__active);
|
$this->assertFalse($Session->__active);
|
||||||
$this->assertFalse($Session->valid());
|
$this->assertFalse($Session->valid());
|
||||||
Configure::write('Session.start', true);
|
Configure::write('Session.start', true);
|
||||||
unset($_SESSION);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionError method
|
* testSessionError method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -136,16 +132,14 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
|
|
||||||
$this->assertFalse($Session->error());
|
$this->assertFalse($Session->error());
|
||||||
unset($_SESSION);
|
|
||||||
|
|
||||||
Configure::write('Session.start', false);
|
Configure::write('Session.start', false);
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$this->assertFalse($Session->__active);
|
$this->assertFalse($Session->__active);
|
||||||
$this->assertFalse($Session->error());
|
$this->assertFalse($Session->error());
|
||||||
Configure::write('Session.start', true);
|
Configure::write('Session.start', true);
|
||||||
unset($_SESSION);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionReadWrite method
|
* testSessionReadWrite method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -154,7 +148,6 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
function testSessionReadWrite() {
|
function testSessionReadWrite() {
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
|
|
||||||
$this->assertFalse($Session->read());
|
|
||||||
$this->assertFalse($Session->read('Test'));
|
$this->assertFalse($Session->read('Test'));
|
||||||
|
|
||||||
$this->assertTrue($Session->write('Test', 'some value'));
|
$this->assertTrue($Session->write('Test', 'some value'));
|
||||||
|
@ -179,17 +172,14 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$this->assertEqual($Session->read('Test'), 'some value');
|
$this->assertEqual($Session->read('Test'), 'some value');
|
||||||
$Session->del('Test');
|
$Session->del('Test');
|
||||||
|
|
||||||
unset($_SESSION);
|
|
||||||
|
|
||||||
Configure::write('Session.start', false);
|
Configure::write('Session.start', false);
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$this->assertFalse($Session->write('Test', 'some value'));
|
$this->assertFalse($Session->write('Test', 'some value'));
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
$this->assertFalse($Session->read('Test'));
|
$this->assertFalse($Session->read('Test'));
|
||||||
Configure::write('Session.start', true);
|
Configure::write('Session.start', true);
|
||||||
unset($_SESSION);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionDel method
|
* testSessionDel method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -202,16 +192,14 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
$this->assertTrue($Session->del('Test'));
|
$this->assertTrue($Session->del('Test'));
|
||||||
unset($_SESSION);
|
|
||||||
|
|
||||||
Configure::write('Session.start', false);
|
Configure::write('Session.start', false);
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
$this->assertFalse($Session->del('Test'));
|
$this->assertFalse($Session->del('Test'));
|
||||||
Configure::write('Session.start', true);
|
Configure::write('Session.start', true);
|
||||||
unset($_SESSION);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionDelete method
|
* testSessionDelete method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -224,28 +212,14 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
$this->assertTrue($Session->delete('Test'));
|
$this->assertTrue($Session->delete('Test'));
|
||||||
unset($_SESSION);
|
|
||||||
|
|
||||||
Configure::write('Session.start', false);
|
Configure::write('Session.start', false);
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
$this->assertFalse($Session->delete('Test'));
|
$this->assertFalse($Session->delete('Test'));
|
||||||
Configure::write('Session.start', true);
|
Configure::write('Session.start', true);
|
||||||
unset($_SESSION);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionId method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testSessionId() {
|
|
||||||
$Session =& new SessionComponent();
|
|
||||||
|
|
||||||
$this->assertNull($Session->id());
|
|
||||||
unset($_SESSION);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* testSessionCheck method
|
* testSessionCheck method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -259,16 +233,14 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
$this->assertTrue($Session->check('Test'));
|
$this->assertTrue($Session->check('Test'));
|
||||||
$Session->delete('Test');
|
$Session->delete('Test');
|
||||||
unset($_SESSION);
|
|
||||||
|
|
||||||
Configure::write('Session.start', false);
|
Configure::write('Session.start', false);
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
$this->assertFalse($Session->check('Test'));
|
$this->assertFalse($Session->check('Test'));
|
||||||
Configure::write('Session.start', true);
|
Configure::write('Session.start', true);
|
||||||
unset($_SESSION);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSessionFlash method
|
* testSessionFlash method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -291,7 +263,18 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$Session->setFlash('This is a test message', 'non_existing_layout');
|
$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()));
|
$this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'layout' => 'default', 'params' => array()));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* testSessionId method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testSessionId() {
|
||||||
|
unset($_SESSION);
|
||||||
|
$Session =& new SessionComponent();
|
||||||
|
$this->assertNull($Session->id());
|
||||||
|
}
|
||||||
|
/**
|
||||||
* testSessionDestroy method
|
* testSessionDestroy method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -305,7 +288,5 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$Session->destroy('Test');
|
$Session->destroy('Test');
|
||||||
$this->assertNull($Session->read('Test'));
|
$this->assertNull($Session->read('Test'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -34,7 +34,7 @@ App::import('Core', 'Session');
|
||||||
* @subpackage cake.tests.cases.libs
|
* @subpackage cake.tests.cases.libs
|
||||||
*/
|
*/
|
||||||
class SessionTest extends CakeTestCase {
|
class SessionTest extends CakeTestCase {
|
||||||
var $fixtures = array('core.session');//using fixtures really messes things up. but should eventually be used.
|
var $fixtures = array('core.session');
|
||||||
/**
|
/**
|
||||||
* setUp method
|
* setUp method
|
||||||
*
|
*
|
||||||
|
@ -42,13 +42,9 @@ class SessionTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
function setUp() {
|
||||||
restore_error_handler();
|
$this->Session =& new CakeSession();
|
||||||
|
|
||||||
@$this->Session =& new CakeSession();
|
|
||||||
$this->Session->start();
|
$this->Session->start();
|
||||||
$this->Session->_checkValid();
|
$this->Session->_checkValid();
|
||||||
|
|
||||||
set_error_handler('simpleTestErrorHandler');
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testCheck method
|
* testCheck method
|
||||||
|
@ -270,11 +266,12 @@ class SessionTest extends CakeTestCase {
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testReadAndWriteWithDatabaseStorage() {
|
function testReadAndWriteWithCakeStorage() {
|
||||||
Configure::write('Session.table', 'sessions');
|
unset($_SESSION);
|
||||||
Configure::write('Session.database', 'default');
|
session_destroy();
|
||||||
Configure::write('Session.save', 'database');
|
ini_set('session.save_handler', 'files');
|
||||||
$this->Session->renew();
|
Configure::write('Session.save', 'cake');
|
||||||
|
$this->setUp();
|
||||||
|
|
||||||
$this->Session->write('SessionTestCase', 0);
|
$this->Session->write('SessionTestCase', 0);
|
||||||
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
|
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
|
||||||
|
@ -291,17 +288,82 @@ class SessionTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Session->write('SessionTestCase', 'This is a Test');
|
$this->Session->write('SessionTestCase', 'This is a Test');
|
||||||
$this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
|
$this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', 'This is a Test');
|
||||||
|
$this->Session->write('SessionTestCase', 'This was updated');
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), 'This was updated');
|
||||||
|
|
||||||
|
$this->Session->destroy();
|
||||||
|
$this->assertFalse($this->Session->read('SessionTestCase'));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* tearDown method
|
* testReadAndWriteWithDatabaseStorage method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function testReadAndWriteWithCacheStorage() {
|
||||||
$this->Session->del('SessionTestCase');
|
unset($_SESSION);
|
||||||
unset($this->Session);
|
session_destroy();
|
||||||
|
ini_set('session.save_handler', 'files');
|
||||||
|
Configure::write('Session.save', 'cache');
|
||||||
|
$this->setUp();
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', 0);
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', '0');
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), '0');
|
||||||
|
$this->assertFalse($this->Session->read('SessionTestCase') === 0);
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', false);
|
||||||
|
$this->assertFalse($this->Session->read('SessionTestCase'));
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', null);
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), null);
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', 'This is a Test');
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', 'This is a Test');
|
||||||
|
$this->Session->write('SessionTestCase', 'This was updated');
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), 'This was updated');
|
||||||
|
|
||||||
|
$this->Session->destroy();
|
||||||
|
$this->assertFalse($this->Session->read('SessionTestCase'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* testReadAndWriteWithDatabaseStorage method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testReadAndWriteWithDatabaseStorage() {
|
||||||
|
unset($_SESSION);
|
||||||
|
session_destroy();
|
||||||
|
Configure::write('Session.table', 'sessions');
|
||||||
|
Configure::write('Session.database', 'test');
|
||||||
|
Configure::write('Session.save', 'database');
|
||||||
|
$this->setUp();
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', 0);
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), 0);
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', '0');
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), '0');
|
||||||
|
$this->assertFalse($this->Session->read('SessionTestCase') === 0);
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', false);
|
||||||
|
$this->assertFalse($this->Session->read('SessionTestCase'));
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', null);
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), null);
|
||||||
|
|
||||||
|
$this->Session->write('SessionTestCase', 'This is a Test');
|
||||||
|
$this->assertEqual($this->Session->read('SessionTestCase'), 'This is a Test');
|
||||||
|
|
||||||
|
$this->Session->destroy();
|
||||||
|
$this->assertFalse($this->Session->read('SessionTestCase'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -33,183 +33,177 @@
|
||||||
* @subpackage cake.cake.tests.lib
|
* @subpackage cake.cake.tests.lib
|
||||||
*/
|
*/
|
||||||
class CakeHtmlReporter extends SimpleReporter {
|
class CakeHtmlReporter extends SimpleReporter {
|
||||||
var $_character_set;
|
var $_character_set;
|
||||||
var $_show_passes = false;
|
var $_show_passes = false;
|
||||||
|
/**
|
||||||
/**
|
* Does nothing yet. The first output will
|
||||||
* Does nothing yet. The first output will
|
* be sent on the first test start. For use
|
||||||
* be sent on the first test start. For use
|
* by a web browser.
|
||||||
* by a web browser.
|
* @access public
|
||||||
* @access public
|
*/
|
||||||
*/
|
function CakeHtmlReporter($character_set = 'ISO-8859-1') {
|
||||||
function CakeHtmlReporter($character_set = 'ISO-8859-1') {
|
|
||||||
if (isset($_GET['show_passes']) && $_GET['show_passes']) {
|
if (isset($_GET['show_passes']) && $_GET['show_passes']) {
|
||||||
$this->_show_passes = true;
|
$this->_show_passes = true;
|
||||||
}
|
}
|
||||||
$this->SimpleReporter();
|
$this->SimpleReporter();
|
||||||
$this->_character_set = $character_set;
|
$this->_character_set = $character_set;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
/**
|
* Paints the top of the web page setting the
|
||||||
* Paints the top of the web page setting the
|
* title to the name of the starting test.
|
||||||
* title to the name of the starting test.
|
* @param string $test_name Name class of test.
|
||||||
* @param string $test_name Name class of test.
|
* @access public
|
||||||
* @access public
|
*/
|
||||||
*/
|
|
||||||
function paintHeader($testName) {
|
function paintHeader($testName) {
|
||||||
$this->sendNoCacheHeaders();
|
$this->sendNoCacheHeaders();
|
||||||
$baseUrl = BASE;
|
ob_start();
|
||||||
print "<h2>$testName</h2>\n";
|
echo "<h2>$testName</h2>\n";
|
||||||
print "<ul class='tests'>\n";
|
echo "<ul class='tests'>\n";
|
||||||
flush();
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
/**
|
* Send the headers necessary to ensure the page is
|
||||||
* Send the headers necessary to ensure the page is
|
* reloaded on every request. Otherwise you could be
|
||||||
* reloaded on every request. Otherwise you could be
|
* scratching your head over out of date test data.
|
||||||
* scratching your head over out of date test data.
|
* @access public
|
||||||
* @access public
|
* @static
|
||||||
* @static
|
*/
|
||||||
*/
|
function sendNoCacheHeaders() {
|
||||||
function sendNoCacheHeaders() {
|
if (!headers_sent()) {
|
||||||
if (! headers_sent()) {
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
header("Pragma: no-cache");
|
||||||
header("Pragma: no-cache");
|
}
|
||||||
}
|
}
|
||||||
}
|
/**
|
||||||
|
* Paints the end of the test with a summary of
|
||||||
/**
|
* the passes and failures.
|
||||||
* Paints the end of the test with a summary of
|
* @param string $test_name Name class of test.
|
||||||
* the passes and failures.
|
* @access public
|
||||||
* @param string $test_name Name class of test.
|
*/
|
||||||
* @access public
|
function paintFooter($test_name) {
|
||||||
*/
|
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
|
||||||
function paintFooter($test_name) {
|
ob_start();
|
||||||
$colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
|
echo "</ul>\n";
|
||||||
print "</ul>\n";
|
echo "<div style=\"";
|
||||||
print "<div style=\"";
|
echo "padding: 8px; margin: 1em 0; background-color: $colour; color: white;";
|
||||||
print "padding: 8px; margin: 1em 0; background-color: $colour; color: white;";
|
echo "\">";
|
||||||
print "\">";
|
echo $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
|
||||||
print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
|
echo " test cases complete:\n";
|
||||||
print " test cases complete:\n";
|
echo "<strong>" . $this->getPassCount() . "</strong> passes, ";
|
||||||
print "<strong>" . $this->getPassCount() . "</strong> passes, ";
|
echo "<strong>" . $this->getFailCount() . "</strong> fails and ";
|
||||||
print "<strong>" . $this->getFailCount() . "</strong> fails and ";
|
echo "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
|
||||||
print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
|
echo "</div>\n";
|
||||||
print "</div>\n";
|
echo "</body>\n</html>\n";
|
||||||
print "</body>\n</html>\n";
|
}
|
||||||
}
|
/**
|
||||||
|
* Paints the test failure with a breadcrumbs
|
||||||
/**
|
* trail of the nesting test suites below the
|
||||||
* Paints the test failure with a breadcrumbs
|
* top level test.
|
||||||
* trail of the nesting test suites below the
|
* @param string $message Failure message displayed in
|
||||||
* top level test.
|
* the context of the other tests.
|
||||||
* @param string $message Failure message displayed in
|
* @access public
|
||||||
* the context of the other tests.
|
*/
|
||||||
* @access public
|
function paintFail($message) {
|
||||||
*/
|
ob_start();
|
||||||
function paintFail($message) {
|
parent::paintFail($message);
|
||||||
parent::paintFail($message);
|
echo "<li class='fail'>\n";
|
||||||
print "<li class='fail'>\n";
|
echo "<span>Failed</span>";
|
||||||
print "<span>Failed</span>";
|
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||||
print "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
|
||||||
$breadcrumb = Set::filter($this->getTestList());
|
$breadcrumb = Set::filter($this->getTestList());
|
||||||
array_shift($breadcrumb);
|
array_shift($breadcrumb);
|
||||||
print "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||||
print "</li>\n";
|
echo "</li>\n";
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Paints the test pass with a breadcrumbs
|
||||||
|
* trail of the nesting test suites below the
|
||||||
|
* top level test.
|
||||||
|
* @param string $message Pass message displayed in
|
||||||
|
* the context of the other tests.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintPass($message) {
|
||||||
|
ob_start();
|
||||||
|
parent::paintPass($message);
|
||||||
|
|
||||||
/**
|
|
||||||
* Paints the test pass with a breadcrumbs
|
|
||||||
* trail of the nesting test suites below the
|
|
||||||
* top level test.
|
|
||||||
* @param string $message Pass message displayed in
|
|
||||||
* the context of the other tests.
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
function paintPass($message) {
|
|
||||||
parent::paintPass($message);
|
|
||||||
if ($this->_show_passes) {
|
if ($this->_show_passes) {
|
||||||
print "<li class='pass'>\n";
|
echo "<li class='pass'>\n";
|
||||||
print "<span>Passed</span> ";
|
echo "<span>Passed</span> ";
|
||||||
$breadcrumb = Set::filter($this->getTestList());
|
$breadcrumb = Set::filter($this->getTestList());
|
||||||
array_shift($breadcrumb);
|
array_shift($breadcrumb);
|
||||||
print implode(" -> ", $breadcrumb);
|
echo implode(" -> ", $breadcrumb);
|
||||||
print "<br />" . $this->_htmlEntities($message) . "\n";
|
echo "<br />" . $this->_htmlEntities($message) . "\n";
|
||||||
print "</li>\n";
|
echo "</li>\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Paints a PHP error.
|
|
||||||
* @param string $message Message is ignored.
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
function paintError($message) {
|
|
||||||
parent::paintError($message);
|
|
||||||
print "<li class='fail'>\n";
|
|
||||||
print "<span>Error</span>";
|
|
||||||
print "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
|
||||||
$breadcrumb = Set::filter($this->getTestList());
|
|
||||||
array_shift($breadcrumb);
|
|
||||||
print "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
|
||||||
print "</li>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Paints a PHP exception.
|
|
||||||
* @param Exception $exception Exception to display.
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
function paintException($exception) {
|
|
||||||
parent::paintException($exception);
|
|
||||||
print "<li class='fail'>\n";
|
|
||||||
print "<span>Exception</span>";
|
|
||||||
$message = 'Unexpected exception of type [' . get_class($exception) .
|
|
||||||
'] with message ['. $exception->getMessage() .
|
|
||||||
'] in ['. $exception->getFile() .
|
|
||||||
' line ' . $exception->getLine() . ']';
|
|
||||||
print "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
|
||||||
$breadcrumb = Set::filter($this->getTestList());
|
|
||||||
array_shift($breadcrumb);
|
|
||||||
print "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
|
||||||
print "</li>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints the message for skipping tests.
|
|
||||||
* @param string $message Text of skip condition.
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
function paintSkip($message) {
|
|
||||||
parent::paintSkip($message);
|
|
||||||
print "<li class='skipped'>\n";
|
|
||||||
print "<span>Skipped</span> ";
|
|
||||||
print $this->_htmlEntities($message);
|
|
||||||
print "</li>\n";
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
/**
|
* Paints a PHP error.
|
||||||
* Paints formatted text such as dumped variables.
|
* @param string $message Message is ignored.
|
||||||
* @param string $message Text to show.
|
* @access public
|
||||||
* @access public
|
*/
|
||||||
*/
|
function paintError($message) {
|
||||||
function paintFormattedMessage($message) {
|
ob_start();
|
||||||
print '<pre>' . $this->_htmlEntities($message) . '</pre>';
|
parent::paintError($message);
|
||||||
}
|
echo "<li class='fail'>\n";
|
||||||
|
echo "<span>Error</span>";
|
||||||
/**
|
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||||
* Character set adjusted entity conversion.
|
$breadcrumb = Set::filter($this->getTestList());
|
||||||
* @param string $message Plain text or Unicode message.
|
array_shift($breadcrumb);
|
||||||
* @return string Browser readable message.
|
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||||
* @access protected
|
echo "</li>\n";
|
||||||
*/
|
}
|
||||||
function _htmlEntities($message) {
|
/**
|
||||||
return htmlentities($message, ENT_COMPAT, $this->_character_set);
|
* Paints a PHP exception.
|
||||||
}
|
* @param Exception $exception Exception to display.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintException($exception) {
|
||||||
|
ob_start();
|
||||||
|
parent::paintException($exception);
|
||||||
|
echo "<li class='fail'>\n";
|
||||||
|
echo "<span>Exception</span>";
|
||||||
|
$message = 'Unexpected exception of type [' . get_class($exception) .
|
||||||
|
'] with message ['. $exception->getMessage() .
|
||||||
|
'] in ['. $exception->getFile() .
|
||||||
|
' line ' . $exception->getLine() . ']';
|
||||||
|
echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n";
|
||||||
|
$breadcrumb = Set::filter($this->getTestList());
|
||||||
|
array_shift($breadcrumb);
|
||||||
|
echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n";
|
||||||
|
echo "</li>\n";
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Prints the message for skipping tests.
|
||||||
|
* @param string $message Text of skip condition.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintSkip($message) {
|
||||||
|
ob_start();
|
||||||
|
parent::paintSkip($message);
|
||||||
|
echo "<li class='skipped'>\n";
|
||||||
|
echo "<span>Skipped</span> ";
|
||||||
|
echo $this->_htmlEntities($message);
|
||||||
|
echo "</li>\n";
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Paints formatted text such as dumped variables.
|
||||||
|
* @param string $message Text to show.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function paintFormattedMessage($message) {
|
||||||
|
ob_start();
|
||||||
|
echo '<pre>' . $this->_htmlEntities($message) . '</pre>';
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Character set adjusted entity conversion.
|
||||||
|
* @param string $message Plain text or Unicode message.
|
||||||
|
* @return string Browser readable message.
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function _htmlEntities($message) {
|
||||||
|
return htmlentities($message, ENT_COMPAT, $this->_character_set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -128,7 +128,6 @@ class CakeTestCase extends UnitTestCase {
|
||||||
*/
|
*/
|
||||||
function endTest($method) {
|
function endTest($method) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides SimpleTestCase::assert to enable calling of skipIf() from within tests
|
* Overrides SimpleTestCase::assert to enable calling of skipIf() from within tests
|
||||||
*/
|
*/
|
||||||
|
@ -138,7 +137,6 @@ class CakeTestCase extends UnitTestCase {
|
||||||
}
|
}
|
||||||
return parent::assert($expectation, $compare, $message);
|
return parent::assert($expectation, $compare, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides SimpleTestCase::skipIf to provide a boolean return value
|
* Overrides SimpleTestCase::skipIf to provide a boolean return value
|
||||||
*/
|
*/
|
||||||
|
@ -146,7 +144,6 @@ class CakeTestCase extends UnitTestCase {
|
||||||
parent::skipIf($shouldSkip, $message);
|
parent::skipIf($shouldSkip, $message);
|
||||||
return $shouldSkip;
|
return $shouldSkip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback issued when a controller's action is about to be invoked through testAction().
|
* Callback issued when a controller's action is about to be invoked through testAction().
|
||||||
*
|
*
|
||||||
|
@ -158,7 +155,6 @@ class CakeTestCase extends UnitTestCase {
|
||||||
if (!isset($this->db)) {
|
if (!isset($this->db)) {
|
||||||
$this->_initDb();
|
$this->_initDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
$classRegistry =& ClassRegistry::getInstance();
|
$classRegistry =& ClassRegistry::getInstance();
|
||||||
$models = array();
|
$models = array();
|
||||||
|
|
||||||
|
@ -168,8 +164,7 @@ class CakeTestCase extends UnitTestCase {
|
||||||
$models[$object->alias] = array (
|
$models[$object->alias] = array (
|
||||||
'table' => $object->table,
|
'table' => $object->table,
|
||||||
'model' => $object->alias,
|
'model' => $object->alias,
|
||||||
'key' => Inflector::camelize($key)
|
'key' => Inflector::camelize($key));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,8 +172,7 @@ class CakeTestCase extends UnitTestCase {
|
||||||
$this->_queries = array(
|
$this->_queries = array(
|
||||||
'create' => array(),
|
'create' => array(),
|
||||||
'insert' => array(),
|
'insert' => array(),
|
||||||
'drop' => array()
|
'drop' => array());
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($models as $model) {
|
foreach ($models as $model) {
|
||||||
$fixture =& new CakeTestFixture($this->db);
|
$fixture =& new CakeTestFixture($this->db);
|
||||||
|
|
|
@ -33,8 +33,8 @@ define ('APP_TEST_GROUPS', APP . 'tests' .DS. 'groups');
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.cake.tests.lib
|
* @subpackage cake.cake.tests.lib
|
||||||
*/
|
*/
|
||||||
class TestManager {
|
class TestManager {
|
||||||
var $_testExtension = '.test.php';
|
var $_testExtension = '.test.php';
|
||||||
|
@ -243,8 +243,8 @@ class TestManager {
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.cake.tests.lib
|
* @subpackage cake.cake.tests.lib
|
||||||
*/
|
*/
|
||||||
class CliTestManager extends TestManager {
|
class CliTestManager extends TestManager {
|
||||||
|
|
||||||
|
@ -273,8 +273,8 @@ class CliTestManager extends TestManager {
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.cake.tests.lib
|
* @subpackage cake.cake.tests.lib
|
||||||
*/
|
*/
|
||||||
class TextTestManager extends TestManager {
|
class TextTestManager extends TestManager {
|
||||||
var $_url;
|
var $_url;
|
||||||
|
@ -302,7 +302,7 @@ class TextTestManager extends TestManager {
|
||||||
$urlExtra = '&plugin=' . $manager->pluginTest;
|
$urlExtra = '&plugin=' . $manager->pluginTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
$buffer .= "All tests\n" . $_SERVER['SERVER_NAME'] . $manager->getBaseURL() . "?group=all&output=txt{$urlExtra}\n";
|
$buffer .= "All tests\n" . $_SERVER['SERVER_NAME'] . $manager->getBaseURL() . "?group=all&output=txt{$urlExtra}\n";
|
||||||
|
|
||||||
foreach ((array)$groupTests as $groupTest) {
|
foreach ((array)$groupTests as $groupTest) {
|
||||||
$buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?group=" . $groupTest . "&output=txt{$urlExtra}"."\n";
|
$buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?group=" . $groupTest . "&output=txt{$urlExtra}"."\n";
|
||||||
|
@ -341,8 +341,8 @@ class TextTestManager extends TestManager {
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.cake.tests.lib
|
* @subpackage cake.cake.tests.lib
|
||||||
*/
|
*/
|
||||||
class HtmlTestManager extends TestManager {
|
class HtmlTestManager extends TestManager {
|
||||||
var $_url;
|
var $_url;
|
||||||
|
@ -376,7 +376,7 @@ class HtmlTestManager extends TestManager {
|
||||||
foreach ((array)$groupTests as $groupTest) {
|
foreach ((array)$groupTests as $groupTest) {
|
||||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}" . "{$urlExtra}'>" . $groupTest . "</a></li>\n";
|
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}" . "{$urlExtra}'>" . $groupTest . "</a></li>\n";
|
||||||
}
|
}
|
||||||
$buffer .= "</ul>\n";
|
$buffer .= "</ul>\n";
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ class HtmlTestManager extends TestManager {
|
||||||
|
|
||||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $title . "</a></li>\n";
|
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $title . "</a></li>\n";
|
||||||
}
|
}
|
||||||
$buffer .= "</ul>\n";
|
$buffer .= "</ul>\n";
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,6 +465,7 @@ if (function_exists('caketestsgetreporter')) {
|
||||||
$query .= '&plugin=' . $_GET['plugin'];
|
$query .= '&plugin=' . $_GET['plugin'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ob_start();
|
||||||
echo "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a> | <a href='" . RUN_TEST_LINK . $query . "&show_passes=1'>Show Passes</a> | \n";
|
echo "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a> | <a href='" . RUN_TEST_LINK . $query . "&show_passes=1'>Show Passes</a> | \n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -489,6 +490,7 @@ if (function_exists('caketestsgetreporter')) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query .= '&code_coverage=true';
|
$query .= '&code_coverage=true';
|
||||||
|
ob_start();
|
||||||
echo " <a href='" . RUN_TEST_LINK . $query . "'>Analyze Code Coverage</a></p>\n";
|
echo " <a href='" . RUN_TEST_LINK . $query . "'>Analyze Code Coverage</a></p>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -497,6 +499,7 @@ if (function_exists('caketestsgetreporter')) {
|
||||||
function CakePHPTestCaseList() {
|
function CakePHPTestCaseList() {
|
||||||
switch (CAKE_TEST_OUTPUT) {
|
switch (CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
|
ob_start();
|
||||||
echo HtmlTestManager::getTestCaseList();
|
echo HtmlTestManager::getTestCaseList();
|
||||||
break;
|
break;
|
||||||
case CAKE_TEST_OUTPUT_TEXT:
|
case CAKE_TEST_OUTPUT_TEXT:
|
||||||
|
@ -521,6 +524,7 @@ if (function_exists('caketestsgetreporter')) {
|
||||||
function CakePHPTestHeader() {
|
function CakePHPTestHeader() {
|
||||||
switch (CAKE_TEST_OUTPUT) {
|
switch (CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
|
ob_start();
|
||||||
$dispatch =& new Dispatcher();
|
$dispatch =& new Dispatcher();
|
||||||
$dispatch->baseUrl();
|
$dispatch->baseUrl();
|
||||||
define('BASE', $dispatch->webroot);
|
define('BASE', $dispatch->webroot);
|
||||||
|
@ -538,6 +542,7 @@ if (function_exists('caketestsgetreporter')) {
|
||||||
function CakePHPTestSuiteHeader() {
|
function CakePHPTestSuiteHeader() {
|
||||||
switch (CAKE_TEST_OUTPUT) {
|
switch (CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
|
ob_start();
|
||||||
$groups = $_SERVER['PHP_SELF'].'?show=groups';
|
$groups = $_SERVER['PHP_SELF'].'?show=groups';
|
||||||
$cases = $_SERVER['PHP_SELF'].'?show=cases';
|
$cases = $_SERVER['PHP_SELF'].'?show=cases';
|
||||||
$plugins = Configure::listObjects('plugin');
|
$plugins = Configure::listObjects('plugin');
|
||||||
|
@ -549,6 +554,7 @@ if (function_exists('caketestsgetreporter')) {
|
||||||
function CakePHPTestSuiteFooter() {
|
function CakePHPTestSuiteFooter() {
|
||||||
switch ( CAKE_TEST_OUTPUT) {
|
switch ( CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
|
ob_start();
|
||||||
$baseUrl = BASE;
|
$baseUrl = BASE;
|
||||||
include CAKE_TESTS_LIB . 'footer.php';
|
include CAKE_TESTS_LIB . 'footer.php';
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue