mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Merge remote branch 'origin/2.0' into 2.0-phpunit-upgrade
This commit is contained in:
commit
0eaf437fe4
115 changed files with 1327 additions and 1232 deletions
|
@ -264,6 +264,9 @@ class ShellDispatcher {
|
||||||
include_once CORE_PATH . 'cake' . DS . 'console' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php';
|
include_once CORE_PATH . 'cake' . DS . 'console' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php';
|
||||||
App::build();
|
App::build();
|
||||||
}
|
}
|
||||||
|
if (!defined('FULL_BASE_URL')) {
|
||||||
|
define('FULL_BASE_URL', '/');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,10 +115,7 @@ class TemplateTask extends Shell {
|
||||||
if ($data == null) {
|
if ($data == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$this->templateVars = $data + $this->templateVars;
|
||||||
foreach ($data as $name => $value) {
|
|
||||||
$this->templateVars[$name] = $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -344,7 +344,7 @@ class ViewTask extends BakeTask {
|
||||||
$this->hr();
|
$this->hr();
|
||||||
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
|
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
|
||||||
if (strtolower($looksGood) == 'y') {
|
if (strtolower($looksGood) == 'y') {
|
||||||
$this->bake($action);
|
$this->bake($action, ' ');
|
||||||
$this->_stop();
|
$this->_stop();
|
||||||
} else {
|
} else {
|
||||||
$this->out(__('Bake Aborted.'));
|
$this->out(__('Bake Aborted.'));
|
||||||
|
|
|
@ -266,7 +266,7 @@ class Cache {
|
||||||
}
|
}
|
||||||
$key = self::$_engines[$config]->key($key);
|
$key = self::$_engines[$config]->key($key);
|
||||||
|
|
||||||
if (!$key || is_resource($value) || $settings['duration'] < 1) {
|
if (!$key || is_resource($value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
cake/libs/cache/file.php
vendored
1
cake/libs/cache/file.php
vendored
|
@ -299,6 +299,7 @@ class FileEngine extends CacheEngine {
|
||||||
if ($this->_init && !($dir->isDir() && $dir->isWritable())) {
|
if ($this->_init && !($dir->isDir() && $dir->isWritable())) {
|
||||||
$this->_init = false;
|
$this->_init = false;
|
||||||
trigger_error(sprintf(__('%s is not writable'), $this->settings['path']), E_USER_WARNING);
|
trigger_error(sprintf(__('%s is not writable'), $this->settings['path']), E_USER_WARNING);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,7 +390,7 @@ class CakeResponse {
|
||||||
* e.g `header('WWW-Authenticate: Negotiate');`
|
* e.g `header('WWW-Authenticate: Negotiate');`
|
||||||
*
|
*
|
||||||
* ### Array of string headers
|
* ### Array of string headers
|
||||||
* e.g `header(array('WWW-Authenticate: Negotiate'), array('Content-type: application/pdf'));`
|
* e.g `header(array('WWW-Authenticate: Negotiate', 'Content-type: application/pdf'));`
|
||||||
*
|
*
|
||||||
* Multiple calls for setting the same header name will have the same effect as setting the header once
|
* Multiple calls for setting the same header name will have the same effect as setting the header once
|
||||||
* with the last value sent for it
|
* with the last value sent for it
|
||||||
|
|
|
@ -116,6 +116,16 @@ class CookieComponent extends Component {
|
||||||
*/
|
*/
|
||||||
public $key = null;
|
public $key = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTTP only cookie
|
||||||
|
*
|
||||||
|
* Set to true to make HTTP only cookies. Cookies that are HTTP only
|
||||||
|
* are not accessible in Javascript.
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
public $httpOnly = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Values stored in the cookie.
|
* Values stored in the cookie.
|
||||||
*
|
*
|
||||||
|
@ -125,7 +135,7 @@ class CookieComponent extends Component {
|
||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private $__values = array();
|
protected $_values = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of encryption to use.
|
* Type of encryption to use.
|
||||||
|
@ -137,7 +147,7 @@ class CookieComponent extends Component {
|
||||||
* @access private
|
* @access private
|
||||||
* @todo add additional encryption methods
|
* @todo add additional encryption methods
|
||||||
*/
|
*/
|
||||||
private $__type = 'cipher';
|
protected $_type = 'cipher';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to reset cookie time if $expire is passed to CookieComponent::write()
|
* Used to reset cookie time if $expire is passed to CookieComponent::write()
|
||||||
|
@ -145,7 +155,7 @@ class CookieComponent extends Component {
|
||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private $__reset = null;
|
protected $_reset = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expire time of the cookie
|
* Expire time of the cookie
|
||||||
|
@ -155,15 +165,17 @@ class CookieComponent extends Component {
|
||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private $__expires = 0;
|
protected $_expires = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main execution method.
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to the instantiating controller object
|
* @param ComponentCollection $collection A ComponentCollection for this component
|
||||||
|
* @param array $settings Array of settings.
|
||||||
*/
|
*/
|
||||||
public function initialize(&$controller) {
|
public function __construct(ComponentCollection $collection, $settings = array()) {
|
||||||
$this->key = Configure::read('Security.salt');
|
$this->key = Configure::read('Security.salt');
|
||||||
|
parent::__construct($collection, $settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,10 +183,10 @@ class CookieComponent extends Component {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function startup() {
|
public function startup() {
|
||||||
$this->__expire($this->time);
|
$this->_expire($this->time);
|
||||||
|
|
||||||
if (isset($_COOKIE[$this->name])) {
|
if (isset($_COOKIE[$this->name])) {
|
||||||
$this->__values = $this->__decrypt($_COOKIE[$this->name]);
|
$this->_values = $this->_decrypt($_COOKIE[$this->name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,8 +211,8 @@ class CookieComponent extends Component {
|
||||||
if (is_null($encrypt)) {
|
if (is_null($encrypt)) {
|
||||||
$encrypt = true;
|
$encrypt = true;
|
||||||
}
|
}
|
||||||
$this->__encrypted = $encrypt;
|
$this->_encrypted = $encrypt;
|
||||||
$this->__expire($expires);
|
$this->_expire($expires);
|
||||||
|
|
||||||
if (!is_array($key)) {
|
if (!is_array($key)) {
|
||||||
$key = array($key => $value);
|
$key = array($key => $value);
|
||||||
|
@ -208,19 +220,19 @@ class CookieComponent extends Component {
|
||||||
|
|
||||||
foreach ($key as $name => $value) {
|
foreach ($key as $name => $value) {
|
||||||
if (strpos($name, '.') === false) {
|
if (strpos($name, '.') === false) {
|
||||||
$this->__values[$name] = $value;
|
$this->_values[$name] = $value;
|
||||||
$this->__write("[$name]", $value);
|
$this->_write("[$name]", $value);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$names = explode('.', $name, 2);
|
$names = explode('.', $name, 2);
|
||||||
if (!isset($this->__values[$names[0]])) {
|
if (!isset($this->_values[$names[0]])) {
|
||||||
$this->__values[$names[0]] = array();
|
$this->_values[$names[0]] = array();
|
||||||
}
|
}
|
||||||
$this->__values[$names[0]] = Set::insert($this->__values[$names[0]], $names[1], $value);
|
$this->_values[$names[0]] = Set::insert($this->_values[$names[0]], $names[1], $value);
|
||||||
$this->__write('[' . implode('][', $names) . ']', $value);
|
$this->_write('[' . implode('][', $names) . ']', $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->__encrypted = true;
|
$this->_encrypted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,26 +245,26 @@ class CookieComponent extends Component {
|
||||||
* @return string or null, value for specified key
|
* @return string or null, value for specified key
|
||||||
*/
|
*/
|
||||||
public function read($key = null) {
|
public function read($key = null) {
|
||||||
if (empty($this->__values) && isset($_COOKIE[$this->name])) {
|
if (empty($this->_values) && isset($_COOKIE[$this->name])) {
|
||||||
$this->__values = $this->__decrypt($_COOKIE[$this->name]);
|
$this->_values = $this->_decrypt($_COOKIE[$this->name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($key)) {
|
if (is_null($key)) {
|
||||||
return $this->__values;
|
return $this->_values;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($key, '.') !== false) {
|
if (strpos($key, '.') !== false) {
|
||||||
$names = explode('.', $key, 2);
|
$names = explode('.', $key, 2);
|
||||||
$key = $names[0];
|
$key = $names[0];
|
||||||
}
|
}
|
||||||
if (!isset($this->__values[$key])) {
|
if (!isset($this->_values[$key])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($names[1])) {
|
if (!empty($names[1])) {
|
||||||
return Set::extract($this->__values[$key], $names[1]);
|
return Set::extract($this->_values[$key], $names[1]);
|
||||||
}
|
}
|
||||||
return $this->__values[$key];
|
return $this->_values[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,17 +280,17 @@ class CookieComponent extends Component {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function delete($key) {
|
public function delete($key) {
|
||||||
if (empty($this->__values)) {
|
if (empty($this->_values)) {
|
||||||
$this->read();
|
$this->read();
|
||||||
}
|
}
|
||||||
if (strpos($key, '.') === false) {
|
if (strpos($key, '.') === false) {
|
||||||
unset($this->__values[$key]);
|
unset($this->_values[$key]);
|
||||||
$this->__delete("[$key]");
|
$this->_delete("[$key]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$names = explode('.', $key, 2);
|
$names = explode('.', $key, 2);
|
||||||
$this->__values[$names[0]] = Set::remove($this->__values[$names[0]], $names[1]);
|
$this->_values[$names[0]] = Set::remove($this->_values[$names[0]], $names[1]);
|
||||||
$this->__delete('[' . implode('][', $names) . ']');
|
$this->_delete('[' . implode('][', $names) . ']');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,18 +303,18 @@ class CookieComponent extends Component {
|
||||||
*/
|
*/
|
||||||
public function destroy() {
|
public function destroy() {
|
||||||
if (isset($_COOKIE[$this->name])) {
|
if (isset($_COOKIE[$this->name])) {
|
||||||
$this->__values = $this->__decrypt($_COOKIE[$this->name]);
|
$this->_values = $this->_decrypt($_COOKIE[$this->name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->__values as $name => $value) {
|
foreach ($this->_values as $name => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
foreach ($value as $key => $val) {
|
foreach ($value as $key => $val) {
|
||||||
unset($this->__values[$name][$key]);
|
unset($this->_values[$name][$key]);
|
||||||
$this->__delete("[$name][$key]");
|
$this->_delete("[$name][$key]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($this->__values[$name]);
|
unset($this->_values[$name]);
|
||||||
$this->__delete("[$name]");
|
$this->_delete("[$name]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,8 +325,8 @@ class CookieComponent extends Component {
|
||||||
* @access public
|
* @access public
|
||||||
* @todo NOT IMPLEMENTED
|
* @todo NOT IMPLEMENTED
|
||||||
*/
|
*/
|
||||||
function type($type = 'cipher') {
|
public function type($type = 'cipher') {
|
||||||
$this->__type = 'cipher';
|
$this->_type = 'cipher';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -329,23 +341,22 @@ class CookieComponent extends Component {
|
||||||
*
|
*
|
||||||
* @param mixed $expires Can be either Unix timestamp, or date string
|
* @param mixed $expires Can be either Unix timestamp, or date string
|
||||||
* @return int Unix timestamp
|
* @return int Unix timestamp
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __expire($expires = null) {
|
protected function _expire($expires = null) {
|
||||||
$now = time();
|
$now = time();
|
||||||
if (is_null($expires)) {
|
if (is_null($expires)) {
|
||||||
return $this->__expires;
|
return $this->_expires;
|
||||||
}
|
}
|
||||||
$this->__reset = $this->__expires;
|
$this->_reset = $this->_expires;
|
||||||
|
|
||||||
if ($expires == 0) {
|
if ($expires == 0) {
|
||||||
return $this->__expires = 0;
|
return $this->_expires = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_integer($expires) || is_numeric($expires)) {
|
if (is_integer($expires) || is_numeric($expires)) {
|
||||||
return $this->__expires = $now + intval($expires);
|
return $this->_expires = $now + intval($expires);
|
||||||
}
|
}
|
||||||
return $this->__expires = strtotime($expires, $now);
|
return $this->_expires = strtotime($expires, $now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -353,14 +364,16 @@ class CookieComponent extends Component {
|
||||||
*
|
*
|
||||||
* @param string $name Name for cookie
|
* @param string $name Name for cookie
|
||||||
* @param string $value Value for cookie
|
* @param string $value Value for cookie
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __write($name, $value) {
|
protected function _write($name, $value) {
|
||||||
setcookie($this->name . $name, $this->__encrypt($value), $this->__expires, $this->path, $this->domain, $this->secure);
|
$this->_setcookie(
|
||||||
|
$this->name . $name, $this->_encrypt($value),
|
||||||
|
$this->_expires, $this->path, $this->domain, $this->secure, $this->httpOnly
|
||||||
|
);
|
||||||
|
|
||||||
if (!is_null($this->__reset)) {
|
if (!is_null($this->_reset)) {
|
||||||
$this->__expires = $this->__reset;
|
$this->_expires = $this->_reset;
|
||||||
$this->__reset = null;
|
$this->_reset = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,26 +381,43 @@ class CookieComponent extends Component {
|
||||||
* Sets a cookie expire time to remove cookie value
|
* Sets a cookie expire time to remove cookie value
|
||||||
*
|
*
|
||||||
* @param string $name Name of cookie
|
* @param string $name Name of cookie
|
||||||
* @access private
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __delete($name) {
|
protected function _delete($name) {
|
||||||
setcookie($this->name . $name, '', time() - 42000, $this->path, $this->domain, $this->secure);
|
$this->_setcookie(
|
||||||
|
$this->name . $name, '',
|
||||||
|
time() - 42000, $this->path, $this->domain, $this->secure, $this->httpOnly
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object wrapper for setcookie() so it can be mocked in unit tests.
|
||||||
|
*
|
||||||
|
* @param string $name Name of the cookie
|
||||||
|
* @param integer $expire Time the cookie expires in
|
||||||
|
* @param string $path Path the cookie applies to
|
||||||
|
* @param string $domain Domain the cookie is for.
|
||||||
|
* @param boolean $secure Is the cookie https?
|
||||||
|
* @param boolean $httpOnly Is the cookie available in the client?
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function _setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly = false) {
|
||||||
|
setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Encrypts $value using public $type method in Security class
|
* Encrypts $value using public $type method in Security class
|
||||||
*
|
*
|
||||||
* @param string $value Value to encrypt
|
* @param string $value Value to encrypt
|
||||||
* @return string encrypted string
|
* @return string encrypted string
|
||||||
* @access private
|
* @return string Encoded values
|
||||||
*/
|
*/
|
||||||
function __encrypt($value) {
|
protected function _encrypt($value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value = $this->__implode($value);
|
$value = $this->_implode($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->__encrypted === true) {
|
if ($this->_encrypted === true) {
|
||||||
$type = $this->__type;
|
$type = $this->_type;
|
||||||
$value = "Q2FrZQ==." .base64_encode(Security::$type($value, $this->key));
|
$value = "Q2FrZQ==." .base64_encode(Security::$type($value, $this->key));
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -398,30 +428,29 @@ class CookieComponent extends Component {
|
||||||
*
|
*
|
||||||
* @param array $values Values to decrypt
|
* @param array $values Values to decrypt
|
||||||
* @return string decrypted string
|
* @return string decrypted string
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __decrypt($values) {
|
protected function _decrypt($values) {
|
||||||
$decrypted = array();
|
$decrypted = array();
|
||||||
$type = $this->__type;
|
$type = $this->_type;
|
||||||
|
|
||||||
foreach ($values as $name => $value) {
|
foreach ($values as $name => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
foreach ($value as $key => $val) {
|
foreach ($value as $key => $val) {
|
||||||
$pos = strpos($val, 'Q2FrZQ==.');
|
$pos = strpos($val, 'Q2FrZQ==.');
|
||||||
$decrypted[$name][$key] = $this->__explode($val);
|
$decrypted[$name][$key] = $this->_explode($val);
|
||||||
|
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
$val = substr($val, 8);
|
$val = substr($val, 8);
|
||||||
$decrypted[$name][$key] = $this->__explode(Security::$type(base64_decode($val), $this->key));
|
$decrypted[$name][$key] = $this->_explode(Security::$type(base64_decode($val), $this->key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$pos = strpos($value, 'Q2FrZQ==.');
|
$pos = strpos($value, 'Q2FrZQ==.');
|
||||||
$decrypted[$name] = $this->__explode($value);
|
$decrypted[$name] = $this->_explode($value);
|
||||||
|
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
$value = substr($value, 8);
|
$value = substr($value, 8);
|
||||||
$decrypted[$name] = $this->__explode(Security::$type(base64_decode($value), $this->key));
|
$decrypted[$name] = $this->_explode(Security::$type(base64_decode($value), $this->key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -433,9 +462,8 @@ class CookieComponent extends Component {
|
||||||
*
|
*
|
||||||
* @param array $array Map of key and values
|
* @param array $array Map of key and values
|
||||||
* @return string String in the form key1|value1,key2|value2
|
* @return string String in the form key1|value1,key2|value2
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __implode($array) {
|
protected function _implode($array) {
|
||||||
$string = '';
|
$string = '';
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
$string .= ',' . $key . '|' . $value;
|
$string .= ',' . $key . '|' . $value;
|
||||||
|
@ -444,13 +472,12 @@ class CookieComponent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explode method to return array from string set in CookieComponent::__implode()
|
* Explode method to return array from string set in CookieComponent::_implode()
|
||||||
*
|
*
|
||||||
* @param string $string String in the form key1|value1,key2|value2
|
* @param string $string String in the form key1|value1,key2|value2
|
||||||
* @return array Map of key and values
|
* @return array Map of key and values
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __explode($string) {
|
protected function _explode($string) {
|
||||||
$array = array();
|
$array = array();
|
||||||
foreach (explode(',', $string) as $pair) {
|
foreach (explode(',', $string) as $pair) {
|
||||||
$key = explode('|', $pair);
|
$key = explode('|', $pair);
|
||||||
|
|
|
@ -790,8 +790,8 @@ class EmailComponent extends Component {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _mail() {
|
function _mail() {
|
||||||
$header = implode("\n", $this->_header);
|
$header = implode("\r\n", $this->_header);
|
||||||
$message = implode("\n", $this->_message);
|
$message = implode("\r\n", $this->_message);
|
||||||
if (is_array($this->to)) {
|
if (is_array($this->to)) {
|
||||||
$to = implode(', ', array_map(array($this, '_formatAddress'), $this->to));
|
$to = implode(', ', array_map(array($this, '_formatAddress'), $this->to));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -167,6 +167,8 @@ class RequestHandlerComponent extends Component {
|
||||||
$this->renderAs($controller, $this->ext);
|
$this->renderAs($controller, $this->ext);
|
||||||
} elseif ($this->request->is('ajax')) {
|
} elseif ($this->request->is('ajax')) {
|
||||||
$this->renderAs($controller, 'ajax');
|
$this->renderAs($controller, 'ajax');
|
||||||
|
} elseif (empty($this->ext) || in_array($this->ext, array('html', 'htm'))) {
|
||||||
|
$this->respondAs('html', array('charset' => Configure::read('App.encoding')));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->requestedWith('xml')) {
|
if ($this->requestedWith('xml')) {
|
||||||
|
|
|
@ -714,7 +714,7 @@ class Controller extends Object {
|
||||||
} else {
|
} else {
|
||||||
$data = array($one => $two);
|
$data = array($one => $two);
|
||||||
}
|
}
|
||||||
$this->viewVars = array_merge($this->viewVars, $data);
|
$this->viewVars = $data + $this->viewVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -74,13 +74,6 @@ class I18n {
|
||||||
*/
|
*/
|
||||||
private $__noLocale = false;
|
private $__noLocale = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if $__domains cache should be wrote
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private $__cache = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true when I18N::__bindTextDomain() is called for the first time.
|
* Set to true when I18N::__bindTextDomain() is called for the first time.
|
||||||
* If a translation file is found it is set to false again
|
* If a translation file is found it is set to false again
|
||||||
|
@ -118,7 +111,7 @@ class I18n {
|
||||||
*/
|
*/
|
||||||
public static function translate($singular, $plural = null, $domain = null, $category = 6, $count = null) {
|
public static function translate($singular, $plural = null, $domain = null, $category = 6, $count = null) {
|
||||||
$_this =& I18n::getInstance();
|
$_this =& I18n::getInstance();
|
||||||
|
|
||||||
if (strpos($singular, "\r\n") !== false) {
|
if (strpos($singular, "\r\n") !== false) {
|
||||||
$singular = str_replace("\r\n", "\n", $singular);
|
$singular = str_replace("\r\n", "\n", $singular);
|
||||||
}
|
}
|
||||||
|
@ -143,15 +136,16 @@ class I18n {
|
||||||
if (is_null($domain)) {
|
if (is_null($domain)) {
|
||||||
$domain = 'default';
|
$domain = 'default';
|
||||||
}
|
}
|
||||||
$_this->domain = $domain . '_' . $_this->l10n->locale;
|
|
||||||
|
|
||||||
if (empty($_this->__domains)) {
|
$_this->domain = $domain . '_' . $_this->l10n->lang;
|
||||||
$_this->__domains = Cache::read($_this->domain, '_cake_core_');
|
|
||||||
|
if (empty($_this->__domains[$domain][$_this->__lang])) {
|
||||||
|
$_this->__domains[$domain][$_this->__lang] = Cache::read($_this->domain, '_cake_core_');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_this->__domains[$_this->category][$_this->__lang][$domain])) {
|
if (empty($_this->__domains[$domain][$_this->__lang][$_this->category])) {
|
||||||
$_this->__bindTextDomain($domain);
|
$_this->__bindTextDomain($domain);
|
||||||
$_this->__cache = true;
|
Cache::write($_this->domain, $_this->__domains[$domain][$_this->__lang], '_cake_core_');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_this->category == 'LC_TIME') {
|
if ($_this->category == 'LC_TIME') {
|
||||||
|
@ -160,8 +154,8 @@ class I18n {
|
||||||
|
|
||||||
if (!isset($count)) {
|
if (!isset($count)) {
|
||||||
$plurals = 0;
|
$plurals = 0;
|
||||||
} elseif (!empty($_this->__domains[$_this->category][$_this->__lang][$domain]["%plural-c"]) && $_this->__noLocale === false) {
|
} elseif (!empty($_this->__domains[$domain][$_this->__lang][$_this->category]["%plural-c"]) && $_this->__noLocale === false) {
|
||||||
$header = $_this->__domains[$_this->category][$_this->__lang][$domain]["%plural-c"];
|
$header = $_this->__domains[$domain][$_this->__lang][$_this->category]["%plural-c"];
|
||||||
$plurals = $_this->__pluralGuess($header, $count);
|
$plurals = $_this->__pluralGuess($header, $count);
|
||||||
} else {
|
} else {
|
||||||
if ($count != 1) {
|
if ($count != 1) {
|
||||||
|
@ -171,8 +165,8 @@ class I18n {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_this->__domains[$_this->category][$_this->__lang][$domain][$singular])) {
|
if (!empty($_this->__domains[$domain][$_this->__lang][$_this->category][$singular])) {
|
||||||
if (($trans = $_this->__domains[$_this->category][$_this->__lang][$domain][$singular]) || ($plurals) && ($trans = $_this->__domains[$_this->category][$_this->__lang][$domain][$plural])) {
|
if (($trans = $_this->__domains[$domain][$_this->__lang][$_this->category][$singular]) || ($plurals) && ($trans = $_this->__domains[$domain][$_this->__lang][$_this->category][$plural])) {
|
||||||
if (is_array($trans)) {
|
if (is_array($trans)) {
|
||||||
if (isset($trans[$plurals])) {
|
if (isset($trans[$plurals])) {
|
||||||
$trans = $trans[$plurals];
|
$trans = $trans[$plurals];
|
||||||
|
@ -190,6 +184,26 @@ class I18n {
|
||||||
return $singular;
|
return $singular;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the domains internal data array. Useful for testing i18n.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function clear() {
|
||||||
|
$self =& I18n::getInstance();
|
||||||
|
$self->__domains = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the loaded domains cache.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function domains() {
|
||||||
|
$self =& I18n::getInstance();
|
||||||
|
return $self->__domains;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to find the plural form of a string.
|
* Attempts to find the plural form of a string.
|
||||||
*
|
*
|
||||||
|
@ -276,12 +290,12 @@ class I18n {
|
||||||
if (file_exists($fn = "$app.mo")) {
|
if (file_exists($fn = "$app.mo")) {
|
||||||
$this->__loadMo($fn, $domain);
|
$this->__loadMo($fn, $domain);
|
||||||
$this->__noLocale = false;
|
$this->__noLocale = false;
|
||||||
$merge[$this->category][$this->__lang][$domain] = $this->__domains[$this->category][$this->__lang][$domain];
|
$merge[$domain][$this->__lang][$this->category] = $this->__domains[$domain][$this->__lang][$this->category];
|
||||||
$core = null;
|
$core = null;
|
||||||
} elseif (file_exists($fn = "$app.po") && ($f = fopen($fn, "r"))) {
|
} elseif (file_exists($fn = "$app.po") && ($f = fopen($fn, "r"))) {
|
||||||
$this->__loadPo($f, $domain);
|
$this->__loadPo($f, $domain);
|
||||||
$this->__noLocale = false;
|
$this->__noLocale = false;
|
||||||
$merge[$this->category][$this->__lang][$domain] = $this->__domains[$this->category][$this->__lang][$domain];
|
$merge[$domain][$this->__lang][$this->category] = $this->__domains[$domain][$this->__lang][$this->category];
|
||||||
$core = null;
|
$core = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,27 +316,27 @@ class I18n {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->__domains[$this->category][$this->__lang][$domain])) {
|
if (empty($this->__domains[$domain][$this->__lang][$this->category])) {
|
||||||
$this->__domains[$this->category][$this->__lang][$domain] = array();
|
$this->__domains[$domain][$this->__lang][$this->category] = array();
|
||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($head = $this->__domains[$this->category][$this->__lang][$domain][""]) {
|
if ($head = $this->__domains[$domain][$this->__lang][$this->category][""]) {
|
||||||
foreach (explode("\n", $head) as $line) {
|
foreach (explode("\n", $head) as $line) {
|
||||||
$header = strtok($line,":");
|
$header = strtok($line,":");
|
||||||
$line = trim(strtok("\n"));
|
$line = trim(strtok("\n"));
|
||||||
$this->__domains[$this->category][$this->__lang][$domain]["%po-header"][strtolower($header)] = $line;
|
$this->__domains[$domain][$this->__lang][$this->category]["%po-header"][strtolower($header)] = $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->__domains[$this->category][$this->__lang][$domain]["%po-header"]["plural-forms"])) {
|
if (isset($this->__domains[$domain][$this->__lang][$this->category]["%po-header"]["plural-forms"])) {
|
||||||
$switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $this->__domains[$this->category][$this->__lang][$domain]["%po-header"]["plural-forms"]);
|
$switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $this->__domains[$domain][$this->__lang][$this->category]["%po-header"]["plural-forms"]);
|
||||||
$this->__domains[$this->category][$this->__lang][$domain]["%plural-c"] = $switch;
|
$this->__domains[$domain][$this->__lang][$this->category]["%plural-c"] = $switch;
|
||||||
unset($this->__domains[$this->category][$this->__lang][$domain]["%po-header"]);
|
unset($this->__domains[$domain][$this->__lang][$this->category]["%po-header"]);
|
||||||
}
|
}
|
||||||
$this->__domains = Set::pushDiff($this->__domains, $merge);
|
$this->__domains = Set::pushDiff($this->__domains, $merge);
|
||||||
|
|
||||||
if (isset($this->__domains[$this->category][$this->__lang][$domain][null])) {
|
if (isset($this->__domains[$domain][$this->__lang][$this->category][null])) {
|
||||||
unset($this->__domains[$this->category][$this->__lang][$domain][null]);
|
unset($this->__domains[$domain][$this->__lang][$this->category][null]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $domain;
|
return $domain;
|
||||||
|
@ -357,10 +371,10 @@ class I18n {
|
||||||
if (strpos($msgstr, "\000")) {
|
if (strpos($msgstr, "\000")) {
|
||||||
$msgstr = explode("\000", $msgstr);
|
$msgstr = explode("\000", $msgstr);
|
||||||
}
|
}
|
||||||
$this->__domains[$this->category][$this->__lang][$domain][$msgid] = $msgstr;
|
$this->__domains[$domain][$this->__lang][$this->category][$msgid] = $msgstr;
|
||||||
|
|
||||||
if (isset($msgid_plural)) {
|
if (isset($msgid_plural)) {
|
||||||
$this->__domains[$this->category][$this->__lang][$domain][$msgid_plural] =& $this->__domains[$this->category][$this->__lang][$domain][$msgid];
|
$this->__domains[$domain][$this->__lang][$this->category][$msgid_plural] =& $this->__domains[$domain][$this->__lang][$this->category][$msgid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,7 +448,7 @@ class I18n {
|
||||||
} while (!feof($file));
|
} while (!feof($file));
|
||||||
fclose($file);
|
fclose($file);
|
||||||
$merge[""] = $header;
|
$merge[""] = $header;
|
||||||
return $this->__domains[$this->category][$this->__lang][$domain] = array_merge($merge ,$translations);
|
return $this->__domains[$domain][$this->__lang][$this->category] = array_merge($merge ,$translations);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -491,9 +505,9 @@ class I18n {
|
||||||
$value[$i] = $val;
|
$value[$i] = $val;
|
||||||
}
|
}
|
||||||
if (count($value) == 1) {
|
if (count($value) == 1) {
|
||||||
$this->__domains[$this->category][$this->__lang][$domain][$currentToken] = array_pop($value);
|
$this->__domains[$domain][$this->__lang][$this->category][$currentToken] = array_pop($value);
|
||||||
} else {
|
} else {
|
||||||
$this->__domains[$this->category][$this->__lang][$domain][$currentToken] = $value;
|
$this->__domains[$domain][$this->__lang][$this->category][$currentToken] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,23 +549,12 @@ class I18n {
|
||||||
* @param string $domain Domain where format is stored
|
* @param string $domain Domain where format is stored
|
||||||
* @return mixed translated format string if only value or array of translated strings for corresponding format.
|
* @return mixed translated format string if only value or array of translated strings for corresponding format.
|
||||||
*/
|
*/
|
||||||
private function __translateTime($format, $domain) {
|
function __translateTime($format, $domain) {
|
||||||
if (!empty($this->__domains['LC_TIME'][$this->__lang][$domain][$format])) {
|
if (!empty($this->__domains[$domain][$this->__lang]['LC_TIME'][$format])) {
|
||||||
if (($trans = $this->__domains[$this->category][$this->__lang][$domain][$format])) {
|
if (($trans = $this->__domains[$domain][$this->__lang][$this->category][$format])) {
|
||||||
return $trans;
|
return $trans;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $format;
|
return $format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Object destructor
|
|
||||||
*
|
|
||||||
* Write cache file if changes have been made to the $__map or $__paths
|
|
||||||
*/
|
|
||||||
function __destruct() {
|
|
||||||
if ($this->__cache) {
|
|
||||||
Cache::write($this->domain, array_filter($this->__domains), '_cake_core_');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,6 +234,13 @@ class Inflector {
|
||||||
*/
|
*/
|
||||||
protected static $_cache = array();
|
protected static $_cache = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The initial state of Inflector so reset() works.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static $_initialState = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache inflected values, and return if already available
|
* Cache inflected values, and return if already available
|
||||||
*
|
*
|
||||||
|
@ -255,6 +262,24 @@ class Inflector {
|
||||||
return self::$_cache[$type][$key];
|
return self::$_cache[$type][$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears Inflectors inflected value caches. And resets the inflection
|
||||||
|
* rules to the initial values.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function reset() {
|
||||||
|
if (empty(self::$_initialState)) {
|
||||||
|
self::$_initialState = get_class_vars('Inflector');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (self::$_initialState as $key => $val) {
|
||||||
|
if ($key != '_initialState') {
|
||||||
|
self::${$key} = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds custom inflection $rules, of either 'plural', 'singular' or 'transliteration' $type.
|
* Adds custom inflection $rules, of either 'plural', 'singular' or 'transliteration' $type.
|
||||||
*
|
*
|
||||||
|
@ -540,3 +565,6 @@ class Inflector {
|
||||||
return preg_replace(array_keys($map), array_values($map), $string);
|
return preg_replace(array_keys($map), array_values($map), $string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store the initial state
|
||||||
|
Inflector::reset();
|
|
@ -299,6 +299,17 @@ class DboPostgres extends DboSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($column) {
|
switch($column) {
|
||||||
|
case 'binary':
|
||||||
|
$data = pg_escape_bytea($data);
|
||||||
|
break;
|
||||||
|
case 'boolean':
|
||||||
|
if ($data === true || $data === 't' || $data === 'true') {
|
||||||
|
return 'TRUE';
|
||||||
|
} elseif ($data === false || $data === 'f' || $data === 'false') {
|
||||||
|
return 'FALSE';
|
||||||
|
}
|
||||||
|
return (!empty($data) ? 'TRUE' : 'FALSE');
|
||||||
|
break;
|
||||||
case 'float':
|
case 'float':
|
||||||
if (is_float($data)) {
|
if (is_float($data)) {
|
||||||
$data = sprintf('%F', $data);
|
$data = sprintf('%F', $data);
|
||||||
|
@ -312,17 +323,6 @@ class DboPostgres extends DboSource {
|
||||||
if ($data === '') {
|
if ($data === '') {
|
||||||
return $read ? 'NULL' : 'DEFAULT';
|
return $read ? 'NULL' : 'DEFAULT';
|
||||||
}
|
}
|
||||||
case 'binary':
|
|
||||||
$data = pg_escape_bytea($data);
|
|
||||||
break;
|
|
||||||
case 'boolean':
|
|
||||||
if ($data === true || $data === 't' || $data === 'true') {
|
|
||||||
return 'TRUE';
|
|
||||||
} elseif ($data === false || $data === 'f' || $data === 'false') {
|
|
||||||
return 'FALSE';
|
|
||||||
}
|
|
||||||
return (!empty($data) ? 'TRUE' : 'FALSE');
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$data = pg_escape_string($data);
|
$data = pg_escape_string($data);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -555,6 +555,9 @@ class DboSource extends DataSource {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (preg_match('/^[\w-_\s]*[\w-_]+/', $data)) {
|
||||||
|
return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote);
|
||||||
|
}
|
||||||
return $this->cacheMethod(__FUNCTION__, $cacheKey, $data);
|
return $this->cacheMethod(__FUNCTION__, $cacheKey, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1657,8 +1660,10 @@ class DboSource extends DataSource {
|
||||||
$noJoin = false;
|
$noJoin = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$conditions[$field] = $value;
|
if ($field !== $originalField) {
|
||||||
unset($conditions[$originalField]);
|
$conditions[$field] = $value;
|
||||||
|
unset($conditions[$originalField]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($noJoin === true) {
|
if ($noJoin === true) {
|
||||||
return $this->conditions($conditions);
|
return $this->conditions($conditions);
|
||||||
|
@ -1979,18 +1984,8 @@ class DboSource extends DataSource {
|
||||||
if ($comma === false) {
|
if ($comma === false) {
|
||||||
$build = explode('.', $fields[$i]);
|
$build = explode('.', $fields[$i]);
|
||||||
if (!Set::numeric($build)) {
|
if (!Set::numeric($build)) {
|
||||||
$fields[$i] = $this->name($build[0] . '.' . $build[1]);
|
$fields[$i] = $this->name(implode('.', $build));
|
||||||
}
|
}
|
||||||
$comma = String::tokenize($fields[$i]);
|
|
||||||
foreach ($comma as $string) {
|
|
||||||
if (preg_match('/^[0-9]+\.[0-9]+$/', $string)) {
|
|
||||||
$value[] = $string;
|
|
||||||
} else {
|
|
||||||
$build = explode('.', $string);
|
|
||||||
$value[] = $this->name(trim($build[0]) . '.' . trim($build[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$fields[$i] = implode(', ', $value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$fields[$i] = $prepend . $fields[$i];
|
$fields[$i] = $prepend . $fields[$i];
|
||||||
|
|
|
@ -2042,10 +2042,12 @@ class Model extends Object {
|
||||||
* find('all', array(
|
* find('all', array(
|
||||||
* 'conditions' => array('name' => 'Thomas Anderson'),
|
* 'conditions' => array('name' => 'Thomas Anderson'),
|
||||||
* 'joins' => array(
|
* 'joins' => array(
|
||||||
* 'alias' => 'Thought',
|
* array(
|
||||||
* 'table' => 'thoughts',
|
* 'alias' => 'Thought',
|
||||||
* 'type' => 'LEFT',
|
* 'table' => 'thoughts',
|
||||||
* 'conditions' => '`Thought`.`person_id` = `Person`.`id`'
|
* 'type' => 'LEFT',
|
||||||
|
* 'conditions' => '`Thought`.`person_id` = `Person`.`id`'
|
||||||
|
* )
|
||||||
* )
|
* )
|
||||||
* ));
|
* ));
|
||||||
* }}}
|
* }}}
|
||||||
|
|
|
@ -71,6 +71,16 @@ endif;
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
<?php
|
||||||
|
App::import('Core', 'Validation');
|
||||||
|
if (!Validation::alphaNumeric('cakephp')) {
|
||||||
|
echo '<p><span class="notice">';
|
||||||
|
__('PCRE has not been compiled with Unicode support.');
|
||||||
|
echo '<br/>';
|
||||||
|
__('Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
|
||||||
|
echo '</span></p>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
<?php
|
<?php
|
||||||
if (isset($filePresent)):
|
if (isset($filePresent)):
|
||||||
if (!class_exists('ConnectionManager')) {
|
if (!class_exists('ConnectionManager')) {
|
||||||
|
@ -157,4 +167,4 @@ You can also add some CSS styles for your pages at: APP/webroot/css.');
|
||||||
<ul><li><?php echo __('Recommended Software Books'); ?></li></ul></li>
|
<ul><li><?php echo __('Recommended Software Books'); ?></li></ul></li>
|
||||||
<li><a href="http://www.cafepress.com/cakefoundation"><?php echo __('CakePHP gear'); ?> </a>
|
<li><a href="http://www.cafepress.com/cakefoundation"><?php echo __('CakePHP gear'); ?> </a>
|
||||||
<ul><li><?php echo __('Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li>
|
<ul><li><?php echo __('Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -597,7 +597,7 @@ class View extends Object {
|
||||||
if ($data == null) {
|
if ($data == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->viewVars = array_merge($this->viewVars, $data);
|
$this->viewVars = $data + $this->viewVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,16 +34,13 @@ class AllShellsTest extends PHPUnit_Framework_TestSuite {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function suite() {
|
public static function suite() {
|
||||||
$suite = new PHPUnit_Framework_TestSuite('All shell classes');
|
$suite = new CakeTestSuite('All shell classes');
|
||||||
|
|
||||||
$path = CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS;
|
$path = CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS;
|
||||||
|
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'cake.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'cake.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'console_error_handler.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'console_error_handler.test.php');
|
||||||
$tasks = array('acl', 'api', 'bake', 'schema', 'shell');
|
$suite->addTestDirectory($path);
|
||||||
foreach ($tasks as $task) {
|
|
||||||
$suite->addTestFile($path . $task . '.test.php');
|
|
||||||
}
|
|
||||||
return $suite;
|
return $suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* AllBakeTasksTest file
|
* AllTasksTest file
|
||||||
*
|
*
|
||||||
* PHP 5
|
* PHP 5
|
||||||
*
|
*
|
||||||
|
@ -19,14 +19,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AllBakeTasksTest class
|
* AllTasksTest class
|
||||||
*
|
*
|
||||||
* This test group will run bake and its task's tests.
|
* This test group will run all the task tests.
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.groups
|
* @subpackage cake.tests.groups
|
||||||
*/
|
*/
|
||||||
class AllBakeTasksTest extends PHPUnit_Framework_TestSuite {
|
class AllTasksTest extends PHPUnit_Framework_TestSuite {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* suite method, defines tests for this suite.
|
* suite method, defines tests for this suite.
|
||||||
|
@ -34,15 +34,12 @@ class AllBakeTasksTest extends PHPUnit_Framework_TestSuite {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function suite() {
|
public static function suite() {
|
||||||
$suite = new PHPUnit_Framework_TestSuite('Bake and its task tests');
|
$suite = new CakeTestSuite('All Tasks tests');
|
||||||
|
|
||||||
$path = CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'tasks' . DS;
|
$path = CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'tasks' . DS;
|
||||||
|
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'bake.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'bake.test.php');
|
||||||
$tasks = array('controller', 'model', 'view', 'fixture', 'test', 'db_config', 'project', 'plugin');
|
$suite->addTestDirectory($path);
|
||||||
foreach ($tasks as $task) {
|
|
||||||
$suite->addTestFile($path . $task . '.test.php');
|
|
||||||
}
|
|
||||||
return $suite;
|
return $suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -165,6 +165,7 @@ class ShellDispatcherTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'plugins' => array(
|
'plugins' => array(
|
||||||
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
|
||||||
|
@ -176,15 +177,6 @@ class ShellDispatcherTest extends CakeTestCase {
|
||||||
), true);
|
), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* tearDown method
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function tearDown() {
|
|
||||||
App::build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testParseParams method
|
* testParseParams method
|
||||||
*
|
*
|
||||||
|
|
|
@ -51,20 +51,19 @@ class AclShellTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
|
public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setup method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
$this->_aclDb = Configure::read('Acl.database');
|
parent::setUp();
|
||||||
$this->_aclClass = Configure::read('Acl.classname');
|
|
||||||
|
|
||||||
Configure::write('Acl.database', 'test_suite');
|
Configure::write('Acl.database', 'test');
|
||||||
Configure::write('Acl.classname', 'DbAcl');
|
Configure::write('Acl.classname', 'DbAcl');
|
||||||
|
|
||||||
$this->Dispatcher = $this->getMock(
|
$this->Dispatcher = $this->getMock(
|
||||||
'ShellDispatcher',
|
'ShellDispatcher',
|
||||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch')
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch', 'clear')
|
||||||
);
|
);
|
||||||
$this->Task = $this->getMock(
|
$this->Task = $this->getMock(
|
||||||
'AclShell',
|
'AclShell',
|
||||||
|
@ -74,18 +73,7 @@ class AclShellTest extends CakeTestCase {
|
||||||
$collection = new ComponentCollection();
|
$collection = new ComponentCollection();
|
||||||
$this->Task->Acl = new AclComponent($collection);
|
$this->Task->Acl = new AclComponent($collection);
|
||||||
|
|
||||||
$this->Task->params['datasource'] = 'test_suite';
|
$this->Task->params['datasource'] = 'test';
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* endTest method
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function endTest() {
|
|
||||||
ClassRegistry::flush();
|
|
||||||
Configure::write('Acl.database', $this->_aclDb);
|
|
||||||
Configure::write('Acl.classname', $this->_aclClass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,14 +43,15 @@ if (!class_exists('ApiShell')) {
|
||||||
class ApiShellTest extends CakeTestCase {
|
class ApiShellTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dispatcher = $this->getMock(
|
$this->Dispatcher = $this->getMock(
|
||||||
'ShellDispatcher',
|
'ShellDispatcher',
|
||||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch')
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch', 'clear')
|
||||||
);
|
);
|
||||||
$this->Shell = $this->getMock(
|
$this->Shell = $this->getMock(
|
||||||
'ApiShell',
|
'ApiShell',
|
||||||
|
@ -59,15 +60,6 @@ class ApiShellTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* tearDown method
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function endTest() {
|
|
||||||
ClassRegistry::flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that method names are detected properly including those with no arguments.
|
* Test that method names are detected properly including those with no arguments.
|
||||||
*
|
*
|
||||||
|
|
|
@ -54,14 +54,15 @@ class BakeShellTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.user');
|
public $fixtures = array('core.user');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* start test
|
* setup test
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dispatcher = $this->getMock(
|
$this->Dispatcher = $this->getMock(
|
||||||
'ShellDispatcher',
|
'ShellDispatcher',
|
||||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
|
||||||
);
|
);
|
||||||
$this->Shell = $this->getMock(
|
$this->Shell = $this->getMock(
|
||||||
'BakeShell',
|
'BakeShell',
|
||||||
|
@ -72,11 +73,12 @@ class BakeShellTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* teardown method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Dispatch, $this->Shell);
|
unset($this->Dispatch, $this->Shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +98,7 @@ class BakeShellTest extends CakeTestCase {
|
||||||
$this->Shell->View = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
|
$this->Shell->View = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
|
||||||
$this->Shell->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher));
|
$this->Shell->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher));
|
||||||
|
|
||||||
$this->Shell->DbConfig->expects($this->once())->method('getConfig')->will($this->returnValue('test_suite'));
|
$this->Shell->DbConfig->expects($this->once())->method('getConfig')->will($this->returnValue('test'));
|
||||||
|
|
||||||
$this->Shell->Model->expects($this->never())->method('getName');
|
$this->Shell->Model->expects($this->never())->method('getName');
|
||||||
$this->Shell->Model->expects($this->once())->method('bake')->will($this->returnValue(true));
|
$this->Shell->Model->expects($this->once())->method('bake')->will($this->returnValue(true));
|
||||||
|
|
|
@ -54,10 +54,10 @@ class SchemaShellTestSchema extends CakeSchema {
|
||||||
/**
|
/**
|
||||||
* connection property
|
* connection property
|
||||||
*
|
*
|
||||||
* @var string 'test_suite'
|
* @var string 'test'
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public $connection = 'test_suite';
|
public $connection = 'test';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* comments property
|
* comments property
|
||||||
|
@ -115,14 +115,14 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setup method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setup() {
|
||||||
$this->Dispatcher = $this->getMock(
|
$this->Dispatcher = $this->getMock(
|
||||||
'ShellDispatcher',
|
'ShellDispatcher',
|
||||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
|
||||||
);
|
);
|
||||||
$this->Shell = $this->getMock(
|
$this->Shell = $this->getMock(
|
||||||
'SchemaShell',
|
'SchemaShell',
|
||||||
|
@ -136,8 +136,13 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function teardown() {
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
|
if (!empty($this->file) && $this->file instanceof File) {
|
||||||
|
$this->file->delete();
|
||||||
|
unset($this->file);
|
||||||
|
}
|
||||||
|
App::build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,13 +170,13 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
unset($this->Shell->Schema);
|
unset($this->Shell->Schema);
|
||||||
$this->Shell->params = array(
|
$this->Shell->params = array(
|
||||||
'file' => 'other_file.php',
|
'file' => 'other_file.php',
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'path' => '/test/path'
|
'path' => '/test/path'
|
||||||
);
|
);
|
||||||
$this->Shell->startup();
|
$this->Shell->startup();
|
||||||
$this->assertEqual(strtolower($this->Shell->Schema->name), strtolower(APP_DIR));
|
$this->assertEqual(strtolower($this->Shell->Schema->name), strtolower(APP_DIR));
|
||||||
$this->assertEqual($this->Shell->Schema->file, 'other_file.php');
|
$this->assertEqual($this->Shell->Schema->file, 'other_file.php');
|
||||||
$this->assertEqual($this->Shell->Schema->connection, 'test_suite');
|
$this->assertEqual($this->Shell->Schema->connection, 'test');
|
||||||
$this->assertEqual($this->Shell->Schema->path, '/test/path');
|
$this->assertEqual($this->Shell->Schema->path, '/test/path');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,8 +231,8 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
$this->Shell->startup();
|
$this->Shell->startup();
|
||||||
$this->Shell->dump();
|
$this->Shell->dump();
|
||||||
|
|
||||||
$sql =& new File(TMP . 'tests' . DS . 'i18n.sql');
|
$this->file =& new File(TMP . 'tests' . DS . 'i18n.sql');
|
||||||
$contents = $sql->read();
|
$contents = $this->file->read();
|
||||||
$this->assertPattern('/DROP TABLE/', $contents);
|
$this->assertPattern('/DROP TABLE/', $contents);
|
||||||
$this->assertPattern('/CREATE TABLE `i18n`/', $contents);
|
$this->assertPattern('/CREATE TABLE `i18n`/', $contents);
|
||||||
$this->assertPattern('/id/', $contents);
|
$this->assertPattern('/id/', $contents);
|
||||||
|
@ -236,8 +241,6 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
$this->assertPattern('/locale/', $contents);
|
$this->assertPattern('/locale/', $contents);
|
||||||
$this->assertPattern('/foreign_key/', $contents);
|
$this->assertPattern('/foreign_key/', $contents);
|
||||||
$this->assertPattern('/content/', $contents);
|
$this->assertPattern('/content/', $contents);
|
||||||
|
|
||||||
$sql->delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,21 +254,21 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
$this->Shell->args = array('TestPlugin.TestPluginApp');
|
$this->Shell->args = array('TestPlugin.TestPluginApp');
|
||||||
$this->Shell->params = array(
|
$this->Shell->params = array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'write' => TMP . 'tests' . DS . 'dump_test.sql'
|
'write' => TMP . 'tests' . DS . 'dump_test.sql'
|
||||||
);
|
);
|
||||||
$this->Shell->startup();
|
$this->Shell->startup();
|
||||||
$this->Shell->expects($this->once())->method('_stop');
|
$this->Shell->expects($this->once())->method('_stop');
|
||||||
$this->Shell->dump();
|
$this->Shell->dump();
|
||||||
|
|
||||||
$file =& new File(TMP . 'tests' . DS . 'dump_test.sql');
|
$this->file =& new File(TMP . 'tests' . DS . 'dump_test.sql');
|
||||||
$contents = $file->read();
|
$contents = $this->file->read();
|
||||||
|
|
||||||
$this->assertPattern('/CREATE TABLE `acos`/', $contents);
|
$this->assertPattern('/CREATE TABLE `acos`/', $contents);
|
||||||
$this->assertPattern('/id/', $contents);
|
$this->assertPattern('/id/', $contents);
|
||||||
$this->assertPattern('/model/', $contents);
|
$this->assertPattern('/model/', $contents);
|
||||||
|
|
||||||
$file->delete();
|
$this->file->delete();
|
||||||
App::build();
|
App::build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,17 +347,19 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
public function testGenerateWithPlugins() {
|
public function testGenerateWithPlugins() {
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
));
|
), true);
|
||||||
|
App::objects('plugin', null, false);
|
||||||
|
|
||||||
$this->Shell->params = array(
|
$this->Shell->params = array(
|
||||||
'plugin' => 'TestPlugin',
|
'plugin' => 'TestPlugin',
|
||||||
'connection' => 'test_suite'
|
'connection' => 'test'
|
||||||
);
|
);
|
||||||
$this->Shell->startup();
|
$this->Shell->startup();
|
||||||
$this->Shell->Schema->path = TMP . 'tests' . DS;
|
$this->Shell->Schema->path = TMP . 'tests' . DS;
|
||||||
|
|
||||||
$this->Shell->generate();
|
$this->Shell->generate();
|
||||||
$file = new File(TMP . 'tests' . DS . 'schema.php');
|
$this->file = new File(TMP . 'tests' . DS . 'schema.php');
|
||||||
$contents = $file->read();
|
$contents = $this->file->read();
|
||||||
|
|
||||||
$this->assertPattern('/class TestPluginSchema/', $contents);
|
$this->assertPattern('/class TestPluginSchema/', $contents);
|
||||||
$this->assertPattern('/var \$posts/', $contents);
|
$this->assertPattern('/var \$posts/', $contents);
|
||||||
|
@ -363,9 +368,6 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
$this->assertPattern('/var \$test_plugin_comments/', $contents);
|
$this->assertPattern('/var \$test_plugin_comments/', $contents);
|
||||||
$this->assertNoPattern('/var \$users/', $contents);
|
$this->assertNoPattern('/var \$users/', $contents);
|
||||||
$this->assertNoPattern('/var \$articles/', $contents);
|
$this->assertNoPattern('/var \$articles/', $contents);
|
||||||
|
|
||||||
$file->delete();
|
|
||||||
App::build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -375,7 +377,7 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testCreateNoArgs() {
|
public function testCreateNoArgs() {
|
||||||
$this->Shell->params = array(
|
$this->Shell->params = array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'path' => APP . 'config' . DS . 'sql'
|
'path' => APP . 'config' . DS . 'sql'
|
||||||
);
|
);
|
||||||
$this->Shell->args = array('i18n');
|
$this->Shell->args = array('i18n');
|
||||||
|
@ -383,7 +385,7 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
|
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
|
||||||
$this->Shell->create();
|
$this->Shell->create();
|
||||||
|
|
||||||
$db = ConnectionManager::getDataSource('test_suite');
|
$db = ConnectionManager::getDataSource('test');
|
||||||
$sources = $db->listSources();
|
$sources = $db->listSources();
|
||||||
$this->assertTrue(in_array($db->config['prefix'] . 'i18n', $sources));
|
$this->assertTrue(in_array($db->config['prefix'] . 'i18n', $sources));
|
||||||
|
|
||||||
|
@ -397,8 +399,13 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testCreateWithTableArgs() {
|
public function testCreateWithTableArgs() {
|
||||||
|
$db = ConnectionManager::getDataSource('test');
|
||||||
|
$sources = $db->listSources();
|
||||||
|
if (in_array('acos', $sources)) {
|
||||||
|
$this->markTestSkipped('acos table already exists, cannot try to create it again.');
|
||||||
|
}
|
||||||
$this->Shell->params = array(
|
$this->Shell->params = array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'name' => 'DbAcl',
|
'name' => 'DbAcl',
|
||||||
'path' => APP . 'config' . DS . 'schema'
|
'path' => APP . 'config' . DS . 'schema'
|
||||||
);
|
);
|
||||||
|
@ -407,13 +414,11 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
|
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
|
||||||
$this->Shell->create();
|
$this->Shell->create();
|
||||||
|
|
||||||
$db =& ConnectionManager::getDataSource('test');
|
$db = ConnectionManager::getDataSource('test');
|
||||||
$sources = $db->listSources();
|
$sources = $db->listSources();
|
||||||
$this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources));
|
$this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources), 'acos should be present.');
|
||||||
$this->assertFalse(in_array($db->config['prefix'] . 'aros', $sources));
|
$this->assertFalse(in_array($db->config['prefix'] . 'aros', $sources), 'aros should not be found.');
|
||||||
$this->assertFalse(in_array('aros_acos', $sources));
|
$this->assertFalse(in_array('aros_acos', $sources), 'aros_acos should not be found.');
|
||||||
|
|
||||||
$db->execute('DROP TABLE ' . $db->config['prefix'] . 'acos');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -422,19 +427,23 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testUpdateWithTable() {
|
public function testUpdateWithTable() {
|
||||||
|
$this->Shell = $this->getMock(
|
||||||
|
'SchemaShell',
|
||||||
|
array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '__run'),
|
||||||
|
array(&$this->Dispatcher)
|
||||||
|
);
|
||||||
|
|
||||||
$this->Shell->params = array(
|
$this->Shell->params = array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'f' => true
|
'f' => true
|
||||||
);
|
);
|
||||||
$this->Shell->args = array('SchemaShellTest', 'articles');
|
$this->Shell->args = array('SchemaShellTest', 'articles');
|
||||||
$this->Shell->startup();
|
$this->Shell->startup();
|
||||||
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
|
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
|
||||||
|
$this->Shell->expects($this->once())->method('__run')
|
||||||
|
->with($this->arrayHasKey('articles'), 'update', $this->isInstanceOf('CakeSchema'));
|
||||||
|
|
||||||
$this->Shell->update();
|
$this->Shell->update();
|
||||||
|
|
||||||
$article =& new Model(array('name' => 'Article', 'ds' => 'test_suite'));
|
|
||||||
$fields = $article->schema();
|
|
||||||
$this->assertTrue(isset($fields['summary']));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -448,13 +457,11 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
$this->Shell->params = array(
|
$this->Shell->params = array(
|
||||||
'plugin' => 'TestPlugin',
|
'plugin' => 'TestPlugin',
|
||||||
'connection' => 'test_suite'
|
'connection' => 'test'
|
||||||
);
|
);
|
||||||
$this->Shell->startup();
|
$this->Shell->startup();
|
||||||
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'config' . DS . 'schema';
|
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'config' . DS . 'schema';
|
||||||
$this->assertEqual($this->Shell->Schema->path, $expected);
|
$this->assertEqual($this->Shell->Schema->path, $expected);
|
||||||
|
|
||||||
App::build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -467,18 +474,15 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
));
|
));
|
||||||
$this->Shell->params = array(
|
$this->Shell->params = array(
|
||||||
'connection' => 'test_suite'
|
'connection' => 'test'
|
||||||
);
|
);
|
||||||
$this->Shell->args = array('TestPlugin.TestPluginApp');
|
$this->Shell->args = array('TestPlugin.TestPluginApp');
|
||||||
$this->Shell->startup();
|
$this->Shell->startup();
|
||||||
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
|
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
|
||||||
$this->Shell->create();
|
$this->Shell->create();
|
||||||
|
|
||||||
$db =& ConnectionManager::getDataSource('test_suite');
|
$db =& ConnectionManager::getDataSource('test');
|
||||||
$sources = $db->listSources();
|
$sources = $db->listSources();
|
||||||
$this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources));
|
$this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources));
|
||||||
|
|
||||||
$db->execute('DROP TABLE ' . $db->config['prefix'] . 'acos');
|
|
||||||
App::build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ class ShellTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Dispatcher = $this->getMock(
|
$this->Dispatcher = $this->getMock(
|
||||||
'ShellDispatcher',
|
'ShellDispatcher',
|
||||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
|
||||||
);
|
);
|
||||||
$this->Shell =& new TestShell($this->Dispatcher);
|
$this->Shell =& new TestShell($this->Dispatcher);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,13 +72,13 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.bake_article', 'core.bake_articles_bake_tag', 'core.bake_comment', 'core.bake_tag');
|
public $fixtures = array('core.bake_article', 'core.bake_articles_bake_tag', 'core.bake_comment', 'core.bake_tag');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('ControllerTask',
|
$this->Task = $this->getMock('ControllerTask',
|
||||||
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'),
|
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'),
|
||||||
|
@ -101,11 +101,11 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* teardown method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function teardown() {
|
||||||
unset($this->Task, $this->Dispatcher);
|
unset($this->Task, $this->Dispatcher);
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
}
|
}
|
||||||
|
@ -116,12 +116,12 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testListAll() {
|
public function testListAll() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->interactive = true;
|
$this->Task->interactive = true;
|
||||||
$this->Task->expects($this->at(1))->method('out')->with('1. BakeArticles');
|
$this->Task->expects($this->at(1))->method('out')->with('1. BakeArticles');
|
||||||
$this->Task->expects($this->at(2))->method('out')->with('2. BakeArticlesBakeTags');
|
$this->Task->expects($this->at(2))->method('out')->with('2. BakeArticlesBakeTags');
|
||||||
|
@ -129,7 +129,7 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
$this->Task->expects($this->at(4))->method('out')->with('4. BakeTags');
|
$this->Task->expects($this->at(4))->method('out')->with('4. BakeTags');
|
||||||
|
|
||||||
$expected = array('BakeArticles', 'BakeArticlesBakeTags', 'BakeComments', 'BakeTags');
|
$expected = array('BakeArticles', 'BakeArticlesBakeTags', 'BakeComments', 'BakeTags');
|
||||||
$result = $this->Task->listAll('test_suite');
|
$result = $this->Task->listAll('test');
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$this->Task->interactive = false;
|
$this->Task->interactive = false;
|
||||||
|
@ -145,19 +145,20 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGetNameValidIndex() {
|
public function testGetNameValidIndex() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
$this->Task->interactive = true;
|
$this->Task->interactive = true;
|
||||||
$this->Task->expects($this->at(5))->method('in')->will($this->returnValue(3));
|
$this->Task->expects($this->any())->method('in')->will(
|
||||||
$this->Task->expects($this->at(7))->method('in')->will($this->returnValue(1));
|
$this->onConsecutiveCalls(3, 1)
|
||||||
|
);
|
||||||
|
|
||||||
$result = $this->Task->getName('test_suite');
|
$result = $this->Task->getName('test');
|
||||||
$expected = 'BakeComments';
|
$expected = 'BakeComments';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->Task->getName('test_suite');
|
$result = $this->Task->getName('test');
|
||||||
$expected = 'BakeArticles';
|
$expected = 'BakeArticles';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +176,7 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
$this->Task->expects($this->once())->method('err');
|
$this->Task->expects($this->once())->method('err');
|
||||||
$this->Task->expects($this->once())->method('_stop');
|
$this->Task->expects($this->once())->method('_stop');
|
||||||
|
|
||||||
$this->Task->getName('test_suite');
|
$this->Task->getName('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,7 +418,7 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testBakeTest() {
|
public function testBakeTest() {
|
||||||
$this->Task->plugin = 'ControllerTest';
|
$this->Task->plugin = 'ControllerTest';
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->interactive = false;
|
$this->Task->interactive = false;
|
||||||
|
|
||||||
$this->Task->Test->expects($this->once())->method('bake')->with('Controller', 'BakeArticles');
|
$this->Task->Test->expects($this->once())->method('bake')->with('Controller', 'BakeArticles');
|
||||||
|
@ -434,12 +435,12 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testInteractive() {
|
public function testInteractive() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
|
|
||||||
$this->Task->expects($this->any())->method('in')
|
$this->Task->expects($this->any())->method('in')
|
||||||
|
@ -469,12 +470,12 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testInteractiveAdminMethodsNotInteractive() {
|
function testInteractiveAdminMethodsNotInteractive() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->interactive = true;
|
$this->Task->interactive = true;
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
|
|
||||||
|
@ -511,12 +512,14 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteIntoAll() {
|
public function testExecuteIntoAll() {
|
||||||
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
|
$count = count($this->Task->listAll('test'));
|
||||||
'Execute into all could not be run as an Article, Tag or Comment model was already loaded. %s');
|
if ($count != count($this->fixtures)) {
|
||||||
if ($skip) {
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->Task->connection = 'test_suite';
|
if (!defined('ARTICLE_MODEL_CREATED')) {
|
||||||
|
$this->markTestSkipped('Execute into all could not be run as an Article, Tag or Comment model was already loaded.');
|
||||||
|
}
|
||||||
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('all');
|
$this->Task->args = array('all');
|
||||||
|
|
||||||
|
@ -538,12 +541,10 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithController() {
|
public function testExecuteWithController() {
|
||||||
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
|
if (!defined('ARTICLE_MODEL_CREATED')) {
|
||||||
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
|
$this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined');
|
||||||
if ($skip) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('BakeArticles');
|
$this->Task->args = array('BakeArticles');
|
||||||
|
|
||||||
|
@ -574,12 +575,10 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithControllerNameVariations($name) {
|
public function testExecuteWithControllerNameVariations($name) {
|
||||||
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
|
if (!defined('ARTICLE_MODEL_CREATED')) {
|
||||||
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
|
$this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined.');
|
||||||
if ($skip) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array($name);
|
$this->Task->args = array($name);
|
||||||
|
|
||||||
|
@ -596,12 +595,10 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithPublicParam() {
|
public function testExecuteWithPublicParam() {
|
||||||
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
|
if (!defined('ARTICLE_MODEL_CREATED')) {
|
||||||
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
|
$this->markTestSkipped('Execute with public param requires no Article, Tag or Comment model to be defined.');
|
||||||
if ($skip) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('BakeArticles', 'public');
|
$this->Task->args = array('BakeArticles', 'public');
|
||||||
|
|
||||||
|
@ -619,13 +616,11 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithControllerAndBoth() {
|
public function testExecuteWithControllerAndBoth() {
|
||||||
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
|
if (!defined('ARTICLE_MODEL_CREATED')) {
|
||||||
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
|
$this->markTestSkipped('Execute with controller and both requires no Article, Tag or Comment model to be defined.');
|
||||||
if ($skip) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_'));
|
$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_'));
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('BakeArticles', 'public', 'admin');
|
$this->Task->args = array('BakeArticles', 'public', 'admin');
|
||||||
|
|
||||||
|
@ -642,13 +637,11 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithControllerAndAdmin() {
|
public function testExecuteWithControllerAndAdmin() {
|
||||||
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
|
if (!defined('ARTICLE_MODEL_CREATED')) {
|
||||||
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
|
$this->markTestSkipped('Execute with controller and admin requires no Article, Tag or Comment model to be defined.');
|
||||||
if ($skip) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_'));
|
$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_'));
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('BakeArticles', 'admin');
|
$this->Task->args = array('BakeArticles', 'admin');
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,14 @@ class TEST_DATABASE_CONFIG {
|
||||||
class DbConfigTaskTest extends CakeTestCase {
|
class DbConfigTaskTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setup method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('DbConfigTask',
|
$this->Task = $this->getMock('DbConfigTask',
|
||||||
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest', '_verify'),
|
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest', '_verify'),
|
||||||
|
@ -87,9 +88,9 @@ class DbConfigTaskTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Task, $this->Dispatcher);
|
unset($this->Task, $this->Dispatcher);
|
||||||
ClassRegistry::flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ class ExtractTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task =& new ExtractTask($this->Dispatcher);
|
$this->Task =& new ExtractTask($this->Dispatcher);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,13 +50,14 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.article', 'core.comment', 'core.datatype', 'core.binary_test');
|
public $fixtures = array('core.article', 'core.comment', 'core.datatype', 'core.binary_test');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('FixtureTask',
|
$this->Task = $this->getMock('FixtureTask',
|
||||||
array('in', 'err', 'createFile', '_stop'),
|
array('in', 'err', 'createFile', '_stop'),
|
||||||
|
@ -72,13 +73,13 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* tearDown method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Task, $this->Dispatcher);
|
unset($this->Task, $this->Dispatcher);
|
||||||
ClassRegistry::flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,7 +148,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
$this->Task->expects($this->at(0))->method('in')
|
$this->Task->expects($this->at(0))->method('in')
|
||||||
->will($this->returnValue('WHERE 1=1 LIMIT 10'));
|
->will($this->returnValue('WHERE 1=1 LIMIT 10'));
|
||||||
|
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
|
|
||||||
$result = $this->Task->bake('Article', false, array(
|
$result = $this->Task->bake('Article', false, array(
|
||||||
|
@ -168,7 +169,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithNamedModel() {
|
public function testExecuteWithNamedModel() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('article');
|
$this->Task->args = array('article');
|
||||||
$filename = '/my/path/article_fixture.php';
|
$filename = '/my/path/article_fixture.php';
|
||||||
|
@ -197,7 +198,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithNamedModelVariations($modelName) {
|
public function testExecuteWithNamedModelVariations($modelName) {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
|
|
||||||
$this->Task->args = array($modelName);
|
$this->Task->args = array($modelName);
|
||||||
|
@ -214,7 +215,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteIntoAll() {
|
public function testExecuteIntoAll() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('all');
|
$this->Task->args = array('all');
|
||||||
$this->Task->Model->expects($this->any())->method('listAll')
|
$this->Task->Model->expects($this->any())->method('listAll')
|
||||||
|
@ -237,7 +238,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAllWithCountAndRecordsFlags() {
|
public function testAllWithCountAndRecordsFlags() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('all');
|
$this->Task->args = array('all');
|
||||||
$this->Task->params = array('count' => 10, 'records' => true);
|
$this->Task->params = array('count' => 10, 'records' => true);
|
||||||
|
@ -263,7 +264,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteInteractive() {
|
public function testExecuteInteractive() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
|
|
||||||
$this->Task->expects($this->any())->method('in')->will($this->returnValue('y'));
|
$this->Task->expects($this->any())->method('in')->will($this->returnValue('y'));
|
||||||
|
@ -285,7 +286,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testBake() {
|
public function testBake() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
|
|
||||||
$result = $this->Task->bake('Article');
|
$result = $this->Task->bake('Article');
|
||||||
|
@ -320,7 +321,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRecordGenerationForBinaryAndFloat() {
|
public function testRecordGenerationForBinaryAndFloat() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
|
|
||||||
$result = $this->Task->bake('Article', 'datatypes');
|
$result = $this->Task->bake('Article', 'datatypes');
|
||||||
|
@ -336,7 +337,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGenerateFixtureFile() {
|
public function testGenerateFixtureFile() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$filename = '/my/path/article_fixture.php';
|
$filename = '/my/path/article_fixture.php';
|
||||||
|
|
||||||
|
@ -357,7 +358,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGeneratePluginFixtureFile() {
|
public function testGeneratePluginFixtureFile() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->plugin = 'TestFixture';
|
$this->Task->plugin = 'TestFixture';
|
||||||
$filename = APP . 'plugins' . DS . 'test_fixture' . DS . 'tests' . DS . 'fixtures' . DS . 'article_fixture.php';
|
$filename = APP . 'plugins' . DS . 'test_fixture' . DS . 'tests' . DS . 'fixtures' . DS . 'article_fixture.php';
|
||||||
|
|
|
@ -53,13 +53,14 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag', 'core.category_thread');
|
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag', 'core.category_thread');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* starTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('ModelTask',
|
$this->Task = $this->getMock('ModelTask',
|
||||||
array('in', 'err', 'createFile', '_stop', '_checkUnitTest'),
|
array('in', 'err', 'createFile', '_stop', '_checkUnitTest'),
|
||||||
|
@ -97,13 +98,13 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* teardown method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Task, $this->Dispatcher);
|
unset($this->Task, $this->Dispatcher);
|
||||||
ClassRegistry::flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +113,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testListAll() {
|
public function testListAll() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
@ -130,11 +131,11 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$this->Task->expects($this->at(10))->method('out')->with('4. Comment');
|
$this->Task->expects($this->at(10))->method('out')->with('4. Comment');
|
||||||
$this->Task->expects($this->at(11))->method('out')->with('5. Tag');
|
$this->Task->expects($this->at(11))->method('out')->with('5. Tag');
|
||||||
|
|
||||||
$result = $this->Task->listAll('test_suite');
|
$result = $this->Task->listAll('test');
|
||||||
$expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags');
|
$expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags');
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$result = $this->Task->listAll();
|
$result = $this->Task->listAll();
|
||||||
$expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags');
|
$expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags');
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
@ -148,7 +149,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
public function testGetNameQuit() {
|
public function testGetNameQuit() {
|
||||||
$this->Task->expects($this->once())->method('in')->will($this->returnValue('q'));
|
$this->Task->expects($this->once())->method('in')->will($this->returnValue('q'));
|
||||||
$this->Task->expects($this->once())->method('_stop');
|
$this->Task->expects($this->once())->method('_stop');
|
||||||
$this->Task->getName('test_suite');
|
$this->Task->getName('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,18 +158,18 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testGetNameValidOption() {
|
function testGetNameValidOption() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls(1, 4));
|
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls(1, 4));
|
||||||
|
|
||||||
$result = $this->Task->getName('test_suite');
|
$result = $this->Task->getName('test');
|
||||||
$expected = 'Article';
|
$expected = 'Article';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$result = $this->Task->getName('test_suite');
|
$result = $this->Task->getName('test');
|
||||||
$expected = 'Comment';
|
$expected = 'Comment';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +183,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls(99, 1));
|
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls(99, 1));
|
||||||
$this->Task->expects($this->once())->method('err');
|
$this->Task->expects($this->once())->method('err');
|
||||||
|
|
||||||
$result = $this->Task->getName('test_suite');
|
$result = $this->Task->getName('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,7 +193,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testGetTableName() {
|
public function testGetTableName() {
|
||||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
|
||||||
$result = $this->Task->getTable('Article', 'test_suite');
|
$result = $this->Task->getTable('Article', 'test');
|
||||||
$expected = 'articles';
|
$expected = 'articles';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +205,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testGetTableNameCustom() {
|
function testGetTableNameCustom() {
|
||||||
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls('n', 'my_table'));
|
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls('n', 'my_table'));
|
||||||
$result = $this->Task->getTable('Article', 'test_suite');
|
$result = $this->Task->getTable('Article', 'test');
|
||||||
$expected = 'my_table';
|
$expected = 'my_table';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
@ -421,7 +422,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testBelongsToGeneration() {
|
public function testBelongsToGeneration() {
|
||||||
$model = new Model(array('ds' => 'test_suite', 'name' => 'Comment'));
|
$model = new Model(array('ds' => 'test', 'name' => 'Comment'));
|
||||||
$result = $this->Task->findBelongsTo($model, array());
|
$result = $this->Task->findBelongsTo($model, array());
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'belongsTo' => array(
|
'belongsTo' => array(
|
||||||
|
@ -439,7 +440,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread'));
|
$model = new Model(array('ds' => 'test', 'name' => 'CategoryThread'));
|
||||||
$result = $this->Task->findBelongsTo($model, array());
|
$result = $this->Task->findBelongsTo($model, array());
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'belongsTo' => array(
|
'belongsTo' => array(
|
||||||
|
@ -459,8 +460,8 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testHasManyHasOneGeneration() {
|
public function testHasManyHasOneGeneration() {
|
||||||
$model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
|
$model = new Model(array('ds' => 'test', 'name' => 'Article'));
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->listAll();
|
$this->Task->listAll();
|
||||||
$result = $this->Task->findHasOneAndMany($model, array());
|
$result = $this->Task->findHasOneAndMany($model, array());
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
@ -481,7 +482,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread'));
|
$model = new Model(array('ds' => 'test', 'name' => 'CategoryThread'));
|
||||||
$result = $this->Task->findHasOneAndMany($model, array());
|
$result = $this->Task->findHasOneAndMany($model, array());
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'hasOne' => array(
|
'hasOne' => array(
|
||||||
|
@ -508,13 +509,13 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testHasAndBelongsToManyGeneration() {
|
public function testHasAndBelongsToManyGeneration() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
|
$model = new Model(array('ds' => 'test', 'name' => 'Article'));
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->listAll();
|
$this->Task->listAll();
|
||||||
$result = $this->Task->findHasAndBelongsToMany($model, array());
|
$result = $this->Task->findHasAndBelongsToMany($model, array());
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
@ -537,9 +538,9 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testDoAssociationsNonInteractive() {
|
public function testDoAssociationsNonInteractive() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->interactive = false;
|
$this->Task->interactive = false;
|
||||||
$model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
|
$model = new Model(array('ds' => 'test', 'name' => 'Article'));
|
||||||
$result = $this->Task->doAssociations($model);
|
$result = $this->Task->doAssociations($model);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'hasMany' => array(
|
'hasMany' => array(
|
||||||
|
@ -623,7 +624,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread'));
|
$model = new Model(array('ds' => 'test', 'name' => 'CategoryThread'));
|
||||||
|
|
||||||
$this->Task->expects($this->any())->method('in')
|
$this->Task->expects($this->any())->method('in')
|
||||||
->will($this->onConsecutiveCalls('n', 'y', 'n', 'n', 'n'));
|
->will($this->onConsecutiveCalls('n', 'y', 'n', 'n', 'n'));
|
||||||
|
@ -774,7 +775,7 @@ STRINGEND;
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithNamedModel() {
|
public function testExecuteWithNamedModel() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('article');
|
$this->Task->args = array('article');
|
||||||
$filename = '/my/path/article.php';
|
$filename = '/my/path/article.php';
|
||||||
|
@ -807,7 +808,7 @@ STRINGEND;
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithNamedModelVariations($name) {
|
public function testExecuteWithNamedModelVariations($name) {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
|
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
|
||||||
|
|
||||||
|
@ -825,7 +826,7 @@ STRINGEND;
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithNamedModelHasManyCreated() {
|
public function testExecuteWithNamedModelHasManyCreated() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('article');
|
$this->Task->args = array('article');
|
||||||
$filename = '/my/path/article.php';
|
$filename = '/my/path/article.php';
|
||||||
|
@ -843,12 +844,12 @@ STRINGEND;
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteIntoAll() {
|
public function testExecuteIntoAll() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('all');
|
$this->Task->args = array('all');
|
||||||
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
|
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
|
||||||
|
@ -888,12 +889,12 @@ STRINGEND;
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testSkipTablesAndAll() {
|
function testSkipTablesAndAll() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('all');
|
$this->Task->args = array('all');
|
||||||
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
|
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
|
||||||
|
@ -927,12 +928,12 @@ STRINGEND;
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteIntoInteractive() {
|
public function testExecuteIntoInteractive() {
|
||||||
$count = count($this->Task->listAll('test_suite'));
|
$count = count($this->Task->listAll('test'));
|
||||||
if ($count != count($this->fixtures)) {
|
if ($count != count($this->fixtures)) {
|
||||||
$this->markTestSkipped('Additional tables detected.');
|
$this->markTestSkipped('Additional tables detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->interactive = true;
|
$this->Task->interactive = true;
|
||||||
|
|
||||||
|
@ -969,7 +970,7 @@ STRINGEND;
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithNonExistantTableName() {
|
public function testExecuteWithNonExistantTableName() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
|
|
||||||
$this->Task->expects($this->once())->method('_stop');
|
$this->Task->expects($this->once())->method('_stop');
|
||||||
|
|
|
@ -44,53 +44,36 @@ require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php';
|
||||||
*/
|
*/
|
||||||
class PluginTaskTest extends CakeTestCase {
|
class PluginTaskTest extends CakeTestCase {
|
||||||
|
|
||||||
public static $_paths = array();
|
|
||||||
|
|
||||||
public static $_testPath = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setup method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('PluginTask',
|
$this->Task = $this->getMock('PluginTask',
|
||||||
array('in', 'err', 'createFile', '_stop'),
|
array('in', 'err', 'createFile', '_stop'),
|
||||||
array(&$this->Dispatcher)
|
array(&$this->Dispatcher)
|
||||||
);
|
);
|
||||||
$this->Task->path = TMP . 'tests' . DS;
|
$this->Task->path = TMP . 'tests' . DS;
|
||||||
}
|
|
||||||
|
$this->_paths = $paths = App::path('plugins');
|
||||||
/**
|
$this->_testPath = array_push($paths, TMP . 'tests' . DS);
|
||||||
* startCase methods
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function setUpBeforeClass() {
|
|
||||||
self::$_paths = $paths = App::path('plugins');
|
|
||||||
self::$_testPath = array_push($paths, TMP . 'tests' . DS);
|
|
||||||
App::build(array('plugins' => $paths));
|
App::build(array('plugins' => $paths));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endCase
|
* teardown
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function tearDownAfterClass() {
|
public function tearDown() {
|
||||||
App::build(array('plugins' => self::$_paths));
|
parent::tearDown();
|
||||||
}
|
App::build(array('plugins' => $this->_paths));
|
||||||
|
|
||||||
/**
|
|
||||||
* endTest method
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function endTest() {
|
|
||||||
ClassRegistry::flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +82,7 @@ class PluginTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testBakeFoldersAndFiles() {
|
public function testBakeFoldersAndFiles() {
|
||||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue(self::$_testPath));
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
|
||||||
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
|
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
|
||||||
|
|
||||||
$path = $this->Task->path . 'bake_test_plugin';
|
$path = $this->Task->path . 'bake_test_plugin';
|
||||||
|
@ -219,7 +202,7 @@ class PluginTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithOneArg() {
|
public function testExecuteWithOneArg() {
|
||||||
$this->Task->expects($this->at(0))->method('in')
|
$this->Task->expects($this->at(0))->method('in')
|
||||||
->will($this->returnValue(self::$_testPath));
|
->will($this->returnValue($this->_testPath));
|
||||||
$this->Task->expects($this->at(1))->method('in')
|
$this->Task->expects($this->at(1))->method('in')
|
||||||
->will($this->returnValue('y'));
|
->will($this->returnValue('y'));
|
||||||
|
|
||||||
|
@ -250,7 +233,7 @@ class PluginTaskTest extends CakeTestCase {
|
||||||
public function testExecuteWithTwoArgs() {
|
public function testExecuteWithTwoArgs() {
|
||||||
$this->Task->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
|
$this->Task->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
|
||||||
|
|
||||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue(self::$_testPath));
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
|
||||||
|
|
||||||
$this->Task->Model->expects($this->once())->method('loadTasks');
|
$this->Task->Model->expects($this->once())->method('loadTasks');
|
||||||
$this->Task->Model->expects($this->once())->method('execute');
|
$this->Task->Model->expects($this->once())->method('execute');
|
||||||
|
|
|
@ -45,13 +45,14 @@ require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php'
|
||||||
class ProjectTaskTest extends CakeTestCase {
|
class ProjectTaskTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setup method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('ProjectTask',
|
$this->Task = $this->getMock('ProjectTask',
|
||||||
array('in', 'err', 'createFile', '_stop'),
|
array('in', 'err', 'createFile', '_stop'),
|
||||||
|
@ -62,12 +63,12 @@ class ProjectTaskTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* teardown method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function tearDown() {
|
||||||
ClassRegistry::flush();
|
parent::tearDown();
|
||||||
|
|
||||||
$Folder = new Folder($this->Task->path . 'bake_test_app');
|
$Folder = new Folder($this->Task->path . 'bake_test_app');
|
||||||
$Folder->delete();
|
$Folder->delete();
|
||||||
|
|
|
@ -44,13 +44,13 @@ require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php
|
||||||
class TemplateTaskTest extends CakeTestCase {
|
class TemplateTaskTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setup method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setup() {
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('TemplateTask',
|
$this->Task = $this->getMock('TemplateTask',
|
||||||
array('in', 'err', 'createFile', '_stop'),
|
array('in', 'err', 'createFile', '_stop'),
|
||||||
|
@ -60,13 +60,14 @@ class TemplateTaskTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* teardown method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function teardown() {
|
||||||
unset($this->Task, $this->Dispatcher);
|
unset($this->Task, $this->Dispatcher);
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
|
App::build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,6 +85,12 @@ class TemplateTaskTest extends CakeTestCase {
|
||||||
$this->assertEqual($this->Task->templateVars['one'], 'three');
|
$this->assertEqual($this->Task->templateVars['one'], 'three');
|
||||||
$this->assertTrue(isset($this->Task->templateVars['four']));
|
$this->assertTrue(isset($this->Task->templateVars['four']));
|
||||||
$this->assertEqual($this->Task->templateVars['four'], 'five');
|
$this->assertEqual($this->Task->templateVars['four'], 'five');
|
||||||
|
|
||||||
|
$this->Task->templateVars = array();
|
||||||
|
$this->Task->set(array(3 => 'three', 4 => 'four'));
|
||||||
|
$this->Task->set(array(1 => 'one', 2 => 'two'));
|
||||||
|
$expected = array(3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two');
|
||||||
|
$this->assertEqual($this->Task->templateVars, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -243,13 +243,14 @@ class TestTaskTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
|
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setup method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setup() {
|
||||||
|
parent::setup();
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('TestTask',
|
$this->Task = $this->getMock('TestTask',
|
||||||
array('in', 'err', 'createFile', '_stop', 'isLoadableClass'),
|
array('in', 'err', 'createFile', '_stop', 'isLoadableClass'),
|
||||||
|
@ -257,7 +258,7 @@ class TestTaskTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->Dispatcher->shellPaths = App::path('shells');
|
$this->Dispatcher->shellPaths = App::path('shells');
|
||||||
$this->Task->name = 'TestTask';
|
$this->Task->name = 'TestTask';
|
||||||
$this->Task->Template =& new TemplateTask($this->Dispatcher);
|
$this->Task->Template = new TemplateTask($this->Dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,7 +266,8 @@ class TestTaskTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function teardown() {
|
||||||
|
parent::teardown();
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,8 +277,8 @@ class TestTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testFilePathGenerationModelRepeated() {
|
public function testFilePathGenerationModelRepeated() {
|
||||||
$this->Task->Dispatch->expects($this->never())->method('stderr');
|
$this->Dispatcher->expects($this->never())->method('stderr');
|
||||||
$this->Task->Dispatch->expects($this->never())->method('_stop');
|
$this->Dispatcher->expects($this->never())->method('_stop');
|
||||||
|
|
||||||
$file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
|
$file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
|
||||||
|
|
||||||
|
@ -446,22 +448,22 @@ class TestTaskTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Task->bake('Model', 'TestTaskArticle');
|
$result = $this->Task->bake('Model', 'TestTaskArticle');
|
||||||
|
|
||||||
$this->assertPattern('/App::import\(\'Model\', \'TestTaskArticle\'\)/', $result);
|
$this->assertContains("App::import('Model', 'TestTaskArticle')", $result);
|
||||||
$this->assertPattern('/class TestTaskArticleTestCase extends CakeTestCase/', $result);
|
$this->assertContains('class TestTaskArticleTestCase extends CakeTestCase', $result);
|
||||||
|
|
||||||
$this->assertPattern('/function startTest\(\)/', $result);
|
$this->assertContains('function startTest()', $result);
|
||||||
$this->assertPattern("/\\\$this->TestTaskArticle \=\& ClassRegistry::init\('TestTaskArticle'\)/", $result);
|
$this->assertContains("\$this->TestTaskArticle =& ClassRegistry::init('TestTaskArticle')", $result);
|
||||||
|
|
||||||
$this->assertPattern('/function endTest\(\)/', $result);
|
$this->assertContains('function endTest()', $result);
|
||||||
$this->assertPattern('/unset\(\$this->TestTaskArticle\)/', $result);
|
$this->assertContains('unset($this->TestTaskArticle)', $result);
|
||||||
|
|
||||||
$this->assertPattern('/function testDoSomething\(\)/i', $result);
|
$this->assertContains('function testDoSomething()', $result);
|
||||||
$this->assertPattern('/function testDoSomethingElse\(\)/i', $result);
|
$this->assertContains('function testDoSomethingElse()', $result);
|
||||||
|
|
||||||
$this->assertPattern("/'app\.test_task_article'/", $result);
|
$this->assertContains("'app.test_task_article'", $result);
|
||||||
$this->assertPattern("/'plugin\.test_task\.test_task_comment'/", $result);
|
$this->assertContains("'plugin.test_task.test_task_comment'", $result);
|
||||||
$this->assertPattern("/'app\.test_task_tag'/", $result);
|
$this->assertContains("'app.test_task_tag'", $result);
|
||||||
$this->assertPattern("/'app\.articles_tag'/", $result);
|
$this->assertContains("'app.articles_tag'", $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -477,24 +479,24 @@ class TestTaskTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Task->bake('Controller', 'TestTaskComments');
|
$result = $this->Task->bake('Controller', 'TestTaskComments');
|
||||||
|
|
||||||
$this->assertPattern('/App::import\(\'Controller\', \'TestTaskComments\'\)/', $result);
|
$this->assertContains("App::import('Controller', 'TestTaskComments')", $result);
|
||||||
$this->assertPattern('/class TestTaskCommentsControllerTestCase extends CakeTestCase/', $result);
|
$this->assertContains('class TestTaskCommentsControllerTestCase extends CakeTestCase', $result);
|
||||||
|
|
||||||
$this->assertPattern('/class TestTestTaskCommentsController extends TestTaskCommentsController/', $result);
|
$this->assertContains('class TestTestTaskCommentsController extends TestTaskCommentsController', $result);
|
||||||
$this->assertPattern('/public \$autoRender = false/', $result);
|
$this->assertContains('public $autoRender = false', $result);
|
||||||
$this->assertPattern('/function redirect\(\$url, \$status = null, \$exit = true\)/', $result);
|
$this->assertContains('function redirect($url, $status = null, $exit = true)', $result);
|
||||||
|
|
||||||
$this->assertPattern('/function startTest\(\)/', $result);
|
$this->assertContains('function startTest()', $result);
|
||||||
$this->assertPattern("/\\\$this->TestTaskComments \=\& new TestTestTaskCommentsController\(\)/", $result);
|
$this->assertContains("\$this->TestTaskComments =& new TestTestTaskCommentsController()", $result);
|
||||||
$this->assertPattern("/\\\$this->TestTaskComments->constructClasses\(\)/", $result);
|
$this->assertContains("\$this->TestTaskComments->constructClasses()", $result);
|
||||||
|
|
||||||
$this->assertPattern('/function endTest\(\)/', $result);
|
$this->assertContains('function endTest()', $result);
|
||||||
$this->assertPattern('/unset\(\$this->TestTaskComments\)/', $result);
|
$this->assertContains('unset($this->TestTaskComments)', $result);
|
||||||
|
|
||||||
$this->assertPattern("/'app\.test_task_article'/", $result);
|
$this->assertContains("'app.test_task_article'", $result);
|
||||||
$this->assertPattern("/'plugin\.test_task\.test_task_comment'/", $result);
|
$this->assertContains("'plugin.test_task.test_task_comment'", $result);
|
||||||
$this->assertPattern("/'app\.test_task_tag'/", $result);
|
$this->assertContains("'app.test_task_tag'", $result);
|
||||||
$this->assertPattern("/'app\.articles_tag'/", $result);
|
$this->assertContains("'app.articles_tag'", $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -224,15 +224,16 @@ class ViewTaskTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
|
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* Ensure that the default theme is used
|
* Ensure that the default theme is used
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTest() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
|
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||||
));
|
));
|
||||||
$this->Task = $this->getMock('ViewTask',
|
$this->Task = $this->getMock('ViewTask',
|
||||||
array('in', 'err', 'createFile', '_stop'),
|
array('in', 'err', 'createFile', '_stop'),
|
||||||
|
@ -245,18 +246,16 @@ class ViewTaskTest extends CakeTestCase {
|
||||||
$this->Dispatcher->shellPaths = App::path('shells');
|
$this->Dispatcher->shellPaths = App::path('shells');
|
||||||
$this->Task->path = TMP;
|
$this->Task->path = TMP;
|
||||||
$this->Task->Template->params['theme'] = 'default';
|
$this->Task->Template->params['theme'] = 'default';
|
||||||
|
|
||||||
$this->_routing = Configure::read('Routing');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* tearDown method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function endTest() {
|
public function tearDown() {
|
||||||
ClassRegistry::flush();
|
parent::tearDown();
|
||||||
Configure::write('Routing', $this->_routing);
|
unset($this->Task, $this->Dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -389,7 +388,7 @@ class ViewTaskTest extends CakeTestCase {
|
||||||
$this->Task->controllerName = 'ViewTaskComments';
|
$this->Task->controllerName = 'ViewTaskComments';
|
||||||
$this->Task->controllerPath = 'view_task_comments';
|
$this->Task->controllerPath = 'view_task_comments';
|
||||||
|
|
||||||
$this->Task->expectNever('createFile');
|
$this->Task->expects($this->never())->method('createFile');
|
||||||
$this->Task->bake('delete', true);
|
$this->Task->bake('delete', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,7 +612,7 @@ class ViewTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteInteractive() {
|
public function testExecuteInteractive() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->args = array();
|
$this->Task->args = array();
|
||||||
$this->Task->params = array();
|
$this->Task->params = array();
|
||||||
|
|
||||||
|
@ -658,7 +657,7 @@ class ViewTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExecuteWithAlternateTemplates() {
|
public function testExecuteWithAlternateTemplates() {
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->args = array('ViewTaskComments', 'index', 'list');
|
$this->Task->args = array('ViewTaskComments', 'index', 'list');
|
||||||
$this->Task->params = array();
|
$this->Task->params = array();
|
||||||
|
|
||||||
|
@ -677,7 +676,7 @@ class ViewTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testExecuteInteractiveWithAdmin() {
|
public function testExecuteInteractiveWithAdmin() {
|
||||||
Configure::write('Routing.prefixes', array('admin'));
|
Configure::write('Routing.prefixes', array('admin'));
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test';
|
||||||
$this->Task->args = array();
|
$this->Task->args = array();
|
||||||
|
|
||||||
$this->Task->Controller->expects($this->once())->method('getName')
|
$this->Task->Controller->expects($this->once())->method('getName')
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TestSuiteShellTest extends CakeTestCase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$this->Dispatcher = $this->getMock(
|
$this->Dispatcher = $this->getMock(
|
||||||
'ShellDispatcher',
|
'ShellDispatcher',
|
||||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
|
||||||
);
|
);
|
||||||
$this->Shell = $this->getMock(
|
$this->Shell = $this->getMock(
|
||||||
'TestSuiteShell',
|
'TestSuiteShell',
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
require_once CAKE . 'dispatcher.php';
|
require_once CAKE . 'dispatcher.php';
|
||||||
|
App::import('Core', 'CakeResponse', false);
|
||||||
|
|
||||||
if (!class_exists('AppController')) {
|
if (!class_exists('AppController')) {
|
||||||
require_once LIBS . 'controller' . DS . 'app_controller.php';
|
require_once LIBS . 'controller' . DS . 'app_controller.php';
|
||||||
|
@ -25,6 +26,17 @@ if (!class_exists('AppController')) {
|
||||||
define('APP_CONTROLLER_EXISTS', true);
|
define('APP_CONTROLLER_EXISTS', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A testing stub that doesn't send headers.
|
||||||
|
*
|
||||||
|
* @package cake.tests.cases
|
||||||
|
*/
|
||||||
|
class DispatcherMockCakeResponse extends CakeResponse {
|
||||||
|
protected function _sendHeader($name, $value = null) {
|
||||||
|
return $name . ' ' . $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestDispatcher class
|
* TestDispatcher class
|
||||||
*
|
*
|
||||||
|
@ -50,16 +62,6 @@ class TestDispatcher extends Dispatcher {
|
||||||
return $controller;
|
return $controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* cakeError method
|
|
||||||
*
|
|
||||||
* @param mixed $filename
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function cakeError($filename, $params) {
|
|
||||||
return array($filename, $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _stop method
|
* _stop method
|
||||||
*
|
*
|
||||||
|
@ -69,15 +71,6 @@ class TestDispatcher extends Dispatcher {
|
||||||
$this->stopped = true;
|
$this->stopped = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* header method
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function header() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -413,7 +406,7 @@ class SomePostsController extends AppController {
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases
|
* @subpackage cake.tests.cases
|
||||||
*/
|
*/
|
||||||
class TestCachedPagesController extends AppController {
|
class TestCachedPagesController extends Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name property
|
* name property
|
||||||
|
@ -437,7 +430,7 @@ class TestCachedPagesController extends AppController {
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public $helpers = array('Cache');
|
public $helpers = array('Cache', 'Html');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cacheAction property
|
* cacheAction property
|
||||||
|
@ -451,6 +444,13 @@ class TestCachedPagesController extends AppController {
|
||||||
'view' => '+2 sec'
|
'view' => '+2 sec'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock out the reponse object so it doesn't send headers.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $_responseClass = 'DispatcherMockCakeResponse';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* viewPath property
|
* viewPath property
|
||||||
*
|
*
|
||||||
|
@ -502,7 +502,7 @@ class TestCachedPagesController extends AppController {
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases
|
* @subpackage cake.tests.cases
|
||||||
*/
|
*/
|
||||||
class TimesheetsController extends AppController {
|
class TimesheetsController extends Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name property
|
* name property
|
||||||
|
@ -562,6 +562,7 @@ class DispatcherTest extends CakeTestCase {
|
||||||
$this->_debug = Configure::read('debug');
|
$this->_debug = Configure::read('debug');
|
||||||
|
|
||||||
App::build(App::core());
|
App::build(App::core());
|
||||||
|
App::objects('plugin', null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1272,8 +1273,6 @@ class DispatcherTest extends CakeTestCase {
|
||||||
|
|
||||||
$Dispatcher = new TestDispatcher();
|
$Dispatcher = new TestDispatcher();
|
||||||
$Dispatcher->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
$Dispatcher->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||||
$debug = Configure::read('debug');
|
|
||||||
//Configure::write('debug', 0);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css');
|
$Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css');
|
||||||
|
@ -1377,20 +1376,20 @@ class DispatcherTest extends CakeTestCase {
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
$expected = "alert('plugin one nested js file');";
|
$expected = "alert('plugin one nested js file');";
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
Configure::write('debug', $debug);
|
|
||||||
//reset the
|
|
||||||
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$Dispatcher->asset('test_plugin/css/unknown.extension');
|
$Dispatcher->asset('test_plugin/css/unknown.extension');
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
$this->assertEqual('Testing a file with unknown extension to mime mapping.', $result);
|
$this->assertEqual('Testing a file with unknown extension to mime mapping.', $result);
|
||||||
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$Dispatcher->asset('test_plugin/css/theme_one.htc');
|
$Dispatcher->asset('test_plugin/css/theme_one.htc');
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
$this->assertEqual('htc file', $result);
|
$this->assertEqual('htc file', $result);
|
||||||
|
|
||||||
|
while (ob_get_level() > 0) {
|
||||||
|
ob_get_clean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1405,7 +1404,6 @@ class DispatcherTest extends CakeTestCase {
|
||||||
'js' => '',
|
'js' => '',
|
||||||
'css' => null
|
'css' => null
|
||||||
));
|
));
|
||||||
$this->assertNoErrors();
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$Dispatcher->asset('ccss/cake.generic.css');
|
$Dispatcher->asset('ccss/cake.generic.css');
|
||||||
|
@ -1471,7 +1469,6 @@ class DispatcherTest extends CakeTestCase {
|
||||||
), true);
|
), true);
|
||||||
|
|
||||||
$dispatcher = new TestDispatcher();
|
$dispatcher = new TestDispatcher();
|
||||||
$dispatcher->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
|
||||||
$url = '/';
|
$url = '/';
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
|
@ -34,16 +34,10 @@ class AllCacheEnginesTest extends PHPUnit_Framework_TestSuite {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function suite() {
|
public static function suite() {
|
||||||
$suite = new PHPUnit_Framework_TestSuite('All Cache related class tests');
|
$suite = new CakeTestSuite('All Cache related class tests');
|
||||||
|
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cache.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cache.test.php');
|
||||||
|
$suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'cache');
|
||||||
$cacheIterator = new DirectoryIterator(CORE_TEST_CASES . DS . 'libs' . DS . 'cache');
|
|
||||||
foreach ($cacheIterator as $i => $file) {
|
|
||||||
if (!$file->isDot()) {
|
|
||||||
$suite->addTestfile($file->getPathname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $suite;
|
return $suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,17 +34,11 @@ class AllComponentsTest extends PHPUnit_Framework_TestSuite {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function suite() {
|
public static function suite() {
|
||||||
$suite = new PHPUnit_Framework_TestSuite('All component class tests');
|
$suite = new CakeTestSuite('All component class tests');
|
||||||
|
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component_collection.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component_collection.test.php');
|
||||||
|
$suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components');
|
||||||
$iterator = new DirectoryIterator(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components');
|
|
||||||
foreach ($iterator as $i => $file) {
|
|
||||||
if (!$file->isDot()) {
|
|
||||||
$suite->addTestfile($file->getPathname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $suite;
|
return $suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,18 +35,11 @@ class AllHelpersTest extends PHPUnit_Framework_TestSuite {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function suite() {
|
public static function suite() {
|
||||||
$suite = new PHPUnit_Framework_TestSuite('All Helper tests');
|
$suite = new CakeTestSuite('All Helper tests');
|
||||||
|
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helper.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helper.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helper_collection.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helper_collection.test.php');
|
||||||
|
$suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS);
|
||||||
$helperIterator = new DirectoryIterator(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS);
|
|
||||||
|
|
||||||
foreach ($helperIterator as $i => $file) {
|
|
||||||
if (!$file->isDot()) {
|
|
||||||
$suite->addTestfile($file->getPathname());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $suite;
|
return $suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ class AllLibsTest extends PHPUnit_Framework_TestSuite {
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'error_handler.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'error_handler.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'file.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'file.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'folder.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'folder.test.php');
|
||||||
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'inflector.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'log' . DS . 'file_log.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'log' . DS . 'file_log.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_log.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_log.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry.test.php');
|
||||||
|
|
|
@ -36,7 +36,7 @@ class AllModelTest extends PHPUnit_Framework_TestSuite {
|
||||||
public static function suite() {
|
public static function suite() {
|
||||||
$suite = new PHPUnit_Framework_TestSuite('All Model related class tests');
|
$suite = new PHPUnit_Framework_TestSuite('All Model related class tests');
|
||||||
|
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_behavior.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'behavior_collection.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_read.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_read.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_write.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_write.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_validation.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_validation.test.php');
|
||||||
|
|
|
@ -39,6 +39,8 @@ class AllRoutingTest extends PHPUnit_Framework_TestSuite {
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'router.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'router.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'route' . DS . 'cake_route.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'route' . DS . 'cake_route.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'route' . DS . 'plugin_short_route.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'route' . DS . 'plugin_short_route.test.php');
|
||||||
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_response.test.php');
|
||||||
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_request.test.php');
|
||||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'dispatcher.test.php');
|
$suite->addTestFile(CORE_TEST_CASES . DS . 'dispatcher.test.php');
|
||||||
return $suite;
|
return $suite;
|
||||||
}
|
}
|
||||||
|
|
61
cake/tests/cases/libs/all_tests.test.php
Normal file
61
cake/tests/cases/libs/all_tests.test.php
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* AllTests file
|
||||||
|
*
|
||||||
|
* PHP 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||||
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
* @link http://cakephp.org CakePHP(tm) Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases
|
||||||
|
* @since CakePHP(tm) v 2.0
|
||||||
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* AllTests class
|
||||||
|
*
|
||||||
|
* This test group will run all test in the cases/libs/models/behaviors directory
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.groups
|
||||||
|
*/
|
||||||
|
class AllTests extends PHPUnit_Framework_TestSuite {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suite define the tests for this suite
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function suite() {
|
||||||
|
$suite = new PHPUnit_Framework_TestSuite('All Tests');
|
||||||
|
|
||||||
|
$path = CORE_TEST_CASES . DS . 'libs' . DS;
|
||||||
|
$console = CORE_TEST_CASES . DS . 'console' . DS;
|
||||||
|
|
||||||
|
$suite->addTestFile($console . 'all_shells.test.php');
|
||||||
|
$suite->addTestFile($console . 'all_tasks.test.php');
|
||||||
|
|
||||||
|
$suite->addTestFile($path . 'all_behaviors.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_cache_engines.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_components.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_configure.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_controllers.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_database.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_helpers.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_libs.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_localization.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_model.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_routing.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_socket.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_test_suite.test.php');;
|
||||||
|
$suite->addTestFile($path . 'all_views.test.php');
|
||||||
|
$suite->addTestFile($path . 'all_xml.test.php');
|
||||||
|
return $suite;
|
||||||
|
}
|
||||||
|
}
|
|
@ -120,14 +120,15 @@ class CacheTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testInvaidConfig() {
|
function testInvaidConfig() {
|
||||||
$this->expectError();
|
$this->expectError();
|
||||||
Cache::config('Invalid', array(
|
Cache::config('invalid', array(
|
||||||
'engine' => 'File',
|
'engine' => 'File',
|
||||||
'duration' => '+1 year',
|
'duration' => '+1 year',
|
||||||
'prefix' => 'testing_invalid_',
|
'prefix' => 'testing_invalid_',
|
||||||
'path' => 'data/',
|
'path' => 'data/',
|
||||||
'serialize' => true
|
'serialize' => true,
|
||||||
|
'random' => 'wii'
|
||||||
));
|
));
|
||||||
$read = Cache::read('Test', 'Invalid');
|
$read = Cache::read('Test', 'invalid');
|
||||||
$this->assertEqual($read, null);
|
$this->assertEqual($read, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
cake/tests/cases/libs/cache/apc.test.php
vendored
15
cake/tests/cases/libs/cache/apc.test.php
vendored
|
@ -29,20 +29,6 @@ if (!class_exists('Cache')) {
|
||||||
*/
|
*/
|
||||||
class ApcEngineTest extends CakeTestCase {
|
class ApcEngineTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
|
||||||
* skip method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function skip() {
|
|
||||||
$skip = true;
|
|
||||||
if (function_exists('apc_store')) {
|
|
||||||
$skip = false;
|
|
||||||
}
|
|
||||||
$this->skipIf($skip, '%s Apc is not installed or configured properly');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUp method
|
* setUp method
|
||||||
*
|
*
|
||||||
|
@ -50,6 +36,7 @@ class ApcEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
$this->skipIf(!function_exists('apc_store'), '%s Apc is not installed or configured properly');
|
||||||
$this->_cacheDisable = Configure::read('Cache.disable');
|
$this->_cacheDisable = Configure::read('Cache.disable');
|
||||||
Configure::write('Cache.disable', false);
|
Configure::write('Cache.disable', false);
|
||||||
Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_'));
|
Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_'));
|
||||||
|
|
9
cake/tests/cases/libs/cache/file.test.php
vendored
9
cake/tests/cases/libs/cache/file.test.php
vendored
|
@ -38,12 +38,12 @@ class FileEngineTest extends CakeTestCase {
|
||||||
public $config = array();
|
public $config = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startCase method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function startCase() {
|
function setUp() {
|
||||||
$this->_cacheDisable = Configure::read('Cache.disable');
|
$this->_cacheDisable = Configure::read('Cache.disable');
|
||||||
$this->_cacheConfig = Cache::config('default');
|
$this->_cacheConfig = Cache::config('default');
|
||||||
Configure::write('Cache.disable', false);
|
Configure::write('Cache.disable', false);
|
||||||
|
@ -51,12 +51,13 @@ class FileEngineTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endCase method
|
* teardown method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function endCase() {
|
function tearDown() {
|
||||||
|
Cache::clear(false, 'default');
|
||||||
Configure::write('Cache.disable', $this->_cacheDisable);
|
Configure::write('Cache.disable', $this->_cacheDisable);
|
||||||
Cache::config('default', $this->_cacheConfig['settings']);
|
Cache::config('default', $this->_cacheConfig['settings']);
|
||||||
}
|
}
|
||||||
|
|
30
cake/tests/cases/libs/cache/memcache.test.php
vendored
30
cake/tests/cases/libs/cache/memcache.test.php
vendored
|
@ -29,20 +29,6 @@ if (!class_exists('Cache')) {
|
||||||
*/
|
*/
|
||||||
class MemcacheEngineTest extends CakeTestCase {
|
class MemcacheEngineTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
|
||||||
* skip method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function skip() {
|
|
||||||
$skip = true;
|
|
||||||
if (class_exists('Memcache')) {
|
|
||||||
$skip = false;
|
|
||||||
}
|
|
||||||
$this->skipIf($skip, '%s Memcache is not installed or configured properly.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUp method
|
* setUp method
|
||||||
*
|
*
|
||||||
|
@ -50,6 +36,7 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
$this->skipIf(!class_exists('Memcache'), '%s Apc is not installed or configured properly');
|
||||||
$this->_cacheDisable = Configure::read('Cache.disable');
|
$this->_cacheDisable = Configure::read('Cache.disable');
|
||||||
Configure::write('Cache.disable', false);
|
Configure::write('Cache.disable', false);
|
||||||
Cache::config('memcache', array(
|
Cache::config('memcache', array(
|
||||||
|
@ -315,4 +302,19 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertFalse(Cache::read('some_value', 'memcache'));
|
$this->assertFalse(Cache::read('some_value', 'memcache'));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* test that a 0 duration can succesfully write.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testZeroDuration() {
|
||||||
|
Cache::config('memcache', array('duration' => 0));
|
||||||
|
$result = Cache::write('test_key', 'written!', 'memcache');
|
||||||
|
|
||||||
|
$this->assertTrue($result, 'Could not write with duration 0');
|
||||||
|
$result = Cache::read('test_key', 'memcache');
|
||||||
|
$this->assertEqual($result, 'written!');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ class CakeLogTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function startTest() {
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$streams = CakeLog::configured();
|
$streams = CakeLog::configured();
|
||||||
foreach ($streams as $stream) {
|
foreach ($streams as $stream) {
|
||||||
CakeLog::drop($stream);
|
CakeLog::drop($stream);
|
||||||
|
|
|
@ -28,25 +28,25 @@ class CakeRequestTestCase extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function startTest() {
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->_server = $_SERVER;
|
$this->_server = $_SERVER;
|
||||||
$this->_get = $_GET;
|
$this->_get = $_GET;
|
||||||
$this->_post = $_POST;
|
$this->_post = $_POST;
|
||||||
$this->_files = $_FILES;
|
$this->_files = $_FILES;
|
||||||
$this->_app = Configure::read('App');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* end test
|
* tearDown-
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function endTest() {
|
function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
$_SERVER = $this->_server;
|
$_SERVER = $this->_server;
|
||||||
$_GET = $this->_get;
|
$_GET = $this->_get;
|
||||||
$_POST = $this->_post;
|
$_POST = $this->_post;
|
||||||
$_FILES = $this->_files;
|
$_FILES = $this->_files;
|
||||||
Configure::write('App', $this->_app);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -742,6 +742,8 @@ class CakeRequestTestCase extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testHeader() {
|
function testHeader() {
|
||||||
|
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||||
|
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-ca) AppleWebKit/534.8+ (KHTML, like Gecko) Version/5.0 Safari/533.16';
|
||||||
$request = new CakeRequest('/', false);
|
$request = new CakeRequest('/', false);
|
||||||
|
|
||||||
$this->assertEquals($_SERVER['HTTP_HOST'], $request->header('host'));
|
$this->assertEquals($_SERVER['HTTP_HOST'], $request->header('host'));
|
||||||
|
|
|
@ -4,7 +4,6 @@ App::import('Core', 'CakeResponse');
|
||||||
|
|
||||||
class CakeResponseTestCase extends CakeTestCase {
|
class CakeResponseTestCase extends CakeTestCase {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the request object constructor
|
* Tests the request object constructor
|
||||||
*
|
*
|
||||||
|
@ -283,6 +282,8 @@ class CakeResponseTestCase extends CakeTestCase {
|
||||||
$result = $response->compress();
|
$result = $response->compress();
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertTrue(in_array('ob_gzhandler', ob_list_handlers()));
|
$this->assertTrue(in_array('ob_gzhandler', ob_list_handlers()));
|
||||||
|
|
||||||
|
ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -116,7 +116,7 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
$_SESSION = null;
|
$_SESSION = null;
|
||||||
|
|
||||||
Configure::write('Session', array(
|
Configure::write('Session', array(
|
||||||
'cookie' => 'test_suite',
|
'cookie' => 'test',
|
||||||
'checkAgent' => false,
|
'checkAgent' => false,
|
||||||
'timeout' => 86400,
|
'timeout' => 86400,
|
||||||
'ini' => array(
|
'ini' => array(
|
||||||
|
@ -127,7 +127,7 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
TestCakeSession::start();
|
TestCakeSession::start();
|
||||||
$this->assertEquals('', ini_get('session.use_trans_sid'), 'Ini value is incorrect');
|
$this->assertEquals('', ini_get('session.use_trans_sid'), 'Ini value is incorrect');
|
||||||
$this->assertEquals('example.com', ini_get('session.referer_check'), 'Ini value is incorrect');
|
$this->assertEquals('example.com', ini_get('session.referer_check'), 'Ini value is incorrect');
|
||||||
$this->assertEquals('test_suite', ini_get('session.name'), 'Ini value is incorrect');
|
$this->assertEquals('test', ini_get('session.name'), 'Ini value is incorrect');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -682,7 +682,7 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
Configure::write('Session.defaults', 'database');
|
Configure::write('Session.defaults', 'database');
|
||||||
Configure::write('Session.handler.table', 'sessions');
|
Configure::write('Session.handler.table', 'sessions');
|
||||||
Configure::write('Session.handler.model', 'Session');
|
Configure::write('Session.handler.model', 'Session');
|
||||||
Configure::write('Session.handler.database', 'test_suite');
|
Configure::write('Session.handler.database', 'test');
|
||||||
|
|
||||||
TestCakeSession::init();
|
TestCakeSession::init();
|
||||||
TestCakeSession::start();
|
TestCakeSession::start();
|
||||||
|
|
|
@ -145,13 +145,13 @@ class CakeSocketTest extends CakeTestCase {
|
||||||
$this->Socket->connect();
|
$this->Socket->connect();
|
||||||
$this->assertEqual($this->Socket->read(26), null);
|
$this->assertEqual($this->Socket->read(26), null);
|
||||||
|
|
||||||
$config = array('host' => '127.0.0.1', 'timeout' => 1);
|
$config = array('host' => '127.0.0.1', 'timeout' => 0.5);
|
||||||
$this->Socket = new CakeSocket($config);
|
$this->Socket = new CakeSocket($config);
|
||||||
$this->assertTrue($this->Socket->connect());
|
$this->assertTrue($this->Socket->connect());
|
||||||
$this->assertFalse($this->Socket->read(1024 * 1024));
|
$this->assertFalse($this->Socket->read(1024 * 1024));
|
||||||
$this->assertEqual($this->Socket->lastError(), '2: ' . __('Connection timed out'));
|
$this->assertEqual($this->Socket->lastError(), '2: ' . __('Connection timed out'));
|
||||||
|
|
||||||
$config = array('host' => 'localhost', 'timeout' => 30);
|
$config = array('host' => 'cakephp.org', 'port' => 80, 'timeout' => 20);
|
||||||
$this->Socket = new CakeSocket($config);
|
$this->Socket = new CakeSocket($config);
|
||||||
$this->assertTrue($this->Socket->connect());
|
$this->assertTrue($this->Socket->connect());
|
||||||
$this->assertEqual($this->Socket->read(26), null);
|
$this->assertEqual($this->Socket->read(26), null);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
* @since CakePHP v 1.2.0.4487
|
* @since CakePHP v 1.2.0.4487
|
||||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
*/
|
*/
|
||||||
|
App::import('Controller', 'Controller', false);
|
||||||
|
require_once TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'lib' . DS . 'reporter' . DS . 'cake_html_reporter.php';
|
||||||
|
|
||||||
if (!class_exists('AppController')) {
|
if (!class_exists('AppController')) {
|
||||||
require_once LIBS . 'controller' . DS . 'app_controller.php';
|
require_once LIBS . 'controller' . DS . 'app_controller.php';
|
||||||
|
|
|
@ -112,14 +112,14 @@ class CakeTestFixtureDefaultImportFixture extends CakeTestFixture {
|
||||||
class FixtureImportTestModel extends Model {
|
class FixtureImportTestModel extends Model {
|
||||||
public $name = 'FixtureImport';
|
public $name = 'FixtureImport';
|
||||||
public $useTable = 'fixture_tests';
|
public $useTable = 'fixture_tests';
|
||||||
public $useDbConfig = 'test_suite';
|
public $useDbConfig = 'test';
|
||||||
}
|
}
|
||||||
|
|
||||||
class FixturePrefixTest extends Model {
|
class FixturePrefixTest extends Model {
|
||||||
public $name = 'FixturePrefix';
|
public $name = 'FixturePrefix';
|
||||||
public $useTable = '_tests';
|
public $useTable = '_tests';
|
||||||
public $tablePrefix = 'fixture';
|
public $tablePrefix = 'fixture';
|
||||||
public $useDbConfig = 'test_suite';
|
public $useDbConfig = 'test';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,12 +139,8 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
$this->criticDb = $this->getMock('DboSource');
|
$this->criticDb = $this->getMock('DboSource');
|
||||||
$this->criticDb->fullDebug = true;
|
$this->criticDb->fullDebug = true;
|
||||||
|
$this->db = ConnectionManager::getDataSource('test');
|
||||||
$dbs = ConnectionManager::enumConnectionObjects();
|
$this->_backupConfig = $this->db->config;
|
||||||
if (!isset($dbs['test_suite'])) {
|
|
||||||
$db = ConnectionManager::getDatasource('test');
|
|
||||||
ConnectionManager::create('test_suite', $db->config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,6 +151,7 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
unset($this->criticDb);
|
unset($this->criticDb);
|
||||||
|
$this->db->config = $this->_backupConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,7 +180,7 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testInitDbPrefix() {
|
function testInitDbPrefix() {
|
||||||
$db = ConnectionManager::getDataSource('test_suite');
|
$db = ConnectionManager::getDataSource('test');
|
||||||
$Source = new CakeTestFixtureTestFixture();
|
$Source = new CakeTestFixtureTestFixture();
|
||||||
$Source->drop($db);
|
$Source->drop($db);
|
||||||
$Source->create($db);
|
$Source->create($db);
|
||||||
|
@ -198,14 +195,14 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
ConnectionManager::create('fixture_test_suite', $config);
|
ConnectionManager::create('fixture_test_suite', $config);
|
||||||
|
|
||||||
$Fixture->fields = $Fixture->records = null;
|
$Fixture->fields = $Fixture->records = null;
|
||||||
$Fixture->import = array('table' => 'fixture_tests', 'connection' => 'test_suite', 'records' => true);
|
$Fixture->import = array('table' => 'fixture_tests', 'connection' => 'test', 'records' => true);
|
||||||
$Fixture->init();
|
$Fixture->init();
|
||||||
$this->assertEqual(count($Fixture->records), count($Source->records));
|
$this->assertEqual(count($Fixture->records), count($Source->records));
|
||||||
$Fixture->create(ConnectionManager::getDataSource('fixture_test_suite'));
|
$Fixture->create(ConnectionManager::getDataSource('fixture_test_suite'));
|
||||||
|
|
||||||
$Fixture =& new CakeTestFixtureImportFixture();
|
$Fixture = new CakeTestFixtureImportFixture();
|
||||||
$Fixture->fields = $Fixture->records = $Fixture->table = null;
|
$Fixture->fields = $Fixture->records = $Fixture->table = null;
|
||||||
$Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test_suite');
|
$Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test');
|
||||||
$Fixture->init();
|
$Fixture->init();
|
||||||
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
|
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
|
||||||
$this->assertEqual($Fixture->table, 'fixture_tests');
|
$this->assertEqual($Fixture->table, 'fixture_tests');
|
||||||
|
@ -223,24 +220,27 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testInitDbPrefixDuplication() {
|
function testInitDbPrefixDuplication() {
|
||||||
$this->_initDb();
|
$db = ConnectionManager::getDataSource('test');
|
||||||
$backPrefix = $this->db->config['prefix'];
|
$backPrefix = $db->config['prefix'];
|
||||||
$this->db->config['prefix'] = 'cake_fixture_test_';
|
$db->config['prefix'] = 'cake_fixture_test_';
|
||||||
|
ConnectionManager::create('fixture_test_suite', $db->config);
|
||||||
|
$newDb = ConnectionManager::getDataSource('fixture_test_suite');
|
||||||
|
$newDb->config['prefix'] = 'cake_fixture_test_';
|
||||||
|
|
||||||
$Source =& new CakeTestFixtureTestFixture();
|
$Source = new CakeTestFixtureTestFixture();
|
||||||
$Source->create($this->db);
|
$Source->create($db);
|
||||||
$Source->insert($this->db);
|
$Source->insert($db);
|
||||||
|
|
||||||
$Fixture =& new CakeTestFixtureImportFixture();
|
$Fixture = new CakeTestFixtureImportFixture();
|
||||||
$Fixture->fields = $Fixture->records = $Fixture->table = null;
|
$Fixture->fields = $Fixture->records = $Fixture->table = null;
|
||||||
$Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test_suite');
|
$Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test');
|
||||||
|
|
||||||
$Fixture->init();
|
$Fixture->init();
|
||||||
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
|
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
|
||||||
$this->assertEqual($Fixture->table, 'fixture_tests');
|
$this->assertEqual($Fixture->table, 'fixture_tests');
|
||||||
|
|
||||||
$Source->drop($this->db);
|
$Source->drop($db);
|
||||||
$this->db->config['prefix'] = $backPrefix;
|
$db->config['prefix'] = $backPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -249,26 +249,25 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testInitModelTablePrefix() {
|
function testInitModelTablePrefix() {
|
||||||
$this->_initDb();
|
|
||||||
$hasPrefix = !empty($this->db->config['prefix']);
|
$hasPrefix = !empty($this->db->config['prefix']);
|
||||||
if ($this->skipIf($hasPrefix, 'Cannot run this test, you have a database connection prefix.')) {
|
if ($this->skipIf($hasPrefix, 'Cannot run this test, you have a database connection prefix.')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$Source =& new CakeTestFixtureTestFixture();
|
$Source = new CakeTestFixtureTestFixture();
|
||||||
$Source->create($db);
|
$Source->create($this->db);
|
||||||
$Source->insert($db);
|
$Source->insert($this->db);
|
||||||
|
|
||||||
$Fixture =& new CakeTestFixtureTestFixture();
|
$Fixture = new CakeTestFixtureTestFixture();
|
||||||
unset($Fixture->table);
|
unset($Fixture->table);
|
||||||
$Fixture->fields = $Fixture->records = null;
|
$Fixture->fields = $Fixture->records = null;
|
||||||
$Fixture->import = array('model' => 'FixturePrefixTest', 'connection' => 'test_suite', 'records' => false);
|
$Fixture->import = array('model' => 'FixturePrefixTest', 'connection' => 'test', 'records' => false);
|
||||||
$Fixture->init();
|
$Fixture->init();
|
||||||
$this->assertEqual($Fixture->table, 'fixture_tests');
|
$this->assertEqual($Fixture->table, 'fixture_tests');
|
||||||
|
|
||||||
$keys = array_flip(ClassRegistry::keys());
|
$keys = array_flip(ClassRegistry::keys());
|
||||||
$this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
|
$this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
|
||||||
|
|
||||||
$Source->drop($db);
|
$Source->drop($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -279,7 +278,7 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testImport() {
|
function testImport() {
|
||||||
$defaultDb = ConnectionManager::getDataSource('default');
|
$defaultDb = ConnectionManager::getDataSource('default');
|
||||||
$testSuiteDb = ConnectionManager::getDataSource('test_suite');
|
$testSuiteDb = ConnectionManager::getDataSource('test');
|
||||||
$defaultConfig = $defaultDb->config;
|
$defaultConfig = $defaultDb->config;
|
||||||
$testSuiteConfig = $testSuiteDb->config;
|
$testSuiteConfig = $testSuiteDb->config;
|
||||||
ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix'])));
|
ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix'])));
|
||||||
|
@ -314,7 +313,7 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
function testImportWithRecords() {
|
function testImportWithRecords() {
|
||||||
|
|
||||||
$defaultDb = ConnectionManager::getDataSource('default');
|
$defaultDb = ConnectionManager::getDataSource('default');
|
||||||
$testSuiteDb = ConnectionManager::getDataSource('test_suite');
|
$testSuiteDb = ConnectionManager::getDataSource('test');
|
||||||
$defaultConfig = $defaultDb->config;
|
$defaultConfig = $defaultDb->config;
|
||||||
$testSuiteConfig = $testSuiteDb->config;
|
$testSuiteConfig = $testSuiteDb->config;
|
||||||
ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix'])));
|
ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix'])));
|
||||||
|
|
|
@ -211,6 +211,8 @@ class ClassRegistryTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testClassRegistryFlush() {
|
function testClassRegistryFlush() {
|
||||||
|
$Tag = ClassRegistry::init('RegisterArticleTag');
|
||||||
|
|
||||||
$ArticleTag = ClassRegistry::getObject('RegisterArticleTag');
|
$ArticleTag = ClassRegistry::getObject('RegisterArticleTag');
|
||||||
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
|
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
|
|
|
@ -40,16 +40,8 @@ class ConfigureTest extends CakeTestCase {
|
||||||
$this->_debug = Configure::read('debug');
|
$this->_debug = Configure::read('debug');
|
||||||
|
|
||||||
Configure::write('Cache.disable', true);
|
Configure::write('Cache.disable', true);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* endTest
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function endTest() {
|
|
||||||
App::build();
|
App::build();
|
||||||
|
App::objects('plugin', null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -397,27 +389,27 @@ class AppImportTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testListObjects() {
|
function testListObjects() {
|
||||||
$result = App::objects('class', TEST_CAKE_CORE_INCLUDE_PATH . 'libs');
|
$result = App::objects('class', TEST_CAKE_CORE_INCLUDE_PATH . 'libs', false);
|
||||||
$this->assertTrue(in_array('Xml', $result));
|
$this->assertTrue(in_array('Xml', $result));
|
||||||
$this->assertTrue(in_array('Cache', $result));
|
$this->assertTrue(in_array('Cache', $result));
|
||||||
$this->assertTrue(in_array('HttpSocket', $result));
|
$this->assertTrue(in_array('HttpSocket', $result));
|
||||||
|
|
||||||
$result = App::objects('behavior');
|
$result = App::objects('behavior', null, false);
|
||||||
$this->assertTrue(in_array('Tree', $result));
|
$this->assertTrue(in_array('Tree', $result));
|
||||||
|
|
||||||
$result = App::objects('controller');
|
$result = App::objects('controller', null, false);
|
||||||
$this->assertTrue(in_array('Pages', $result));
|
$this->assertTrue(in_array('Pages', $result));
|
||||||
|
|
||||||
$result = App::objects('component');
|
$result = App::objects('component', null, false);
|
||||||
$this->assertTrue(in_array('Auth', $result));
|
$this->assertTrue(in_array('Auth', $result));
|
||||||
|
|
||||||
$result = App::objects('view');
|
$result = App::objects('view', null, false);
|
||||||
$this->assertTrue(in_array('Media', $result));
|
$this->assertTrue(in_array('Media', $result));
|
||||||
|
|
||||||
$result = App::objects('helper');
|
$result = App::objects('helper', null, false);
|
||||||
$this->assertTrue(in_array('Html', $result));
|
$this->assertTrue(in_array('Html', $result));
|
||||||
|
|
||||||
$result = App::objects('model');
|
$result = App::objects('model', null, false);
|
||||||
$notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
|
$notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
|
||||||
foreach ($notExpected as $class) {
|
foreach ($notExpected as $class) {
|
||||||
$this->assertFalse(in_array($class, $result));
|
$this->assertFalse(in_array($class, $result));
|
||||||
|
@ -714,6 +706,9 @@ class AppImportTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testMultipleLoading() {
|
function testMultipleLoading() {
|
||||||
|
if (class_exists('I18n', false) || class_exists('CakeSocket', false)) {
|
||||||
|
$this->markTestSkipped('Cannot test loading of classes that exist.');
|
||||||
|
}
|
||||||
$toLoad = array('I18n', 'CakeSocket');
|
$toLoad = array('I18n', 'CakeSocket');
|
||||||
|
|
||||||
$classes = array_flip(get_declared_classes());
|
$classes = array_flip(get_declared_classes());
|
||||||
|
|
|
@ -30,10 +30,10 @@ class AclNodeTwoTestBase extends AclNode {
|
||||||
/**
|
/**
|
||||||
* useDbConfig property
|
* useDbConfig property
|
||||||
*
|
*
|
||||||
* @var string 'test_suite'
|
* @var string 'test'
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public $useDbConfig = 'test_suite';
|
public $useDbConfig = 'test';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cacheSources property
|
* cacheSources property
|
||||||
|
@ -189,12 +189,12 @@ class DbAclTwoTest extends DbAcl {
|
||||||
*/
|
*/
|
||||||
class AclComponentTest extends CakeTestCase {
|
class AclComponentTest extends CakeTestCase {
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
if (!class_exists('MockAclImplementation', false)) {
|
if (!class_exists('MockAclImplementation', false)) {
|
||||||
$this->getMock('AclInterface', array(), array(), 'MockAclImplementation');
|
$this->getMock('AclInterface', array(), array(), 'MockAclImplementation');
|
||||||
}
|
}
|
||||||
|
@ -206,10 +206,10 @@ class AclComponentTest extends CakeTestCase {
|
||||||
/**
|
/**
|
||||||
* tearDown method
|
* tearDown method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Acl);
|
unset($this->Acl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,16 +347,14 @@ class DbAclTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.aro_two', 'core.aco_two', 'core.aros_aco_two');
|
public $fixtures = array('core.aro_two', 'core.aco_two', 'core.aros_aco_two');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function startTest() {
|
function setUp() {
|
||||||
$this->_settings = Configure::read('Acl');
|
parent::setUp();
|
||||||
|
|
||||||
Configure::write('Acl.classname', 'DbAclTwoTest');
|
Configure::write('Acl.classname', 'DbAclTwoTest');
|
||||||
Configure::write('Acl.database', 'test_suite');
|
Configure::write('Acl.database', 'test');
|
||||||
$Collection = new ComponentCollection();
|
$Collection = new ComponentCollection();
|
||||||
$this->Acl = new AclComponent($Collection);
|
$this->Acl = new AclComponent($Collection);
|
||||||
}
|
}
|
||||||
|
@ -367,9 +365,9 @@ class DbAclTest extends CakeTestCase {
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function endTest() {
|
function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Acl);
|
unset($this->Acl);
|
||||||
Configure::write('Acl', $this->_settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,10 +76,10 @@ class AuthUser extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* useDbConfig property
|
* useDbConfig property
|
||||||
*
|
*
|
||||||
* @var string 'test_suite'
|
* @var string 'test'
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public $useDbConfig = 'test_suite';
|
public $useDbConfig = 'test';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parentNode method
|
* parentNode method
|
||||||
|
@ -155,10 +155,10 @@ class UuidUser extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* useDbConfig property
|
* useDbConfig property
|
||||||
*
|
*
|
||||||
* @var string 'test_suite'
|
* @var string 'test'
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public $useDbConfig = 'test_suite';
|
public $useDbConfig = 'test';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* useTable property
|
* useTable property
|
||||||
|
@ -473,22 +473,20 @@ class AuthTest extends CakeTestCase {
|
||||||
public $initialized = false;
|
public $initialized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->_server = $_SERVER;
|
$this->_server = $_SERVER;
|
||||||
$this->_env = $_ENV;
|
$this->_env = $_ENV;
|
||||||
|
|
||||||
$this->_securitySalt = Configure::read('Security.salt');
|
|
||||||
$this->_securityCipher = Configure::read('Security.cipherSeed');
|
|
||||||
Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
||||||
Configure::write('Security.cipherSeed', 770011223369876);
|
Configure::write('Security.cipherSeed', 770011223369876);
|
||||||
|
|
||||||
$this->_acl = Configure::read('Acl');
|
Configure::write('Acl.database', 'test');
|
||||||
Configure::write('Acl.database', 'test_suite');
|
|
||||||
Configure::write('Acl.classname', 'DbAcl');
|
Configure::write('Acl.classname', 'DbAcl');
|
||||||
|
|
||||||
$request = new CakeRequest(null, false);
|
$request = new CakeRequest(null, false);
|
||||||
|
@ -505,27 +503,22 @@ class AuthTest extends CakeTestCase {
|
||||||
$this->Controller->Session->delete('Auth');
|
$this->Controller->Session->delete('Auth');
|
||||||
$this->Controller->Session->delete('Message.auth');
|
$this->Controller->Session->delete('Message.auth');
|
||||||
|
|
||||||
Router::reload();
|
|
||||||
|
|
||||||
$this->initialized = true;
|
$this->initialized = true;
|
||||||
|
Router::reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* tearDown method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
$_SERVER = $this->_server;
|
$_SERVER = $this->_server;
|
||||||
$_ENV = $this->_env;
|
$_ENV = $this->_env;
|
||||||
Configure::write('Acl', $this->_acl);
|
|
||||||
Configure::write('Security.salt', $this->_securitySalt);
|
|
||||||
Configure::write('Security.cipherSeed', $this->_securityCipher);
|
|
||||||
|
|
||||||
$this->Controller->Session->delete('Auth');
|
$this->Controller->Session->delete('Auth');
|
||||||
$this->Controller->Session->delete('Message.auth');
|
$this->Controller->Session->delete('Message.auth');
|
||||||
ClassRegistry::flush();
|
|
||||||
unset($this->Controller, $this->AuthUser);
|
unset($this->Controller, $this->AuthUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,11 +950,9 @@ class AuthTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testLoginRedirect() {
|
function testLoginRedirect() {
|
||||||
$backup = null;
|
|
||||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
|
||||||
$backup = $_SERVER['HTTP_REFERER'];
|
|
||||||
}
|
|
||||||
$_SERVER['HTTP_REFERER'] = false;
|
$_SERVER['HTTP_REFERER'] = false;
|
||||||
|
$_ENV['HTTP_REFERER'] = false;
|
||||||
|
putenv('HTTP_REFERER=');
|
||||||
|
|
||||||
$this->Controller->Session->write('Auth', array(
|
$this->Controller->Session->write('Auth', array(
|
||||||
'AuthUser' => array('id' => '1', 'username' => 'nate')
|
'AuthUser' => array('id' => '1', 'username' => 'nate')
|
||||||
|
@ -1017,13 +1008,12 @@ class AuthTest extends CakeTestCase {
|
||||||
$expected = Router::normalize('/');
|
$expected = Router::normalize('/');
|
||||||
$this->assertEqual($expected, $this->Controller->testUrl);
|
$this->assertEqual($expected, $this->Controller->testUrl);
|
||||||
|
|
||||||
|
|
||||||
$this->Controller->Session->delete('Auth');
|
$this->Controller->Session->delete('Auth');
|
||||||
$_SERVER['HTTP_REFERER'] = Router::url('/admin', true);
|
$_SERVER['HTTP_REFERER'] = $_ENV['HTTP_REFERER'] = Router::url('/admin', true);
|
||||||
|
|
||||||
$this->Controller->Session->write('Auth', array(
|
$this->Controller->Session->write('Auth', array(
|
||||||
'AuthUser' => array('id'=>'1', 'username' => 'nate')
|
'AuthUser' => array('id'=>'1', 'username' => 'nate')
|
||||||
));
|
));
|
||||||
|
$this->Controller->request->params['action'] = 'login';
|
||||||
$this->Controller->request->query['url'] = 'auth_test/login';
|
$this->Controller->request->query['url'] = 'auth_test/login';
|
||||||
$this->Controller->Auth->initialize($this->Controller);
|
$this->Controller->Auth->initialize($this->Controller);
|
||||||
$this->Controller->Auth->loginAction = 'auth_test/login';
|
$this->Controller->Auth->loginAction = 'auth_test/login';
|
||||||
|
@ -1124,7 +1114,6 @@ class AuthTest extends CakeTestCase {
|
||||||
$expected = Router::normalize('/');
|
$expected = Router::normalize('/');
|
||||||
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
|
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
|
||||||
|
|
||||||
$_SERVER['HTTP_REFERER'] = $backup;
|
|
||||||
$this->Controller->Session->delete('Auth');
|
$this->Controller->Session->delete('Auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,9 @@ class CookieComponentTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
$_COOKIE = array();
|
||||||
$Collection = new ComponentCollection();
|
$Collection = new ComponentCollection();
|
||||||
$this->Cookie = new CookieComponent($Collection);
|
$this->Cookie = $this->getMock('CookieComponent', array('_setcookie'), array($Collection));
|
||||||
$this->Controller = new CookieComponentTestController();
|
$this->Controller = new CookieComponentTestController();
|
||||||
$this->Cookie->initialize($this->Controller);
|
$this->Cookie->initialize($this->Controller);
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ class CookieComponentTest extends CakeTestCase {
|
||||||
$this->Cookie->domain = '';
|
$this->Cookie->domain = '';
|
||||||
$this->Cookie->secure = false;
|
$this->Cookie->secure = false;
|
||||||
$this->Cookie->key = 'somerandomhaskey';
|
$this->Cookie->key = 'somerandomhaskey';
|
||||||
|
|
||||||
$this->Cookie->startup($this->Controller);
|
$this->Cookie->startup($this->Controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +101,11 @@ class CookieComponentTest extends CakeTestCase {
|
||||||
$this->Cookie->destroy();
|
$this->Cookie->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets up some default cookie data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function _setCookieData() {
|
protected function _setCookieData() {
|
||||||
$this->Cookie->write(array('Encrytped_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!')));
|
$this->Cookie->write(array('Encrytped_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!')));
|
||||||
$this->Cookie->write(array('Encrytped_multi_cookies.name' => 'CakePHP'));
|
$this->Cookie->write(array('Encrytped_multi_cookies.name' => 'CakePHP'));
|
||||||
|
@ -172,6 +178,48 @@ class CookieComponentTest extends CakeTestCase {
|
||||||
$this->assertEqual($data, $expected);
|
$this->assertEqual($data, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test a simple write()
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testWriteSimple() {
|
||||||
|
$this->Cookie->expects($this->once())->method('_setcookie');
|
||||||
|
|
||||||
|
$this->Cookie->write('Testing', 'value');
|
||||||
|
$result = $this->Cookie->read('Testing');
|
||||||
|
|
||||||
|
$this->assertEquals('value', $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test write with httpOnly cookies
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testWriteHttpOnly() {
|
||||||
|
$this->Cookie->httpOnly = true;
|
||||||
|
$this->Cookie->secure = false;
|
||||||
|
$this->Cookie->expects($this->once())->method('_setcookie')
|
||||||
|
->with('CakeTestCookie[Testing]', 'value', time() + 10, '/', '', false, true);
|
||||||
|
|
||||||
|
$this->Cookie->write('Testing', 'value', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test delete with httpOnly
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testDeleteHttpOnly() {
|
||||||
|
$this->Cookie->httpOnly = true;
|
||||||
|
$this->Cookie->secure = false;
|
||||||
|
$this->Cookie->expects($this->once())->method('_setcookie')
|
||||||
|
->with('CakeTestCookie[Testing]', '', time() - 42000, '/', '', false, true);
|
||||||
|
|
||||||
|
$this->Cookie->delete('Testing', false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testWritePlainCookieArray
|
* testWritePlainCookieArray
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
* @since CakePHP(tm) v 1.2.0.5347
|
* @since CakePHP(tm) v 1.2.0.5347
|
||||||
* @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('Core', 'Controller');
|
||||||
App::import('Component', 'Email');
|
App::import('Component', 'Email');
|
||||||
App::import('Core', 'CakeSocket');
|
App::import('Core', 'CakeSocket');
|
||||||
|
|
||||||
|
@ -895,6 +896,7 @@ HTMLBLOC;
|
||||||
if ($this->skipIf($skip, 'Missing mb_* functions, cannot run test.')) {
|
if ($this->skipIf($skip, 'Missing mb_* functions, cannot run test.')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$restore = mb_internal_encoding();
|
||||||
mb_internal_encoding('ISO-8859-1');
|
mb_internal_encoding('ISO-8859-1');
|
||||||
|
|
||||||
$this->Controller->charset = 'UTF-8';
|
$this->Controller->charset = 'UTF-8';
|
||||||
|
@ -915,6 +917,8 @@ HTMLBLOC;
|
||||||
|
|
||||||
$result = mb_internal_encoding();
|
$result = mb_internal_encoding();
|
||||||
$this->assertEqual($result, 'ISO-8859-1');
|
$this->assertEqual($result, 'ISO-8859-1');
|
||||||
|
|
||||||
|
mb_internal_encoding($restore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -264,6 +264,27 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
$this->assertEqual($this->Controller->ext, '.ctp');
|
$this->assertEqual($this->Controller->ext, '.ctp');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testAutoAjaxLayout method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testAutoAjaxLayout() {
|
||||||
|
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||||
|
$this->RequestHandler->startup($this->Controller);
|
||||||
|
$this->assertEquals($this->Controller->layout, $this->RequestHandler->ajaxLayout);
|
||||||
|
|
||||||
|
$this->_init();
|
||||||
|
$this->Controller->request->query['ext'] = 'js';
|
||||||
|
$this->RequestHandler->initialize($this->Controller);
|
||||||
|
$this->RequestHandler->startup($this->Controller);
|
||||||
|
$this->assertNotEqual($this->Controller->layout, 'ajax');
|
||||||
|
|
||||||
|
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testStartupCallback method
|
* testStartupCallback method
|
||||||
*
|
*
|
||||||
|
|
|
@ -143,25 +143,26 @@ class SecurityComponentTest extends CakeTestCase {
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function startTest() {
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
$request = new CakeRequest('posts/index', false);
|
$request = new CakeRequest('posts/index', false);
|
||||||
$request->addParams(array('controller' => 'posts', 'action' => 'index'));
|
$request->addParams(array('controller' => 'posts', 'action' => 'index'));
|
||||||
$this->Controller = new SecurityTestController($request);
|
$this->Controller = new SecurityTestController($request);
|
||||||
$this->Controller->Components->init($this->Controller);
|
$this->Controller->Components->init($this->Controller);
|
||||||
$this->Controller->Security = $this->Controller->TestSecurity;
|
$this->Controller->Security = $this->Controller->TestSecurity;
|
||||||
$this->Controller->Security->blackHoleCallback = 'fail';
|
$this->Controller->Security->blackHoleCallback = 'fail';
|
||||||
$this->oldSalt = Configure::read('Security.salt');
|
|
||||||
Configure::write('Security.salt', 'foo!');
|
Configure::write('Security.salt', 'foo!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tear-down method. Resets environment state.
|
* Tear-down method. Resets environment state.
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function endTest() {
|
function tearDown() {
|
||||||
Configure::write('Security.salt', $this->oldSalt);
|
parent::tearDown();
|
||||||
$this->Controller->Session->delete('_Token');
|
$this->Controller->Session->delete('_Token');
|
||||||
unset($this->Controller->Security);
|
unset($this->Controller->Security);
|
||||||
unset($this->Controller->Component);
|
unset($this->Controller->Component);
|
||||||
|
|
|
@ -99,7 +99,7 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
Configure::write('Session', array(
|
Configure::write('Session', array(
|
||||||
'defaults' => 'php',
|
'defaults' => 'php',
|
||||||
'timeout' => 100,
|
'timeout' => 100,
|
||||||
'cookie' => 'test_suite'
|
'cookie' => 'test'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -445,12 +445,23 @@ class ControllerTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.post', 'core.comment', 'core.name');
|
public $fixtures = array('core.post', 'core.comment', 'core.name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest
|
* reset environment.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function setUp() {
|
||||||
|
App::objects('plugin', null, false);
|
||||||
|
App::build();
|
||||||
|
Router::reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* teardown
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function endTest() {
|
function teardown() {
|
||||||
App::build();
|
App::build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,6 +868,8 @@ class ControllerTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testFlash() {
|
function testFlash() {
|
||||||
$request = new CakeRequest('controller_posts/index');
|
$request = new CakeRequest('controller_posts/index');
|
||||||
|
$request->webroot = '/';
|
||||||
|
$request->base = '/';
|
||||||
|
|
||||||
$Controller = new Controller($request);
|
$Controller = new Controller($request);
|
||||||
$Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
$Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||||
|
@ -928,6 +941,13 @@ class ControllerTest extends CakeTestCase {
|
||||||
$expected = array('ModelName' => 'name', 'ModelName2' => 'name2');
|
$expected = array('ModelName' => 'name', 'ModelName2' => 'name2');
|
||||||
$Controller->set(array('ModelName', 'ModelName2'), array('name', 'name2'));
|
$Controller->set(array('ModelName', 'ModelName2'), array('name', 'name2'));
|
||||||
$this->assertIdentical($Controller->viewVars, $expected);
|
$this->assertIdentical($Controller->viewVars, $expected);
|
||||||
|
|
||||||
|
$Controller->viewVars = array();
|
||||||
|
$Controller->set(array(3 => 'three', 4 => 'four'));
|
||||||
|
$Controller->set(array(1 => 'one', 2 => 'two'));
|
||||||
|
$expected = array(3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two');
|
||||||
|
$this->assertEqual($Controller->viewVars, $expected);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -953,6 +973,7 @@ class ControllerTest extends CakeTestCase {
|
||||||
$this->assertPattern('/this is the test element/', $result);
|
$this->assertPattern('/this is the test element/', $result);
|
||||||
|
|
||||||
$Controller = new TestController($request);
|
$Controller = new TestController($request);
|
||||||
|
$Controller->helpers = array('Html');
|
||||||
$Controller->constructClasses();
|
$Controller->constructClasses();
|
||||||
$Controller->ControllerComment->validationErrors = array('title' => 'tooShort');
|
$Controller->ControllerComment->validationErrors = array('title' => 'tooShort');
|
||||||
$expected = $Controller->ControllerComment->validationErrors;
|
$expected = $Controller->ControllerComment->validationErrors;
|
||||||
|
|
|
@ -275,14 +275,16 @@ class ScaffoldViewTest extends CakeTestCase {
|
||||||
public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag');
|
public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function startTest() {
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->request = new CakeRequest(null, false);
|
$this->request = new CakeRequest(null, false);
|
||||||
$this->Controller = new ScaffoldMockController($this->request);
|
$this->Controller = new ScaffoldMockController($this->request);
|
||||||
|
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||||
|
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
|
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
|
||||||
|
@ -291,15 +293,13 @@ class ScaffoldViewTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* teardown method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function endTest() {
|
function tearDown() {
|
||||||
unset($this->Controller);
|
parent::tearDown();
|
||||||
|
unset($this->Controller, $this->request);
|
||||||
App::build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -579,23 +579,21 @@ class ScaffoldViewTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testAdminEditScaffold() {
|
function testAdminEditScaffold() {
|
||||||
$_backAdmin = Configure::read('Routing.prefixes');
|
|
||||||
|
|
||||||
Configure::write('Routing.prefixes', array('admin'));
|
Configure::write('Routing.prefixes', array('admin'));
|
||||||
$params = array(
|
$params = array(
|
||||||
'plugin' => null,
|
'plugin' => null,
|
||||||
'pass' => array(),
|
'pass' => array(1),
|
||||||
'form' => array(),
|
'form' => array(),
|
||||||
'named' => array(),
|
'named' => array(),
|
||||||
'prefix' => 'admin',
|
'prefix' => 'admin',
|
||||||
'url' => array('url' =>'admin/scaffold_mock/edit'),
|
'url' => array('url' =>'admin/scaffold_mock/edit/1'),
|
||||||
'controller' => 'scaffold_mock',
|
'controller' => 'scaffold_mock',
|
||||||
'action' => 'admin_edit',
|
'action' => 'admin_edit',
|
||||||
'admin' => 1,
|
'admin' => 1,
|
||||||
);
|
);
|
||||||
$this->Controller->request->base = '';
|
$this->Controller->request->base = '';
|
||||||
$this->Controller->request->webroot = '/';
|
$this->Controller->request->webroot = '/';
|
||||||
$this->Controller->request->here = '/admin/scaffold_mock/edit';
|
$this->Controller->request->here = '/admin/scaffold_mock/edit/1';
|
||||||
$this->Controller->request->addParams($params);
|
$this->Controller->request->addParams($params);
|
||||||
|
|
||||||
//reset, and set router.
|
//reset, and set router.
|
||||||
|
@ -611,8 +609,6 @@ class ScaffoldViewTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->assertPattern('#admin/scaffold_mock/edit/1#', $result);
|
$this->assertPattern('#admin/scaffold_mock/edit/1#', $result);
|
||||||
$this->assertPattern('#Scaffold Mock#', $result);
|
$this->assertPattern('#Scaffold Mock#', $result);
|
||||||
|
|
||||||
Configure::write('Routing.prefixes', $_backAdmin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -686,23 +682,24 @@ class ScaffoldTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag');
|
public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag');
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function startTest() {
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$request = new CakeRequest(null, false);
|
$request = new CakeRequest(null, false);
|
||||||
$this->Controller = new ScaffoldMockController($request);
|
$this->Controller = new ScaffoldMockController($request);
|
||||||
|
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* tearDown method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function endTest() {
|
function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Controller);
|
unset($this->Controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,9 +773,6 @@ class ScaffoldTest extends CakeTestCase {
|
||||||
$this->assertEqual($result['pluralVar'], 'scaffoldMock');
|
$this->assertEqual($result['pluralVar'], 'scaffoldMock');
|
||||||
$this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
|
$this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
|
||||||
}
|
}
|
||||||
function getTests() {
|
|
||||||
return array('start', 'startCase', 'testScaffoldChangingViewProperty', 'endCase', 'end');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that Scaffold overrides the view property even if its set to 'Theme'
|
* test that Scaffold overrides the view property even if its set to 'Theme'
|
||||||
|
@ -875,6 +869,8 @@ class ScaffoldTest extends CakeTestCase {
|
||||||
function testEditScaffoldWithScaffoldFields() {
|
function testEditScaffoldWithScaffoldFields() {
|
||||||
$request = new CakeRequest(null, false);
|
$request = new CakeRequest(null, false);
|
||||||
$this->Controller = new ScaffoldMockControllerWithFields($request);
|
$this->Controller = new ScaffoldMockControllerWithFields($request);
|
||||||
|
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'plugin' => null,
|
'plugin' => null,
|
||||||
'pass' => array(1),
|
'pass' => array(1),
|
||||||
|
|
|
@ -218,14 +218,9 @@ class DebuggerTest extends CakeTestCase {
|
||||||
$result = Debugger::exportVar($View);
|
$result = Debugger::exportVar($View);
|
||||||
$expected = 'View
|
$expected = 'View
|
||||||
View::$Helpers = HelperCollection object
|
View::$Helpers = HelperCollection object
|
||||||
View::$base = NULL
|
|
||||||
View::$here = NULL
|
|
||||||
View::$plugin = NULL
|
View::$plugin = NULL
|
||||||
View::$name = ""
|
View::$name = ""
|
||||||
View::$action = NULL
|
|
||||||
View::$params = array
|
|
||||||
View::$passedArgs = array
|
View::$passedArgs = array
|
||||||
View::$data = array
|
|
||||||
View::$helpers = array
|
View::$helpers = array
|
||||||
View::$viewPath = ""
|
View::$viewPath = ""
|
||||||
View::$viewVars = array
|
View::$viewVars = array
|
||||||
|
@ -247,7 +242,6 @@ class DebuggerTest extends CakeTestCase {
|
||||||
View::$modelId = NULL
|
View::$modelId = NULL
|
||||||
View::$uuids = array
|
View::$uuids = array
|
||||||
View::$output = false
|
View::$output = false
|
||||||
View::$webroot = NULL
|
|
||||||
View::$request = NULL';
|
View::$request = NULL';
|
||||||
$result = str_replace(array("\t", "\r\n", "\n"), "", strtolower($result));
|
$result = str_replace(array("\t", "\r\n", "\n"), "", strtolower($result));
|
||||||
$expected = str_replace(array("\t", "\r\n", "\n"), "", strtolower($expected));
|
$expected = str_replace(array("\t", "\r\n", "\n"), "", strtolower($expected));
|
||||||
|
|
|
@ -44,52 +44,6 @@ class AuthBlueberryUser extends CakeTestModel {
|
||||||
*/
|
*/
|
||||||
public $useTable = false;
|
public $useTable = false;
|
||||||
}
|
}
|
||||||
if (!class_exists('AppController')) {
|
|
||||||
/**
|
|
||||||
* AppController class
|
|
||||||
*
|
|
||||||
* @package cake
|
|
||||||
* @subpackage cake.tests.cases.libs
|
|
||||||
*/
|
|
||||||
class AppController extends Controller {
|
|
||||||
/**
|
|
||||||
* components property
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public $components = array('Blueberry');
|
|
||||||
/**
|
|
||||||
* beforeRender method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function beforeRender() {
|
|
||||||
echo $this->Blueberry->testName;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* header method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function header($header) {
|
|
||||||
echo $header;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* _stop method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function _stop($status = 0) {
|
|
||||||
echo 'Stopped with status: ' . $status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif (!defined('APP_CONTROLLER_EXISTS')){
|
|
||||||
define('APP_CONTROLLER_EXISTS', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BlueberryComponent class
|
* BlueberryComponent class
|
||||||
|
@ -124,7 +78,7 @@ class BlueberryComponent extends Component {
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs
|
* @subpackage cake.tests.cases.libs
|
||||||
*/
|
*/
|
||||||
class TestErrorController extends AppController {
|
class TestErrorController extends Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uses property
|
* uses property
|
||||||
|
@ -134,6 +88,24 @@ class TestErrorController extends AppController {
|
||||||
*/
|
*/
|
||||||
public $uses = array();
|
public $uses = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* components property
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public $components = array('Blueberry');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* beforeRender method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function beforeRender() {
|
||||||
|
echo $this->Blueberry->testName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* index method
|
* index method
|
||||||
*
|
*
|
||||||
|
@ -146,31 +118,6 @@ class TestErrorController extends AppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* BlueberryController class
|
|
||||||
*
|
|
||||||
* @package cake
|
|
||||||
* @subpackage cake.tests.cases.libs
|
|
||||||
*/
|
|
||||||
class BlueberryController extends AppController {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* name property
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public $name = 'BlueberryController';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* uses property
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public $uses = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MyCustomErrorHandler class
|
* MyCustomErrorHandler class
|
||||||
*
|
*
|
||||||
|
@ -204,31 +151,45 @@ class MissingWidgetThingException extends NotFoundException { }
|
||||||
*/
|
*/
|
||||||
class ErrorHandlerTest extends CakeTestCase {
|
class ErrorHandlerTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
|
||||||
* skip method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function skip() {
|
|
||||||
$this->skipIf(PHP_SAPI === 'cli', '%s Cannot be run from console');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setup create a request object to get out of router later.
|
* setup create a request object to get out of router later.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
App::build(array(
|
||||||
|
'views' => array(
|
||||||
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS,
|
||||||
|
TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS
|
||||||
|
)
|
||||||
|
), true);
|
||||||
|
Router::reload();
|
||||||
|
|
||||||
$request = new CakeRequest(null, false);
|
$request = new CakeRequest(null, false);
|
||||||
$request->base = '';
|
$request->base = '';
|
||||||
Router::setRequestInfo($request);
|
Router::setRequestInfo($request);
|
||||||
$this->_debug = Configure::read('debug');
|
$this->_debug = Configure::read('debug');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* teardown
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
function teardown() {
|
function teardown() {
|
||||||
Configure::write('debug', $this->_debug);
|
Configure::write('debug', $this->_debug);
|
||||||
}
|
App::build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mocks out the response on the errorhandler object so headers aren't modified.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function _mockResponse($error) {
|
||||||
|
$error->controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test handleException generating a page.
|
* test handleException generating a page.
|
||||||
|
@ -239,6 +200,9 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
if ($this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.')) {
|
if ($this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($this->skipIf(PHP_SAPI == 'cli', 'This integration test can not be run in cli.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$error = new NotFoundException('Kaboom!');
|
$error = new NotFoundException('Kaboom!');
|
||||||
ob_start();
|
ob_start();
|
||||||
ErrorHandler::handleException($error);
|
ErrorHandler::handleException($error);
|
||||||
|
@ -256,7 +220,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
Configure::write('debug', 2);
|
Configure::write('debug', 2);
|
||||||
|
|
||||||
$exception = new MissingWidgetThingException('Widget not found');
|
$exception = new MissingWidgetThingException('Widget not found');
|
||||||
$ErrorHandler = new MyCustomErrorHandler($exception);
|
$ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception));
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$ErrorHandler->render();
|
$ErrorHandler->render();
|
||||||
|
@ -273,7 +237,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
function testSubclassMethodsNotBeingConvertedDebug0() {
|
function testSubclassMethodsNotBeingConvertedDebug0() {
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 0);
|
||||||
$exception = new MissingWidgetThingException('Widget not found');
|
$exception = new MissingWidgetThingException('Widget not found');
|
||||||
$ErrorHandler = new MyCustomErrorHandler($exception);
|
$ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception));
|
||||||
|
|
||||||
$this->assertEqual('missingWidgetThing', $ErrorHandler->method);
|
$this->assertEqual('missingWidgetThing', $ErrorHandler->method);
|
||||||
|
|
||||||
|
@ -293,7 +257,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 0);
|
||||||
|
|
||||||
$exception = new MissingControllerException('PostsController');
|
$exception = new MissingControllerException('PostsController');
|
||||||
$ErrorHandler = new MyCustomErrorHandler($exception);
|
$ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception));
|
||||||
|
|
||||||
$this->assertEqual('error400', $ErrorHandler->method);
|
$this->assertEqual('error400', $ErrorHandler->method);
|
||||||
|
|
||||||
|
@ -341,7 +305,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
function testUnknownExceptionTypeWithExceptionThatHasA400Code() {
|
function testUnknownExceptionTypeWithExceptionThatHasA400Code() {
|
||||||
$exception = new MissingWidgetThingException('coding fail.');
|
$exception = new MissingWidgetThingException('coding fail.');
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = new ErrorHandler($exception);
|
||||||
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode'));
|
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader'));
|
||||||
$ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(404);
|
$ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(404);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
@ -360,7 +324,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
function testUnknownExceptionTypeWithNoCodeIsA500() {
|
function testUnknownExceptionTypeWithNoCodeIsA500() {
|
||||||
$exception = new OutOfBoundsException('foul ball.');
|
$exception = new OutOfBoundsException('foul ball.');
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = new ErrorHandler($exception);
|
||||||
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode'));
|
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader'));
|
||||||
$ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(500);
|
$ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(500);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
@ -376,10 +340,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testerror400() {
|
function testError400() {
|
||||||
App::build(array(
|
|
||||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)
|
|
||||||
), true);
|
|
||||||
Router::reload();
|
Router::reload();
|
||||||
|
|
||||||
$request = new CakeRequest('posts/view/1000', false);
|
$request = new CakeRequest('posts/view/1000', false);
|
||||||
|
@ -387,7 +348,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
|
|
||||||
$exception = new NotFoundException('Custom message');
|
$exception = new NotFoundException('Custom message');
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = new ErrorHandler($exception);
|
||||||
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode'));
|
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader'));
|
||||||
$ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(404);
|
$ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(404);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
@ -396,8 +357,6 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->assertPattern('/<h2>Custom message<\/h2>/', $result);
|
$this->assertPattern('/<h2>Custom message<\/h2>/', $result);
|
||||||
$this->assertPattern("/<strong>'\/posts\/view\/1000'<\/strong>/", $result);
|
$this->assertPattern("/<strong>'\/posts\/view\/1000'<\/strong>/", $result);
|
||||||
|
|
||||||
App::build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -409,7 +368,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 0);
|
||||||
|
|
||||||
$exception = new NotFoundException('Custom message');
|
$exception = new NotFoundException('Custom message');
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$ErrorHandler->render();
|
$ErrorHandler->render();
|
||||||
|
@ -417,7 +376,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
$this->assertContains('Custom message', $result);
|
$this->assertContains('Custom message', $result);
|
||||||
|
|
||||||
$exception = new MissingActionException(array('controller' => 'PostsController', 'action' => 'index'));
|
$exception = new MissingActionException(array('controller' => 'PostsController', 'action' => 'index'));
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$ErrorHandler->render();
|
$ErrorHandler->render();
|
||||||
|
@ -436,7 +395,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
Router::setRequestInfo($request);
|
Router::setRequestInfo($request);
|
||||||
|
|
||||||
$exception = new NotFoundException('Custom message');
|
$exception = new NotFoundException('Custom message');
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$ErrorHandler->render();
|
$ErrorHandler->render();
|
||||||
|
@ -455,7 +414,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
function testError500Message() {
|
function testError500Message() {
|
||||||
$exception = new InternalErrorException('An Internal Error Has Occurred');
|
$exception = new InternalErrorException('An Internal Error Has Occurred');
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = new ErrorHandler($exception);
|
||||||
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode'));
|
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader'));
|
||||||
$ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(500);
|
$ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(500);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
@ -472,10 +431,8 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testMissingController() {
|
function testMissingController() {
|
||||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController');
|
|
||||||
|
|
||||||
$exception = new MissingControllerException(array('controller' => 'PostsController'));
|
$exception = new MissingControllerException(array('controller' => 'PostsController'));
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$ErrorHandler->render();
|
$ErrorHandler->render();
|
||||||
|
@ -483,20 +440,8 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->assertPattern('/<h2>Missing Controller<\/h2>/', $result);
|
$this->assertPattern('/<h2>Missing Controller<\/h2>/', $result);
|
||||||
$this->assertPattern('/<em>PostsController<\/em>/', $result);
|
$this->assertPattern('/<em>PostsController<\/em>/', $result);
|
||||||
$this->assertPattern('/BlueberryComponent/', $result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO: Integration test that needs to be moved
|
|
||||||
ob_start();
|
|
||||||
$dispatcher = new Dispatcher('/blueberry/inexistent');
|
|
||||||
$result = ob_get_clean();
|
|
||||||
$this->assertPattern('/<h2>Missing Method in BlueberryController<\/h2>/', $result);
|
|
||||||
$this->assertPattern('/<em>BlueberryController::<\/em><em>inexistent\(\)<\/em>/', $result);
|
|
||||||
$this->assertNoPattern('/Location: (.*)\/users\/login/', $result);
|
|
||||||
$this->assertNoPattern('/Stopped with status: 0/', $result);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of tests to run for the various CakeException classes.
|
* Returns an array of tests to run for the various CakeException classes.
|
||||||
*
|
*
|
||||||
|
@ -624,7 +569,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testCakeExceptionHandling($exception, $patterns, $code) {
|
function testCakeExceptionHandling($exception, $patterns, $code) {
|
||||||
$ErrorHandler = new ErrorHandler($exception);
|
$ErrorHandler = new ErrorHandler($exception);
|
||||||
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode'));
|
$ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader'));
|
||||||
$ErrorHandler->controller->response->expects($this->once())
|
$ErrorHandler->controller->response->expects($this->once())
|
||||||
->method('statusCode')
|
->method('statusCode')
|
||||||
->with($code);
|
->with($code);
|
||||||
|
|
|
@ -54,6 +54,50 @@ class I18nTest extends CakeTestCase {
|
||||||
App::objects('plugin', null, false);
|
App::objects('plugin', null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testTranslationCaching() {
|
||||||
|
Configure::write('Config.language', 'cache_test_po');
|
||||||
|
$i18n =& i18n::getInstance();
|
||||||
|
|
||||||
|
// reset internally stored entries
|
||||||
|
I18n::clear();
|
||||||
|
|
||||||
|
Cache::clear(false, '_cake_core_');
|
||||||
|
$lang = Configure::read('Config.language');#$i18n->l10n->locale;
|
||||||
|
|
||||||
|
Cache::config('_cake_core_', Cache::config('default'));
|
||||||
|
|
||||||
|
// make some calls to translate using different domains
|
||||||
|
$this->assertEqual(I18n::translate('dom1.foo', false, 'dom1'), 'Dom 1 Foo');
|
||||||
|
$this->assertEqual(I18n::translate('dom1.bar', false, 'dom1'), 'Dom 1 Bar');
|
||||||
|
$domains = I18n::domains();
|
||||||
|
$this->assertEqual($domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo'], 'Dom 1 Foo');
|
||||||
|
|
||||||
|
// reset internally stored entries
|
||||||
|
I18n::clear();
|
||||||
|
|
||||||
|
// now only dom1 should be in cache
|
||||||
|
$cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
|
||||||
|
$this->assertEqual($cachedDom1['LC_MESSAGES']['dom1.foo'], 'Dom 1 Foo');
|
||||||
|
$this->assertEqual($cachedDom1['LC_MESSAGES']['dom1.bar'], 'Dom 1 Bar');
|
||||||
|
// dom2 not in cache
|
||||||
|
$this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
|
||||||
|
|
||||||
|
// translate a item of dom2 (adds dom2 to cache)
|
||||||
|
$this->assertEqual(I18n::translate('dom2.foo', false, 'dom2'), 'Dom 2 Foo');
|
||||||
|
|
||||||
|
// verify dom2 was cached through manual read from cache
|
||||||
|
$cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
|
||||||
|
$this->assertEqual($cachedDom2['LC_MESSAGES']['dom2.foo'], 'Dom 2 Foo');
|
||||||
|
$this->assertEqual($cachedDom2['LC_MESSAGES']['dom2.bar'], 'Dom 2 Bar');
|
||||||
|
|
||||||
|
// modify cache entry manually to verify that dom1 entries now will be read from cache
|
||||||
|
$cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
|
||||||
|
Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
|
||||||
|
$this->assertEqual(I18n::translate('dom1.foo', false, 'dom1'), 'FOO');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testDefaultStrings method
|
* testDefaultStrings method
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,12 +35,14 @@ App::import('Core', 'Inflector');
|
||||||
class InflectorTest extends CakeTestCase {
|
class InflectorTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inflector property
|
* teardown
|
||||||
*
|
*
|
||||||
* @var mixed null
|
* @return void
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $Inflector = null;
|
function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
|
Inflector::reset();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testInflectingSingulars method
|
* testInflectingSingulars method
|
||||||
|
|
|
@ -918,23 +918,23 @@ class BehaviorCollectionTest extends CakeTestCase {
|
||||||
$this->assertIdentical($Apple->delete(4), false);
|
$this->assertIdentical($Apple->delete(4), false);
|
||||||
|
|
||||||
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'test2'));
|
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'test2'));
|
||||||
if (ob_start()) {
|
|
||||||
$results = $Apple->delete(4);
|
ob_start();
|
||||||
$this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success (cascading)');
|
$results = $Apple->delete(4);
|
||||||
$this->assertIdentical($results, true);
|
$this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success (cascading)');
|
||||||
}
|
$this->assertIdentical($results, true);
|
||||||
if (ob_start()) {
|
|
||||||
$results = $Apple->delete(3, false);
|
ob_start();
|
||||||
$this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success');
|
$results = $Apple->delete(3, false);
|
||||||
$this->assertIdentical($results, true);
|
$this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success');
|
||||||
}
|
$this->assertIdentical($results, true);
|
||||||
|
|
||||||
|
|
||||||
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on'));
|
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on'));
|
||||||
if (ob_start()) {
|
ob_start();
|
||||||
$results = $Apple->delete(2, false);
|
$results = $Apple->delete(2, false);
|
||||||
$this->assertIdentical(trim(ob_get_clean()), 'afterDelete success');
|
$this->assertIdentical(trim(ob_get_clean()), 'afterDelete success');
|
||||||
$this->assertIdentical($results, true);
|
$this->assertIdentical($results, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testBehaviorOnErrorCallback method
|
* testBehaviorOnErrorCallback method
|
||||||
|
@ -946,15 +946,9 @@ class BehaviorCollectionTest extends CakeTestCase {
|
||||||
$Apple = new Apple();
|
$Apple = new Apple();
|
||||||
|
|
||||||
$Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'onError' => 'on'));
|
$Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'onError' => 'on'));
|
||||||
if (ob_start()) {
|
ob_start();
|
||||||
$Apple->Behaviors->Test->onError($Apple);
|
$Apple->Behaviors->Test->onError($Apple);
|
||||||
$this->assertIdentical(trim(ob_get_clean()), 'onError trigger success');
|
$this->assertIdentical(trim(ob_get_clean()), 'onError trigger success');
|
||||||
}
|
|
||||||
|
|
||||||
if (ob_start()) {
|
|
||||||
$Apple->delete(99);
|
|
||||||
//$this->assertIdentical(trim(ob_get_clean()), 'onError trigger success');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testBehaviorValidateCallback method
|
* testBehaviorValidateCallback method
|
||||||
|
|
|
@ -222,7 +222,7 @@ class AclBehaviorTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
Configure::write('Acl.database', 'test_suite');
|
Configure::write('Acl.database', 'test');
|
||||||
|
|
||||||
$this->Aco = new Aco();
|
$this->Aco = new Aco();
|
||||||
$this->Aro = new Aro();
|
$this->Aro = new Aro();
|
||||||
|
@ -347,7 +347,7 @@ class AclBehaviorTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->Aro->save($aroData);
|
$this->Aro->save($aroData);
|
||||||
|
|
||||||
$Person =& new AclPerson();
|
$Person = new AclPerson();
|
||||||
$data = array(
|
$data = array(
|
||||||
'AclPerson' => array(
|
'AclPerson' => array(
|
||||||
'name' => 'Trent',
|
'name' => 'Trent',
|
||||||
|
|
|
@ -39,10 +39,10 @@ class MyAppSchema extends CakeSchema {
|
||||||
/**
|
/**
|
||||||
* connection property
|
* connection property
|
||||||
*
|
*
|
||||||
* @var string 'test_suite'
|
* @var string 'test'
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public $connection = 'test_suite';
|
public $connection = 'test';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* comments property
|
* comments property
|
||||||
|
@ -519,23 +519,22 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
/**
|
/**
|
||||||
* setUp method
|
* setUp method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function startTest() {
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Schema = new TestAppSchema();
|
$this->Schema = new TestAppSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tearDown method
|
* tearDown method
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
@unlink(TMP . 'tests' . DS .'schema.php');
|
@unlink(TMP . 'tests' . DS .'schema.php');
|
||||||
unset($this->Schema);
|
unset($this->Schema);
|
||||||
ClassRegistry::flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -563,16 +562,18 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testSchemaRead() {
|
function testSchemaRead() {
|
||||||
$read = $this->Schema->read(array(
|
$read = $this->Schema->read(array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'name' => 'TestApp',
|
'name' => 'TestApp',
|
||||||
'models' => array('SchemaPost', 'SchemaComment', 'SchemaTag', 'SchemaDatatype')
|
'models' => array('SchemaPost', 'SchemaComment', 'SchemaTag', 'SchemaDatatype')
|
||||||
));
|
));
|
||||||
unset($read['tables']['missing']);
|
unset($read['tables']['missing']);
|
||||||
|
|
||||||
$expected = array('comments', 'datatypes', 'posts', 'posts_tags', 'tags');
|
$expected = array('comments', 'datatypes', 'posts', 'posts_tags', 'tags');
|
||||||
$this->assertEqual(array_keys($read['tables']), $expected);
|
foreach ($expected as $table) {
|
||||||
foreach ($read['tables'] as $table => $fields) {
|
$this->assertTrue(isset($read['tables'][$table]), 'Missing table ' . $table);
|
||||||
$this->assertEqual(array_keys($fields), array_keys($this->Schema->tables[$table]));
|
}
|
||||||
|
foreach ($this->Schema->tables as $table => $fields) {
|
||||||
|
$this->assertEqual(array_keys($fields), array_keys($read['tables'][$table]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEqual(
|
$this->assertEqual(
|
||||||
|
@ -580,7 +581,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
$this->Schema->tables['datatypes']['float_field']
|
$this->Schema->tables['datatypes']['float_field']
|
||||||
);
|
);
|
||||||
|
|
||||||
$db =& ConnectionManager::getDataSource('test_suite');
|
$db =& ConnectionManager::getDataSource('test');
|
||||||
$config = $db->config;
|
$config = $db->config;
|
||||||
$config['prefix'] = 'schema_test_prefix_';
|
$config['prefix'] = 'schema_test_prefix_';
|
||||||
ConnectionManager::create('schema_prefix', $config);
|
ConnectionManager::create('schema_prefix', $config);
|
||||||
|
@ -591,14 +592,14 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
$SchemaPost->table = 'sts';
|
$SchemaPost->table = 'sts';
|
||||||
$SchemaPost->tablePrefix = 'po';
|
$SchemaPost->tablePrefix = 'po';
|
||||||
$read = $this->Schema->read(array(
|
$read = $this->Schema->read(array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'name' => 'TestApp',
|
'name' => 'TestApp',
|
||||||
'models' => array('SchemaPost')
|
'models' => array('SchemaPost')
|
||||||
));
|
));
|
||||||
$this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s');
|
$this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s');
|
||||||
|
|
||||||
$read = $this->Schema->read(array(
|
$read = $this->Schema->read(array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'name' => 'TestApp',
|
'name' => 'TestApp',
|
||||||
'models' => array('SchemaComment', 'SchemaTag', 'SchemaPost')
|
'models' => array('SchemaComment', 'SchemaTag', 'SchemaPost')
|
||||||
));
|
));
|
||||||
|
@ -615,7 +616,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
|
|
||||||
$Schema =& new CakeSchema();
|
$Schema =& new CakeSchema();
|
||||||
$read = $Schema->read(array(
|
$read = $Schema->read(array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'name' => 'TestApp',
|
'name' => 'TestApp',
|
||||||
'models' => array('SchemaPrefixAuthUser')
|
'models' => array('SchemaPrefixAuthUser')
|
||||||
));
|
));
|
||||||
|
@ -638,7 +639,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
$Schema =& new CakeSchema();
|
$Schema =& new CakeSchema();
|
||||||
$Schema->plugin = 'TestPlugin';
|
$Schema->plugin = 'TestPlugin';
|
||||||
$read = $Schema->read(array(
|
$read = $Schema->read(array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'name' => 'TestApp',
|
'name' => 'TestApp',
|
||||||
'models' => true
|
'models' => true
|
||||||
));
|
));
|
||||||
|
@ -647,7 +648,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
$this->assertTrue(isset($read['tables']['authors']));
|
$this->assertTrue(isset($read['tables']['authors']));
|
||||||
$this->assertTrue(isset($read['tables']['test_plugin_comments']));
|
$this->assertTrue(isset($read['tables']['test_plugin_comments']));
|
||||||
$this->assertTrue(isset($read['tables']['posts']));
|
$this->assertTrue(isset($read['tables']['posts']));
|
||||||
$this->assertEqual(count($read['tables']), 4);
|
$this->assertTrue(count($read['tables']) >= 4);
|
||||||
|
|
||||||
App::build();
|
App::build();
|
||||||
}
|
}
|
||||||
|
@ -675,7 +676,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
$fixture->insert($db2);
|
$fixture->insert($db2);
|
||||||
|
|
||||||
$read = $this->Schema->read(array(
|
$read = $this->Schema->read(array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'name' => 'TestApp',
|
'name' => 'TestApp',
|
||||||
'models' => array('SchemaCrossDatabase', 'SchemaPost')
|
'models' => array('SchemaCrossDatabase', 'SchemaPost')
|
||||||
));
|
));
|
||||||
|
@ -701,7 +702,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testGenerateTable() {
|
function testGenerateTable() {
|
||||||
$fields = array(
|
$posts = array(
|
||||||
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
|
||||||
'author_id' => array('type' => 'integer', 'null' => false),
|
'author_id' => array('type' => 'integer', 'null' => false),
|
||||||
'title' => array('type' => 'string', 'null' => false),
|
'title' => array('type' => 'string', 'null' => false),
|
||||||
|
@ -711,11 +712,8 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
'updated' => array('type' => 'datetime', 'null' => true, 'default' => null),
|
'updated' => array('type' => 'datetime', 'null' => true, 'default' => null),
|
||||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
|
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
|
||||||
);
|
);
|
||||||
$result = $this->Schema->generateTable('posts', $fields);
|
$result = $this->Schema->generateTable('posts', $posts);
|
||||||
$this->assertPattern('/var \$posts/', $result);
|
$this->assertPattern('/var \$posts/', $result);
|
||||||
|
|
||||||
eval(substr($result, 4));
|
|
||||||
$this->assertEqual($posts, $fields);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSchemaWrite method
|
* testSchemaWrite method
|
||||||
|
@ -940,11 +938,11 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testSchemaCreateTable() {
|
function testSchemaCreateTable() {
|
||||||
$db =& ConnectionManager::getDataSource('test_suite');
|
$db =& ConnectionManager::getDataSource('test');
|
||||||
$db->cacheSources = false;
|
$db->cacheSources = false;
|
||||||
|
|
||||||
$Schema =& new CakeSchema(array(
|
$Schema =& new CakeSchema(array(
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'testdescribes' => array(
|
'testdescribes' => array(
|
||||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
'int_null' => array('type' => 'integer', 'null' => true),
|
'int_null' => array('type' => 'integer', 'null' => true),
|
||||||
|
|
|
@ -67,7 +67,7 @@ class ConnectionManagerTest extends CakeTestCase {
|
||||||
$sources = ConnectionManager::enumConnectionObjects();
|
$sources = ConnectionManager::enumConnectionObjects();
|
||||||
$this->assertTrue(count($sources) >= 1);
|
$this->assertTrue(count($sources) >= 1);
|
||||||
|
|
||||||
$connections = array('default', 'test', 'test_suite');
|
$connections = array('default', 'test', 'test');
|
||||||
$this->assertTrue(count(array_intersect(array_keys($sources), $connections)) >= 1);
|
$this->assertTrue(count(array_intersect(array_keys($sources), $connections)) >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ class ConnectionManagerTest extends CakeTestCase {
|
||||||
$sources = ConnectionManager::sourceList();
|
$sources = ConnectionManager::sourceList();
|
||||||
$this->assertTrue(count($sources) >= 1);
|
$this->assertTrue(count($sources) >= 1);
|
||||||
|
|
||||||
$connections = array('default', 'test', 'test_suite');
|
$connections = array('default', 'test', 'test');
|
||||||
$this->assertTrue(count(array_intersect($sources, $connections)) >= 1);
|
$this->assertTrue(count(array_intersect($sources, $connections)) >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,7 +328,7 @@ class DboMssqlTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$db = ConnectionManager::getDataSource('test_suite');
|
$db = ConnectionManager::getDataSource('test');
|
||||||
$this->db = new DboMssqlTestDb($db->config);
|
$this->db = new DboMssqlTestDb($db->config);
|
||||||
$this->model = new MssqlTestModel();
|
$this->model = new MssqlTestModel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ class DboMysqlTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$this->Dbo = ConnectionManager::getDataSource('test_suite');
|
$this->Dbo = ConnectionManager::getDataSource('test');
|
||||||
if ($this->Dbo->config['driver'] !== 'mysql') {
|
if ($this->Dbo->config['driver'] !== 'mysql') {
|
||||||
$this->markTestSkipped('The MySQL extension is not available.');
|
$this->markTestSkipped('The MySQL extension is not available.');
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ class DboMysqlTest extends CakeTestCase {
|
||||||
$this->Dbo->query('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
|
$this->Dbo->query('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
|
||||||
|
|
||||||
$this->model = new CakeTestModel(array(
|
$this->model = new CakeTestModel(array(
|
||||||
'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test_suite'
|
'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test'
|
||||||
));
|
));
|
||||||
|
|
||||||
$result = $this->model->schema();
|
$result = $this->model->schema();
|
||||||
|
@ -561,7 +561,7 @@ class DboMysqlTest extends CakeTestCase {
|
||||||
|
|
||||||
$schema1 = new CakeSchema(array(
|
$schema1 = new CakeSchema(array(
|
||||||
'name' => 'AlterTest1',
|
'name' => 'AlterTest1',
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'altertest' => array(
|
'altertest' => array(
|
||||||
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
||||||
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
||||||
|
@ -572,7 +572,7 @@ class DboMysqlTest extends CakeTestCase {
|
||||||
|
|
||||||
$schema2 = new CakeSchema(array(
|
$schema2 = new CakeSchema(array(
|
||||||
'name' => 'AlterTest2',
|
'name' => 'AlterTest2',
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'altertest' => array(
|
'altertest' => array(
|
||||||
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
||||||
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
||||||
|
@ -592,7 +592,7 @@ class DboMysqlTest extends CakeTestCase {
|
||||||
// Change three indexes, delete one and add another one
|
// Change three indexes, delete one and add another one
|
||||||
$schema3 = new CakeSchema(array(
|
$schema3 = new CakeSchema(array(
|
||||||
'name' => 'AlterTest3',
|
'name' => 'AlterTest3',
|
||||||
'connection' => 'test_suite',
|
'connection' => 'test',
|
||||||
'altertest' => array(
|
'altertest' => array(
|
||||||
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
||||||
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
||||||
|
@ -633,7 +633,7 @@ class DboMysqlTest extends CakeTestCase {
|
||||||
|