diff --git a/cake/console/cake.php b/cake/console/cake.php
index 472987c46..ef32c7538 100644
--- a/cake/console/cake.php
+++ b/cake/console/cake.php
@@ -264,6 +264,9 @@ class ShellDispatcher {
include_once CORE_PATH . 'cake' . DS . 'console' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php';
App::build();
}
+ if (!defined('FULL_BASE_URL')) {
+ define('FULL_BASE_URL', '/');
+ }
return true;
}
diff --git a/cake/console/libs/tasks/template.php b/cake/console/libs/tasks/template.php
index 7a93c0f48..7225ce92c 100644
--- a/cake/console/libs/tasks/template.php
+++ b/cake/console/libs/tasks/template.php
@@ -115,10 +115,7 @@ class TemplateTask extends Shell {
if ($data == null) {
return false;
}
-
- foreach ($data as $name => $value) {
- $this->templateVars[$name] = $value;
- }
+ $this->templateVars = $data + $this->templateVars;
}
/**
diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php
index 2e76e74fb..e4e63449b 100644
--- a/cake/console/libs/tasks/view.php
+++ b/cake/console/libs/tasks/view.php
@@ -344,7 +344,7 @@ class ViewTask extends BakeTask {
$this->hr();
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
if (strtolower($looksGood) == 'y') {
- $this->bake($action);
+ $this->bake($action, ' ');
$this->_stop();
} else {
$this->out(__('Bake Aborted.'));
diff --git a/cake/libs/cache.php b/cake/libs/cache.php
index 7f47a7edb..61bd02998 100644
--- a/cake/libs/cache.php
+++ b/cake/libs/cache.php
@@ -266,7 +266,7 @@ class Cache {
}
$key = self::$_engines[$config]->key($key);
- if (!$key || is_resource($value) || $settings['duration'] < 1) {
+ if (!$key || is_resource($value)) {
return false;
}
diff --git a/cake/libs/cache/file.php b/cake/libs/cache/file.php
index 7327f89cc..02b35152b 100644
--- a/cake/libs/cache/file.php
+++ b/cake/libs/cache/file.php
@@ -299,6 +299,7 @@ class FileEngine extends CacheEngine {
if ($this->_init && !($dir->isDir() && $dir->isWritable())) {
$this->_init = false;
trigger_error(sprintf(__('%s is not writable'), $this->settings['path']), E_USER_WARNING);
+ return false;
}
return true;
}
diff --git a/cake/libs/cake_response.php b/cake/libs/cake_response.php
index 96c262754..6a3d300b9 100644
--- a/cake/libs/cake_response.php
+++ b/cake/libs/cake_response.php
@@ -390,7 +390,7 @@ class CakeResponse {
* e.g `header('WWW-Authenticate: Negotiate');`
*
* ### 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
* with the last value sent for it
diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php
index 4cfc543de..36a9d4aae 100644
--- a/cake/libs/controller/components/cookie.php
+++ b/cake/libs/controller/components/cookie.php
@@ -116,6 +116,16 @@ class CookieComponent extends Component {
*/
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.
*
@@ -125,7 +135,7 @@ class CookieComponent extends Component {
* @var string
* @access private
*/
- private $__values = array();
+ protected $_values = array();
/**
* Type of encryption to use.
@@ -137,7 +147,7 @@ class CookieComponent extends Component {
* @access private
* @todo add additional encryption methods
*/
- private $__type = 'cipher';
+ protected $_type = 'cipher';
/**
* Used to reset cookie time if $expire is passed to CookieComponent::write()
@@ -145,7 +155,7 @@ class CookieComponent extends Component {
* @var string
* @access private
*/
- private $__reset = null;
+ protected $_reset = null;
/**
* Expire time of the cookie
@@ -155,15 +165,17 @@ class CookieComponent extends Component {
* @var string
* @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');
+ parent::__construct($collection, $settings);
}
/**
@@ -171,10 +183,10 @@ class CookieComponent extends Component {
*
*/
public function startup() {
- $this->__expire($this->time);
+ $this->_expire($this->time);
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)) {
$encrypt = true;
}
- $this->__encrypted = $encrypt;
- $this->__expire($expires);
+ $this->_encrypted = $encrypt;
+ $this->_expire($expires);
if (!is_array($key)) {
$key = array($key => $value);
@@ -208,19 +220,19 @@ class CookieComponent extends Component {
foreach ($key as $name => $value) {
if (strpos($name, '.') === false) {
- $this->__values[$name] = $value;
- $this->__write("[$name]", $value);
+ $this->_values[$name] = $value;
+ $this->_write("[$name]", $value);
} else {
$names = explode('.', $name, 2);
- if (!isset($this->__values[$names[0]])) {
- $this->__values[$names[0]] = array();
+ if (!isset($this->_values[$names[0]])) {
+ $this->_values[$names[0]] = array();
}
- $this->__values[$names[0]] = Set::insert($this->__values[$names[0]], $names[1], $value);
- $this->__write('[' . implode('][', $names) . ']', $value);
+ $this->_values[$names[0]] = Set::insert($this->_values[$names[0]], $names[1], $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
*/
public function read($key = null) {
- if (empty($this->__values) && isset($_COOKIE[$this->name])) {
- $this->__values = $this->__decrypt($_COOKIE[$this->name]);
+ if (empty($this->_values) && isset($_COOKIE[$this->name])) {
+ $this->_values = $this->_decrypt($_COOKIE[$this->name]);
}
if (is_null($key)) {
- return $this->__values;
+ return $this->_values;
}
if (strpos($key, '.') !== false) {
$names = explode('.', $key, 2);
$key = $names[0];
}
- if (!isset($this->__values[$key])) {
+ if (!isset($this->_values[$key])) {
return null;
}
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
*/
public function delete($key) {
- if (empty($this->__values)) {
+ if (empty($this->_values)) {
$this->read();
}
if (strpos($key, '.') === false) {
- unset($this->__values[$key]);
- $this->__delete("[$key]");
+ unset($this->_values[$key]);
+ $this->_delete("[$key]");
return;
}
$names = explode('.', $key, 2);
- $this->__values[$names[0]] = Set::remove($this->__values[$names[0]], $names[1]);
- $this->__delete('[' . implode('][', $names) . ']');
+ $this->_values[$names[0]] = Set::remove($this->_values[$names[0]], $names[1]);
+ $this->_delete('[' . implode('][', $names) . ']');
}
/**
@@ -291,18 +303,18 @@ class CookieComponent extends Component {
*/
public function destroy() {
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)) {
foreach ($value as $key => $val) {
- unset($this->__values[$name][$key]);
- $this->__delete("[$name][$key]");
+ unset($this->_values[$name][$key]);
+ $this->_delete("[$name][$key]");
}
}
- unset($this->__values[$name]);
- $this->__delete("[$name]");
+ unset($this->_values[$name]);
+ $this->_delete("[$name]");
}
}
@@ -313,8 +325,8 @@ class CookieComponent extends Component {
* @access public
* @todo NOT IMPLEMENTED
*/
- function type($type = 'cipher') {
- $this->__type = 'cipher';
+ public function type($type = 'cipher') {
+ $this->_type = 'cipher';
}
/**
@@ -329,23 +341,22 @@ class CookieComponent extends Component {
*
* @param mixed $expires Can be either Unix timestamp, or date string
* @return int Unix timestamp
- * @access private
*/
- function __expire($expires = null) {
+ protected function _expire($expires = null) {
$now = time();
if (is_null($expires)) {
- return $this->__expires;
+ return $this->_expires;
}
- $this->__reset = $this->__expires;
+ $this->_reset = $this->_expires;
if ($expires == 0) {
- return $this->__expires = 0;
+ return $this->_expires = 0;
}
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 $value Value for cookie
- * @access private
*/
- function __write($name, $value) {
- setcookie($this->name . $name, $this->__encrypt($value), $this->__expires, $this->path, $this->domain, $this->secure);
+ protected function _write($name, $value) {
+ $this->_setcookie(
+ $this->name . $name, $this->_encrypt($value),
+ $this->_expires, $this->path, $this->domain, $this->secure, $this->httpOnly
+ );
- if (!is_null($this->__reset)) {
- $this->__expires = $this->__reset;
- $this->__reset = null;
+ if (!is_null($this->_reset)) {
+ $this->_expires = $this->_reset;
+ $this->_reset = null;
}
}
@@ -368,26 +381,43 @@ class CookieComponent extends Component {
* Sets a cookie expire time to remove cookie value
*
* @param string $name Name of cookie
- * @access private
+ * @return void
*/
- function __delete($name) {
- setcookie($this->name . $name, '', time() - 42000, $this->path, $this->domain, $this->secure);
+ protected function _delete($name) {
+ $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
*
* @param string $value Value to encrypt
* @return string encrypted string
- * @access private
+ * @return string Encoded values
*/
- function __encrypt($value) {
+ protected function _encrypt($value) {
if (is_array($value)) {
- $value = $this->__implode($value);
+ $value = $this->_implode($value);
}
- if ($this->__encrypted === true) {
- $type = $this->__type;
+ if ($this->_encrypted === true) {
+ $type = $this->_type;
$value = "Q2FrZQ==." .base64_encode(Security::$type($value, $this->key));
}
return $value;
@@ -398,30 +428,29 @@ class CookieComponent extends Component {
*
* @param array $values Values to decrypt
* @return string decrypted string
- * @access private
*/
- function __decrypt($values) {
+ protected function _decrypt($values) {
$decrypted = array();
- $type = $this->__type;
+ $type = $this->_type;
foreach ($values as $name => $value) {
if (is_array($value)) {
foreach ($value as $key => $val) {
$pos = strpos($val, 'Q2FrZQ==.');
- $decrypted[$name][$key] = $this->__explode($val);
+ $decrypted[$name][$key] = $this->_explode($val);
if ($pos !== false) {
$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 {
$pos = strpos($value, 'Q2FrZQ==.');
- $decrypted[$name] = $this->__explode($value);
+ $decrypted[$name] = $this->_explode($value);
if ($pos !== false) {
$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
* @return string String in the form key1|value1,key2|value2
- * @access private
*/
- function __implode($array) {
+ protected function _implode($array) {
$string = '';
foreach ($array as $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
* @return array Map of key and values
- * @access private
*/
- function __explode($string) {
+ protected function _explode($string) {
$array = array();
foreach (explode(',', $string) as $pair) {
$key = explode('|', $pair);
diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php
index d0aab867b..06d41178d 100755
--- a/cake/libs/controller/components/email.php
+++ b/cake/libs/controller/components/email.php
@@ -790,8 +790,8 @@ class EmailComponent extends Component {
* @access private
*/
function _mail() {
- $header = implode("\n", $this->_header);
- $message = implode("\n", $this->_message);
+ $header = implode("\r\n", $this->_header);
+ $message = implode("\r\n", $this->_message);
if (is_array($this->to)) {
$to = implode(', ', array_map(array($this, '_formatAddress'), $this->to));
} else {
diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php
index 75d28919b..2f31eb5df 100644
--- a/cake/libs/controller/components/request_handler.php
+++ b/cake/libs/controller/components/request_handler.php
@@ -167,6 +167,8 @@ class RequestHandlerComponent extends Component {
$this->renderAs($controller, $this->ext);
} elseif ($this->request->is('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')) {
diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php
index a9b11759d..d89efe3a6 100644
--- a/cake/libs/controller/controller.php
+++ b/cake/libs/controller/controller.php
@@ -714,7 +714,7 @@ class Controller extends Object {
} else {
$data = array($one => $two);
}
- $this->viewVars = array_merge($this->viewVars, $data);
+ $this->viewVars = $data + $this->viewVars;
}
/**
diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php
index 20b3fccac..a4decf111 100644
--- a/cake/libs/i18n.php
+++ b/cake/libs/i18n.php
@@ -74,13 +74,6 @@ class I18n {
*/
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.
* 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) {
$_this =& I18n::getInstance();
-
+
if (strpos($singular, "\r\n") !== false) {
$singular = str_replace("\r\n", "\n", $singular);
}
@@ -143,15 +136,16 @@ class I18n {
if (is_null($domain)) {
$domain = 'default';
}
- $_this->domain = $domain . '_' . $_this->l10n->locale;
- if (empty($_this->__domains)) {
- $_this->__domains = Cache::read($_this->domain, '_cake_core_');
+ $_this->domain = $domain . '_' . $_this->l10n->lang;
+
+ 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->__cache = true;
+ Cache::write($_this->domain, $_this->__domains[$domain][$_this->__lang], '_cake_core_');
}
if ($_this->category == 'LC_TIME') {
@@ -160,8 +154,8 @@ class I18n {
if (!isset($count)) {
$plurals = 0;
- } elseif (!empty($_this->__domains[$_this->category][$_this->__lang][$domain]["%plural-c"]) && $_this->__noLocale === false) {
- $header = $_this->__domains[$_this->category][$_this->__lang][$domain]["%plural-c"];
+ } elseif (!empty($_this->__domains[$domain][$_this->__lang][$_this->category]["%plural-c"]) && $_this->__noLocale === false) {
+ $header = $_this->__domains[$domain][$_this->__lang][$_this->category]["%plural-c"];
$plurals = $_this->__pluralGuess($header, $count);
} else {
if ($count != 1) {
@@ -171,8 +165,8 @@ class I18n {
}
}
- if (!empty($_this->__domains[$_this->category][$_this->__lang][$domain][$singular])) {
- if (($trans = $_this->__domains[$_this->category][$_this->__lang][$domain][$singular]) || ($plurals) && ($trans = $_this->__domains[$_this->category][$_this->__lang][$domain][$plural])) {
+ if (!empty($_this->__domains[$domain][$_this->__lang][$_this->category][$singular])) {
+ 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 (isset($trans[$plurals])) {
$trans = $trans[$plurals];
@@ -190,6 +184,26 @@ class I18n {
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.
*
@@ -276,12 +290,12 @@ class I18n {
if (file_exists($fn = "$app.mo")) {
$this->__loadMo($fn, $domain);
$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;
} elseif (file_exists($fn = "$app.po") && ($f = fopen($fn, "r"))) {
$this->__loadPo($f, $domain);
$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;
}
}
@@ -302,27 +316,27 @@ class I18n {
}
}
- if (empty($this->__domains[$this->category][$this->__lang][$domain])) {
- $this->__domains[$this->category][$this->__lang][$domain] = array();
+ if (empty($this->__domains[$domain][$this->__lang][$this->category])) {
+ $this->__domains[$domain][$this->__lang][$this->category] = array();
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) {
$header = strtok($line,":");
$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"])) {
- $switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $this->__domains[$this->category][$this->__lang][$domain]["%po-header"]["plural-forms"]);
- $this->__domains[$this->category][$this->__lang][$domain]["%plural-c"] = $switch;
- unset($this->__domains[$this->category][$this->__lang][$domain]["%po-header"]);
+ if (isset($this->__domains[$domain][$this->__lang][$this->category]["%po-header"]["plural-forms"])) {
+ $switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $this->__domains[$domain][$this->__lang][$this->category]["%po-header"]["plural-forms"]);
+ $this->__domains[$domain][$this->__lang][$this->category]["%plural-c"] = $switch;
+ unset($this->__domains[$domain][$this->__lang][$this->category]["%po-header"]);
}
$this->__domains = Set::pushDiff($this->__domains, $merge);
- if (isset($this->__domains[$this->category][$this->__lang][$domain][null])) {
- unset($this->__domains[$this->category][$this->__lang][$domain][null]);
+ if (isset($this->__domains[$domain][$this->__lang][$this->category][null])) {
+ unset($this->__domains[$domain][$this->__lang][$this->category][null]);
}
}
return $domain;
@@ -357,10 +371,10 @@ class I18n {
if (strpos($msgstr, "\000")) {
$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)) {
- $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));
fclose($file);
$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;
}
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 {
- $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
* @return mixed translated format string if only value or array of translated strings for corresponding format.
*/
- private function __translateTime($format, $domain) {
- if (!empty($this->__domains['LC_TIME'][$this->__lang][$domain][$format])) {
- if (($trans = $this->__domains[$this->category][$this->__lang][$domain][$format])) {
+ function __translateTime($format, $domain) {
+ if (!empty($this->__domains[$domain][$this->__lang]['LC_TIME'][$format])) {
+ if (($trans = $this->__domains[$domain][$this->__lang][$this->category][$format])) {
return $trans;
}
}
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_');
- }
- }
}
diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php
index 3b1efd0cc..9221c820b 100644
--- a/cake/libs/inflector.php
+++ b/cake/libs/inflector.php
@@ -234,6 +234,13 @@ class Inflector {
*/
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
*
@@ -255,6 +262,24 @@ class Inflector {
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.
*
@@ -540,3 +565,6 @@ class Inflector {
return preg_replace(array_keys($map), array_values($map), $string);
}
}
+
+// Store the initial state
+Inflector::reset();
\ No newline at end of file
diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php
index b0af738ca..39e5e4b2a 100644
--- a/cake/libs/model/datasources/dbo/dbo_postgres.php
+++ b/cake/libs/model/datasources/dbo/dbo_postgres.php
@@ -299,6 +299,17 @@ class DboPostgres extends DboSource {
}
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':
if (is_float($data)) {
$data = sprintf('%F', $data);
@@ -312,17 +323,6 @@ class DboPostgres extends DboSource {
if ($data === '') {
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:
$data = pg_escape_string($data);
break;
diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php
index 5c4d96ca8..e9dad606b 100755
--- a/cake/libs/model/datasources/dbo_source.php
+++ b/cake/libs/model/datasources/dbo_source.php
@@ -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);
}
@@ -1657,8 +1660,10 @@ class DboSource extends DataSource {
$noJoin = false;
break;
}
- $conditions[$field] = $value;
- unset($conditions[$originalField]);
+ if ($field !== $originalField) {
+ $conditions[$field] = $value;
+ unset($conditions[$originalField]);
+ }
}
if ($noJoin === true) {
return $this->conditions($conditions);
@@ -1979,18 +1984,8 @@ class DboSource extends DataSource {
if ($comma === false) {
$build = explode('.', $fields[$i]);
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];
diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php
index 9abd19c74..22c186219 100644
--- a/cake/libs/model/model.php
+++ b/cake/libs/model/model.php
@@ -2042,10 +2042,12 @@ class Model extends Object {
* find('all', array(
* 'conditions' => array('name' => 'Thomas Anderson'),
* 'joins' => array(
- * 'alias' => 'Thought',
- * 'table' => 'thoughts',
- * 'type' => 'LEFT',
- * 'conditions' => '`Thought`.`person_id` = `Person`.`id`'
+ * array(
+ * 'alias' => 'Thought',
+ * 'table' => 'thoughts',
+ * 'type' => 'LEFT',
+ * 'conditions' => '`Thought`.`person_id` = `Person`.`id`'
+ * )
* )
* ));
* }}}
diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp
index e1f73c7f7..fbfddb47c 100644
--- a/cake/libs/view/pages/home.ctp
+++ b/cake/libs/view/pages/home.ctp
@@ -71,6 +71,16 @@ endif;
endif;
?>
+';
+ __('PCRE has not been compiled with Unicode support.');
+ echo ' ';
+ __('Recompile PCRE with Unicode support by adding --enable-unicode-properties
when configuring');
+ echo ' ';
+ }
+?>
-
\ No newline at end of file
+
diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php
index 0876238aa..eae0222f0 100644
--- a/cake/libs/view/view.php
+++ b/cake/libs/view/view.php
@@ -597,7 +597,7 @@ class View extends Object {
if ($data == null) {
return false;
}
- $this->viewVars = array_merge($this->viewVars, $data);
+ $this->viewVars = $data + $this->viewVars;
}
/**
diff --git a/cake/tests/cases/console/all_shells.test.php b/cake/tests/cases/console/all_shells.test.php
index 50f8763d9..98afe5ad7 100644
--- a/cake/tests/cases/console/all_shells.test.php
+++ b/cake/tests/cases/console/all_shells.test.php
@@ -34,16 +34,13 @@ class AllShellsTest extends PHPUnit_Framework_TestSuite {
* @return void
*/
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;
$suite->addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'cake.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'console_error_handler.test.php');
- $tasks = array('acl', 'api', 'bake', 'schema', 'shell');
- foreach ($tasks as $task) {
- $suite->addTestFile($path . $task . '.test.php');
- }
+ $suite->addTestDirectory($path);
return $suite;
}
}
\ No newline at end of file
diff --git a/cake/tests/cases/console/libs/all_bake_tasks.test.php b/cake/tests/cases/console/all_tasks.test.php
similarity index 70%
rename from cake/tests/cases/console/libs/all_bake_tasks.test.php
rename to cake/tests/cases/console/all_tasks.test.php
index eec2c991b..7316f490e 100644
--- a/cake/tests/cases/console/libs/all_bake_tasks.test.php
+++ b/cake/tests/cases/console/all_tasks.test.php
@@ -1,6 +1,6 @@
addTestFile(CORE_TEST_CASES . DS . 'console' . DS . 'libs' . DS . 'bake.test.php');
- $tasks = array('controller', 'model', 'view', 'fixture', 'test', 'db_config', 'project', 'plugin');
- foreach ($tasks as $task) {
- $suite->addTestFile($path . $task . '.test.php');
- }
+ $suite->addTestDirectory($path);
return $suite;
}
}
diff --git a/cake/tests/cases/console/cake.test.php b/cake/tests/cases/console/cake.test.php
index 8ed92c6e4..aa0deee61 100644
--- a/cake/tests/cases/console/cake.test.php
+++ b/cake/tests/cases/console/cake.test.php
@@ -165,6 +165,7 @@ class ShellDispatcherTest extends CakeTestCase {
* @return void
*/
public function setUp() {
+ parent::setUp();
App::build(array(
'plugins' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
@@ -176,15 +177,6 @@ class ShellDispatcherTest extends CakeTestCase {
), true);
}
-/**
- * tearDown method
- *
- * @return void
- */
- public function tearDown() {
- App::build();
- }
-
/**
* testParseParams method
*
diff --git a/cake/tests/cases/console/libs/acl.test.php b/cake/tests/cases/console/libs/acl.test.php
index 559e5eb3a..259c0c26d 100644
--- a/cake/tests/cases/console/libs/acl.test.php
+++ b/cake/tests/cases/console/libs/acl.test.php
@@ -51,20 +51,19 @@ class AclShellTest extends CakeTestCase {
public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
/**
- * startTest method
+ * setup method
*
* @return void
*/
- public function startTest() {
- $this->_aclDb = Configure::read('Acl.database');
- $this->_aclClass = Configure::read('Acl.classname');
+ public function setUp() {
+ parent::setUp();
- Configure::write('Acl.database', 'test_suite');
+ Configure::write('Acl.database', 'test');
Configure::write('Acl.classname', 'DbAcl');
$this->Dispatcher = $this->getMock(
'ShellDispatcher',
- array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch')
+ array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch', 'clear')
);
$this->Task = $this->getMock(
'AclShell',
@@ -74,18 +73,7 @@ class AclShellTest extends CakeTestCase {
$collection = new ComponentCollection();
$this->Task->Acl = new AclComponent($collection);
- $this->Task->params['datasource'] = 'test_suite';
- }
-
-/**
- * endTest method
- *
- * @return void
- */
- public function endTest() {
- ClassRegistry::flush();
- Configure::write('Acl.database', $this->_aclDb);
- Configure::write('Acl.classname', $this->_aclClass);
+ $this->Task->params['datasource'] = 'test';
}
/**
diff --git a/cake/tests/cases/console/libs/api.test.php b/cake/tests/cases/console/libs/api.test.php
index 76f52b449..39fac8268 100644
--- a/cake/tests/cases/console/libs/api.test.php
+++ b/cake/tests/cases/console/libs/api.test.php
@@ -43,14 +43,15 @@ if (!class_exists('ApiShell')) {
class ApiShellTest extends CakeTestCase {
/**
- * startTest method
+ * setUp method
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
+ parent::setUp();
$this->Dispatcher = $this->getMock(
'ShellDispatcher',
- array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch')
+ array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch', 'clear')
);
$this->Shell = $this->getMock(
'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.
*
diff --git a/cake/tests/cases/console/libs/bake.test.php b/cake/tests/cases/console/libs/bake.test.php
index 370cabc90..eb29b9ca2 100644
--- a/cake/tests/cases/console/libs/bake.test.php
+++ b/cake/tests/cases/console/libs/bake.test.php
@@ -54,14 +54,15 @@ class BakeShellTest extends CakeTestCase {
public $fixtures = array('core.user');
/**
- * start test
+ * setup test
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
+ parent::setUp();
$this->Dispatcher = $this->getMock(
'ShellDispatcher',
- array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
+ array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
);
$this->Shell = $this->getMock(
'BakeShell',
@@ -72,11 +73,12 @@ class BakeShellTest extends CakeTestCase {
}
/**
- * endTest method
+ * teardown method
*
* @return void
*/
- public function endTest() {
+ public function tearDown() {
+ parent::tearDown();
unset($this->Dispatch, $this->Shell);
}
@@ -96,7 +98,7 @@ class BakeShellTest extends CakeTestCase {
$this->Shell->View = $this->getMock('ModelTask', 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->once())->method('bake')->will($this->returnValue(true));
diff --git a/cake/tests/cases/console/libs/schema.test.php b/cake/tests/cases/console/libs/schema.test.php
index bfcfb31bd..c773a4460 100644
--- a/cake/tests/cases/console/libs/schema.test.php
+++ b/cake/tests/cases/console/libs/schema.test.php
@@ -54,10 +54,10 @@ class SchemaShellTestSchema extends CakeSchema {
/**
* connection property
*
- * @var string 'test_suite'
+ * @var string 'test'
* @access public
*/
- public $connection = 'test_suite';
+ public $connection = 'test';
/**
* comments property
@@ -115,14 +115,14 @@ class SchemaShellTest extends CakeTestCase {
);
/**
- * startTest method
+ * setup method
*
* @return void
*/
- public function startTest() {
+ public function setup() {
$this->Dispatcher = $this->getMock(
'ShellDispatcher',
- array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
+ array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
);
$this->Shell = $this->getMock(
'SchemaShell',
@@ -136,8 +136,13 @@ class SchemaShellTest extends CakeTestCase {
*
* @return void
*/
- public function endTest() {
+ public function teardown() {
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);
$this->Shell->params = array(
'file' => 'other_file.php',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'path' => '/test/path'
);
$this->Shell->startup();
$this->assertEqual(strtolower($this->Shell->Schema->name), strtolower(APP_DIR));
$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');
}
@@ -226,8 +231,8 @@ class SchemaShellTest extends CakeTestCase {
$this->Shell->startup();
$this->Shell->dump();
- $sql =& new File(TMP . 'tests' . DS . 'i18n.sql');
- $contents = $sql->read();
+ $this->file =& new File(TMP . 'tests' . DS . 'i18n.sql');
+ $contents = $this->file->read();
$this->assertPattern('/DROP TABLE/', $contents);
$this->assertPattern('/CREATE TABLE `i18n`/', $contents);
$this->assertPattern('/id/', $contents);
@@ -236,8 +241,6 @@ class SchemaShellTest extends CakeTestCase {
$this->assertPattern('/locale/', $contents);
$this->assertPattern('/foreign_key/', $contents);
$this->assertPattern('/content/', $contents);
-
- $sql->delete();
}
/**
@@ -251,21 +254,21 @@ class SchemaShellTest extends CakeTestCase {
));
$this->Shell->args = array('TestPlugin.TestPluginApp');
$this->Shell->params = array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'write' => TMP . 'tests' . DS . 'dump_test.sql'
);
$this->Shell->startup();
$this->Shell->expects($this->once())->method('_stop');
$this->Shell->dump();
- $file =& new File(TMP . 'tests' . DS . 'dump_test.sql');
- $contents = $file->read();
+ $this->file =& new File(TMP . 'tests' . DS . 'dump_test.sql');
+ $contents = $this->file->read();
$this->assertPattern('/CREATE TABLE `acos`/', $contents);
$this->assertPattern('/id/', $contents);
$this->assertPattern('/model/', $contents);
- $file->delete();
+ $this->file->delete();
App::build();
}
@@ -344,17 +347,19 @@ class SchemaShellTest extends CakeTestCase {
public function testGenerateWithPlugins() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
- ));
+ ), true);
+ App::objects('plugin', null, false);
+
$this->Shell->params = array(
'plugin' => 'TestPlugin',
- 'connection' => 'test_suite'
+ 'connection' => 'test'
);
$this->Shell->startup();
$this->Shell->Schema->path = TMP . 'tests' . DS;
$this->Shell->generate();
- $file = new File(TMP . 'tests' . DS . 'schema.php');
- $contents = $file->read();
+ $this->file = new File(TMP . 'tests' . DS . 'schema.php');
+ $contents = $this->file->read();
$this->assertPattern('/class TestPluginSchema/', $contents);
$this->assertPattern('/var \$posts/', $contents);
@@ -363,9 +368,6 @@ class SchemaShellTest extends CakeTestCase {
$this->assertPattern('/var \$test_plugin_comments/', $contents);
$this->assertNoPattern('/var \$users/', $contents);
$this->assertNoPattern('/var \$articles/', $contents);
-
- $file->delete();
- App::build();
}
/**
@@ -375,7 +377,7 @@ class SchemaShellTest extends CakeTestCase {
*/
public function testCreateNoArgs() {
$this->Shell->params = array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'path' => APP . 'config' . DS . 'sql'
);
$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->create();
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$sources = $db->listSources();
$this->assertTrue(in_array($db->config['prefix'] . 'i18n', $sources));
@@ -397,8 +399,13 @@ class SchemaShellTest extends CakeTestCase {
* @return void
*/
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(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'DbAcl',
'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->create();
- $db =& ConnectionManager::getDataSource('test');
+ $db = ConnectionManager::getDataSource('test');
$sources = $db->listSources();
- $this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources));
- $this->assertFalse(in_array($db->config['prefix'] . 'aros', $sources));
- $this->assertFalse(in_array('aros_acos', $sources));
-
- $db->execute('DROP TABLE ' . $db->config['prefix'] . 'acos');
+ $this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources), 'acos should be present.');
+ $this->assertFalse(in_array($db->config['prefix'] . 'aros', $sources), 'aros should not be found.');
+ $this->assertFalse(in_array('aros_acos', $sources), 'aros_acos should not be found.');
}
/**
@@ -422,19 +427,23 @@ class SchemaShellTest extends CakeTestCase {
* @return void
*/
public function testUpdateWithTable() {
+ $this->Shell = $this->getMock(
+ 'SchemaShell',
+ array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '__run'),
+ array(&$this->Dispatcher)
+ );
+
$this->Shell->params = array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'f' => true
);
$this->Shell->args = array('SchemaShellTest', 'articles');
$this->Shell->startup();
$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();
-
- $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(
'plugin' => 'TestPlugin',
- 'connection' => 'test_suite'
+ 'connection' => 'test'
);
$this->Shell->startup();
$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);
-
- App::build();
}
/**
@@ -467,18 +474,15 @@ class SchemaShellTest extends CakeTestCase {
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Shell->params = array(
- 'connection' => 'test_suite'
+ 'connection' => 'test'
);
$this->Shell->args = array('TestPlugin.TestPluginApp');
$this->Shell->startup();
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y'));
$this->Shell->create();
- $db =& ConnectionManager::getDataSource('test_suite');
+ $db =& ConnectionManager::getDataSource('test');
$sources = $db->listSources();
$this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources));
-
- $db->execute('DROP TABLE ' . $db->config['prefix'] . 'acos');
- App::build();
}
}
diff --git a/cake/tests/cases/console/libs/shell.test.php b/cake/tests/cases/console/libs/shell.test.php
index bc711fe75..4e25f7efe 100644
--- a/cake/tests/cases/console/libs/shell.test.php
+++ b/cake/tests/cases/console/libs/shell.test.php
@@ -116,7 +116,7 @@ class ShellTest extends CakeTestCase {
$this->Dispatcher = $this->getMock(
'ShellDispatcher',
- array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
+ array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
);
$this->Shell =& new TestShell($this->Dispatcher);
}
diff --git a/cake/tests/cases/console/libs/tasks/controller.test.php b/cake/tests/cases/console/libs/tasks/controller.test.php
index 9e325af43..ecaff46df 100644
--- a/cake/tests/cases/console/libs/tasks/controller.test.php
+++ b/cake/tests/cases/console/libs/tasks/controller.test.php
@@ -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');
/**
- * startTest method
+ * setUp method
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('ControllerTask',
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'),
@@ -101,11 +101,11 @@ class ControllerTaskTest extends CakeTestCase {
}
/**
- * endTest method
+ * teardown method
*
* @return void
*/
- public function endTest() {
+ public function teardown() {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
}
@@ -116,12 +116,12 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testListAll() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->interactive = true;
$this->Task->expects($this->at(1))->method('out')->with('1. BakeArticles');
$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');
$expected = array('BakeArticles', 'BakeArticlesBakeTags', 'BakeComments', 'BakeTags');
- $result = $this->Task->listAll('test_suite');
+ $result = $this->Task->listAll('test');
$this->assertEqual($result, $expected);
$this->Task->interactive = false;
@@ -145,19 +145,20 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testGetNameValidIndex() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
$this->Task->interactive = true;
- $this->Task->expects($this->at(5))->method('in')->will($this->returnValue(3));
- $this->Task->expects($this->at(7))->method('in')->will($this->returnValue(1));
+ $this->Task->expects($this->any())->method('in')->will(
+ $this->onConsecutiveCalls(3, 1)
+ );
- $result = $this->Task->getName('test_suite');
+ $result = $this->Task->getName('test');
$expected = 'BakeComments';
$this->assertEqual($result, $expected);
- $result = $this->Task->getName('test_suite');
+ $result = $this->Task->getName('test');
$expected = 'BakeArticles';
$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('_stop');
- $this->Task->getName('test_suite');
+ $this->Task->getName('test');
}
/**
@@ -417,7 +418,7 @@ class ControllerTaskTest extends CakeTestCase {
*/
public function testBakeTest() {
$this->Task->plugin = 'ControllerTest';
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->interactive = false;
$this->Task->Test->expects($this->once())->method('bake')->with('Controller', 'BakeArticles');
@@ -434,12 +435,12 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testInteractive() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->expects($this->any())->method('in')
@@ -469,12 +470,12 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
function testInteractiveAdminMethodsNotInteractive() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->interactive = true;
$this->Task->path = '/my/path/';
@@ -511,12 +512,14 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteIntoAll() {
- $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
- 'Execute into all could not be run as an Article, Tag or Comment model was already loaded. %s');
- if ($skip) {
- return;
+ $count = count($this->Task->listAll('test'));
+ if ($count != count($this->fixtures)) {
+ $this->markTestSkipped('Additional tables detected.');
}
- $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->args = array('all');
@@ -538,12 +541,10 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteWithController() {
- $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
- 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
- if ($skip) {
- return;
+ if (!defined('ARTICLE_MODEL_CREATED')) {
+ $this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('BakeArticles');
@@ -574,12 +575,10 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteWithControllerNameVariations($name) {
- $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
- 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
- if ($skip) {
- return;
+ if (!defined('ARTICLE_MODEL_CREATED')) {
+ $this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined.');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array($name);
@@ -596,12 +595,10 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteWithPublicParam() {
- $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
- 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
- if ($skip) {
- return;
+ if (!defined('ARTICLE_MODEL_CREATED')) {
+ $this->markTestSkipped('Execute with public param requires no Article, Tag or Comment model to be defined.');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('BakeArticles', 'public');
@@ -619,13 +616,11 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteWithControllerAndBoth() {
- $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
- 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
- if ($skip) {
- return;
+ if (!defined('ARTICLE_MODEL_CREATED')) {
+ $this->markTestSkipped('Execute with controller and both requires no Article, Tag or Comment model to be defined.');
}
$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->args = array('BakeArticles', 'public', 'admin');
@@ -642,13 +637,11 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteWithControllerAndAdmin() {
- $skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
- 'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
- if ($skip) {
- return;
+ if (!defined('ARTICLE_MODEL_CREATED')) {
+ $this->markTestSkipped('Execute with controller and admin requires no Article, Tag or Comment model to be defined.');
}
$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->args = array('BakeArticles', 'admin');
diff --git a/cake/tests/cases/console/libs/tasks/db_config.test.php b/cake/tests/cases/console/libs/tasks/db_config.test.php
index b515d7e1d..b4271bb4b 100644
--- a/cake/tests/cases/console/libs/tasks/db_config.test.php
+++ b/cake/tests/cases/console/libs/tasks/db_config.test.php
@@ -64,13 +64,14 @@ class TEST_DATABASE_CONFIG {
class DbConfigTaskTest extends CakeTestCase {
/**
- * startTest method
+ * setup method
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
+ parent::setUp();
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('DbConfigTask',
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest', '_verify'),
@@ -87,9 +88,9 @@ class DbConfigTaskTest extends CakeTestCase {
*
* @return void
*/
- public function endTest() {
+ public function tearDown() {
+ parent::tearDown();
unset($this->Task, $this->Dispatcher);
- ClassRegistry::flush();
}
/**
diff --git a/cake/tests/cases/console/libs/tasks/extract.test.php b/cake/tests/cases/console/libs/tasks/extract.test.php
index 900193b85..72f6eb2d5 100644
--- a/cake/tests/cases/console/libs/tasks/extract.test.php
+++ b/cake/tests/cases/console/libs/tasks/extract.test.php
@@ -50,7 +50,7 @@ class ExtractTaskTest extends CakeTestCase {
*/
public function setUp() {
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task =& new ExtractTask($this->Dispatcher);
}
diff --git a/cake/tests/cases/console/libs/tasks/fixture.test.php b/cake/tests/cases/console/libs/tasks/fixture.test.php
index f9485a789..aebacaede 100644
--- a/cake/tests/cases/console/libs/tasks/fixture.test.php
+++ b/cake/tests/cases/console/libs/tasks/fixture.test.php
@@ -50,13 +50,14 @@ class FixtureTaskTest extends CakeTestCase {
public $fixtures = array('core.article', 'core.comment', 'core.datatype', 'core.binary_test');
/**
- * startTest method
+ * setUp method
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
+ parent::setUp();
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('FixtureTask',
array('in', 'err', 'createFile', '_stop'),
@@ -72,13 +73,13 @@ class FixtureTaskTest extends CakeTestCase {
}
/**
- * endTest method
+ * tearDown method
*
* @return void
*/
- public function endTest() {
+ public function tearDown() {
+ parent::tearDown();
unset($this->Task, $this->Dispatcher);
- ClassRegistry::flush();
}
/**
@@ -147,7 +148,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expects($this->at(0))->method('in')
->will($this->returnValue('WHERE 1=1 LIMIT 10'));
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$result = $this->Task->bake('Article', false, array(
@@ -168,7 +169,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteWithNamedModel() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$filename = '/my/path/article_fixture.php';
@@ -197,7 +198,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteWithNamedModelVariations($modelName) {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array($modelName);
@@ -214,7 +215,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteIntoAll() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->Model->expects($this->any())->method('listAll')
@@ -237,7 +238,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testAllWithCountAndRecordsFlags() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->params = array('count' => 10, 'records' => true);
@@ -263,7 +264,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteInteractive() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->expects($this->any())->method('in')->will($this->returnValue('y'));
@@ -285,7 +286,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testBake() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$result = $this->Task->bake('Article');
@@ -320,7 +321,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testRecordGenerationForBinaryAndFloat() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$result = $this->Task->bake('Article', 'datatypes');
@@ -336,7 +337,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testGenerateFixtureFile() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$filename = '/my/path/article_fixture.php';
@@ -357,7 +358,7 @@ class FixtureTaskTest extends CakeTestCase {
* @return void
*/
public function testGeneratePluginFixtureFile() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->plugin = 'TestFixture';
$filename = APP . 'plugins' . DS . 'test_fixture' . DS . 'tests' . DS . 'fixtures' . DS . 'article_fixture.php';
diff --git a/cake/tests/cases/console/libs/tasks/model.test.php b/cake/tests/cases/console/libs/tasks/model.test.php
index b81e3f3d8..237a52dce 100644
--- a/cake/tests/cases/console/libs/tasks/model.test.php
+++ b/cake/tests/cases/console/libs/tasks/model.test.php
@@ -53,13 +53,14 @@ class ModelTaskTest extends CakeTestCase {
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag', 'core.category_thread');
/**
- * starTest method
+ * setUp method
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
+ parent::setUp();
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('ModelTask',
array('in', 'err', 'createFile', '_stop', '_checkUnitTest'),
@@ -97,13 +98,13 @@ class ModelTaskTest extends CakeTestCase {
}
/**
- * endTest method
+ * teardown method
*
* @return void
*/
- public function endTest() {
+ public function tearDown() {
+ parent::tearDown();
unset($this->Task, $this->Dispatcher);
- ClassRegistry::flush();
}
/**
@@ -112,7 +113,7 @@ class ModelTaskTest extends CakeTestCase {
* @return void
*/
public function testListAll() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$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(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');
$this->assertEqual($result, $expected);
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$result = $this->Task->listAll();
$expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags');
$this->assertEqual($result, $expected);
@@ -148,7 +149,7 @@ class ModelTaskTest extends CakeTestCase {
public function testGetNameQuit() {
$this->Task->expects($this->once())->method('in')->will($this->returnValue('q'));
$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
*/
function testGetNameValidOption() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
$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';
$this->assertEqual($result, $expected);
- $result = $this->Task->getName('test_suite');
+ $result = $this->Task->getName('test');
$expected = 'Comment';
$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->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() {
$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';
$this->assertEqual($result, $expected);
}
@@ -204,7 +205,7 @@ class ModelTaskTest extends CakeTestCase {
*/
function testGetTableNameCustom() {
$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';
$this->assertEqual($result, $expected);
}
@@ -421,7 +422,7 @@ class ModelTaskTest extends CakeTestCase {
* @return void
*/
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());
$expected = array(
'belongsTo' => array(
@@ -439,7 +440,7 @@ class ModelTaskTest extends CakeTestCase {
);
$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());
$expected = array(
'belongsTo' => array(
@@ -459,8 +460,8 @@ class ModelTaskTest extends CakeTestCase {
* @return void
*/
public function testHasManyHasOneGeneration() {
- $model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
- $this->Task->connection = 'test_suite';
+ $model = new Model(array('ds' => 'test', 'name' => 'Article'));
+ $this->Task->connection = 'test';
$this->Task->listAll();
$result = $this->Task->findHasOneAndMany($model, array());
$expected = array(
@@ -481,7 +482,7 @@ class ModelTaskTest extends CakeTestCase {
);
$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());
$expected = array(
'hasOne' => array(
@@ -508,13 +509,13 @@ class ModelTaskTest extends CakeTestCase {
* @return void
*/
public function testHasAndBelongsToManyGeneration() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
- $model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
- $this->Task->connection = 'test_suite';
+ $model = new Model(array('ds' => 'test', 'name' => 'Article'));
+ $this->Task->connection = 'test';
$this->Task->listAll();
$result = $this->Task->findHasAndBelongsToMany($model, array());
$expected = array(
@@ -537,9 +538,9 @@ class ModelTaskTest extends CakeTestCase {
* @return void
*/
public function testDoAssociationsNonInteractive() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$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);
$expected = 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')
->will($this->onConsecutiveCalls('n', 'y', 'n', 'n', 'n'));
@@ -774,7 +775,7 @@ STRINGEND;
* @return void
*/
public function testExecuteWithNamedModel() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$filename = '/my/path/article.php';
@@ -807,7 +808,7 @@ STRINGEND;
* @return void
*/
public function testExecuteWithNamedModelVariations($name) {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
@@ -825,7 +826,7 @@ STRINGEND;
* @return void
*/
public function testExecuteWithNamedModelHasManyCreated() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$filename = '/my/path/article.php';
@@ -843,12 +844,12 @@ STRINGEND;
* @return void
*/
public function testExecuteIntoAll() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
@@ -888,12 +889,12 @@ STRINGEND;
* @return void
*/
function testSkipTablesAndAll() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
@@ -927,12 +928,12 @@ STRINGEND;
* @return void
*/
public function testExecuteIntoInteractive() {
- $count = count($this->Task->listAll('test_suite'));
+ $count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->interactive = true;
@@ -969,7 +970,7 @@ STRINGEND;
* @return void
*/
public function testExecuteWithNonExistantTableName() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->expects($this->once())->method('_stop');
diff --git a/cake/tests/cases/console/libs/tasks/plugin.test.php b/cake/tests/cases/console/libs/tasks/plugin.test.php
index 85a593a4b..e79541c41 100644
--- a/cake/tests/cases/console/libs/tasks/plugin.test.php
+++ b/cake/tests/cases/console/libs/tasks/plugin.test.php
@@ -44,53 +44,36 @@ require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php';
*/
class PluginTaskTest extends CakeTestCase {
- public static $_paths = array();
-
- public static $_testPath = array();
-
/**
- * startTest method
+ * setup method
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
+ parent::setUp();
+
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('PluginTask',
array('in', 'err', 'createFile', '_stop'),
array(&$this->Dispatcher)
);
$this->Task->path = TMP . 'tests' . DS;
- }
-
-/**
- * startCase methods
- *
- * @return void
- */
- public static function setUpBeforeClass() {
- self::$_paths = $paths = App::path('plugins');
- self::$_testPath = array_push($paths, TMP . 'tests' . DS);
+
+ $this->_paths = $paths = App::path('plugins');
+ $this->_testPath = array_push($paths, TMP . 'tests' . DS);
App::build(array('plugins' => $paths));
}
/**
- * endCase
+ * teardown
*
* @return void
*/
- public static function tearDownAfterClass() {
- App::build(array('plugins' => self::$_paths));
- }
-
-/**
- * endTest method
- *
- * @return void
- */
- public function endTest() {
- ClassRegistry::flush();
+ public function tearDown() {
+ parent::tearDown();
+ App::build(array('plugins' => $this->_paths));
}
/**
@@ -99,7 +82,7 @@ class PluginTaskTest extends CakeTestCase {
* @return void
*/
public function testBakeFoldersAndFiles() {
- $this->Task->expects($this->at(0))->method('in')->will($this->returnValue(self::$_testPath));
+ $this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
$path = $this->Task->path . 'bake_test_plugin';
@@ -219,7 +202,7 @@ class PluginTaskTest extends CakeTestCase {
*/
public function testExecuteWithOneArg() {
$this->Task->expects($this->at(0))->method('in')
- ->will($this->returnValue(self::$_testPath));
+ ->will($this->returnValue($this->_testPath));
$this->Task->expects($this->at(1))->method('in')
->will($this->returnValue('y'));
@@ -250,7 +233,7 @@ class PluginTaskTest extends CakeTestCase {
public function testExecuteWithTwoArgs() {
$this->Task->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
- $this->Task->expects($this->at(0))->method('in')->will($this->returnValue(self::$_testPath));
+ $this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
$this->Task->Model->expects($this->once())->method('loadTasks');
$this->Task->Model->expects($this->once())->method('execute');
diff --git a/cake/tests/cases/console/libs/tasks/project.test.php b/cake/tests/cases/console/libs/tasks/project.test.php
index 4b30c475e..67cb1c671 100644
--- a/cake/tests/cases/console/libs/tasks/project.test.php
+++ b/cake/tests/cases/console/libs/tasks/project.test.php
@@ -45,13 +45,14 @@ require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php'
class ProjectTaskTest extends CakeTestCase {
/**
- * startTest method
+ * setup method
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
+ parent::setUp();
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('ProjectTask',
array('in', 'err', 'createFile', '_stop'),
@@ -62,12 +63,12 @@ class ProjectTaskTest extends CakeTestCase {
}
/**
- * endTest method
+ * teardown method
*
* @return void
*/
- public function endTest() {
- ClassRegistry::flush();
+ public function tearDown() {
+ parent::tearDown();
$Folder = new Folder($this->Task->path . 'bake_test_app');
$Folder->delete();
diff --git a/cake/tests/cases/console/libs/tasks/template.test.php b/cake/tests/cases/console/libs/tasks/template.test.php
index fbf71bbdb..105515e9d 100644
--- a/cake/tests/cases/console/libs/tasks/template.test.php
+++ b/cake/tests/cases/console/libs/tasks/template.test.php
@@ -44,13 +44,13 @@ require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php
class TemplateTaskTest extends CakeTestCase {
/**
- * startTest method
+ * setup method
*
* @return void
*/
- public function startTest() {
+ public function setup() {
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('TemplateTask',
array('in', 'err', 'createFile', '_stop'),
@@ -60,13 +60,14 @@ class TemplateTaskTest extends CakeTestCase {
}
/**
- * endTest method
+ * teardown method
*
* @return void
*/
- public function endTest() {
+ public function teardown() {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
+ App::build();
}
/**
@@ -84,6 +85,12 @@ class TemplateTaskTest extends CakeTestCase {
$this->assertEqual($this->Task->templateVars['one'], 'three');
$this->assertTrue(isset($this->Task->templateVars['four']));
$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);
}
/**
diff --git a/cake/tests/cases/console/libs/tasks/test.test.php b/cake/tests/cases/console/libs/tasks/test.test.php
index f8753b905..238d92003 100644
--- a/cake/tests/cases/console/libs/tasks/test.test.php
+++ b/cake/tests/cases/console/libs/tasks/test.test.php
@@ -243,13 +243,14 @@ class TestTaskTest extends CakeTestCase {
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
/**
- * startTest method
+ * setup method
*
* @return void
*/
- public function startTest() {
+ public function setup() {
+ parent::setup();
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('TestTask',
array('in', 'err', 'createFile', '_stop', 'isLoadableClass'),
@@ -257,7 +258,7 @@ class TestTaskTest extends CakeTestCase {
);
$this->Dispatcher->shellPaths = App::path('shells');
$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
*/
- public function endTest() {
+ public function teardown() {
+ parent::teardown();
ClassRegistry::flush();
}
@@ -275,8 +277,8 @@ class TestTaskTest extends CakeTestCase {
* @return void
*/
public function testFilePathGenerationModelRepeated() {
- $this->Task->Dispatch->expects($this->never())->method('stderr');
- $this->Task->Dispatch->expects($this->never())->method('_stop');
+ $this->Dispatcher->expects($this->never())->method('stderr');
+ $this->Dispatcher->expects($this->never())->method('_stop');
$file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
@@ -446,22 +448,22 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->bake('Model', 'TestTaskArticle');
- $this->assertPattern('/App::import\(\'Model\', \'TestTaskArticle\'\)/', $result);
- $this->assertPattern('/class TestTaskArticleTestCase extends CakeTestCase/', $result);
+ $this->assertContains("App::import('Model', 'TestTaskArticle')", $result);
+ $this->assertContains('class TestTaskArticleTestCase extends CakeTestCase', $result);
- $this->assertPattern('/function startTest\(\)/', $result);
- $this->assertPattern("/\\\$this->TestTaskArticle \=\& ClassRegistry::init\('TestTaskArticle'\)/", $result);
+ $this->assertContains('function startTest()', $result);
+ $this->assertContains("\$this->TestTaskArticle =& ClassRegistry::init('TestTaskArticle')", $result);
- $this->assertPattern('/function endTest\(\)/', $result);
- $this->assertPattern('/unset\(\$this->TestTaskArticle\)/', $result);
+ $this->assertContains('function endTest()', $result);
+ $this->assertContains('unset($this->TestTaskArticle)', $result);
- $this->assertPattern('/function testDoSomething\(\)/i', $result);
- $this->assertPattern('/function testDoSomethingElse\(\)/i', $result);
+ $this->assertContains('function testDoSomething()', $result);
+ $this->assertContains('function testDoSomethingElse()', $result);
- $this->assertPattern("/'app\.test_task_article'/", $result);
- $this->assertPattern("/'plugin\.test_task\.test_task_comment'/", $result);
- $this->assertPattern("/'app\.test_task_tag'/", $result);
- $this->assertPattern("/'app\.articles_tag'/", $result);
+ $this->assertContains("'app.test_task_article'", $result);
+ $this->assertContains("'plugin.test_task.test_task_comment'", $result);
+ $this->assertContains("'app.test_task_tag'", $result);
+ $this->assertContains("'app.articles_tag'", $result);
}
/**
@@ -477,24 +479,24 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->bake('Controller', 'TestTaskComments');
- $this->assertPattern('/App::import\(\'Controller\', \'TestTaskComments\'\)/', $result);
- $this->assertPattern('/class TestTaskCommentsControllerTestCase extends CakeTestCase/', $result);
+ $this->assertContains("App::import('Controller', 'TestTaskComments')", $result);
+ $this->assertContains('class TestTaskCommentsControllerTestCase extends CakeTestCase', $result);
- $this->assertPattern('/class TestTestTaskCommentsController extends TestTaskCommentsController/', $result);
- $this->assertPattern('/public \$autoRender = false/', $result);
- $this->assertPattern('/function redirect\(\$url, \$status = null, \$exit = true\)/', $result);
+ $this->assertContains('class TestTestTaskCommentsController extends TestTaskCommentsController', $result);
+ $this->assertContains('public $autoRender = false', $result);
+ $this->assertContains('function redirect($url, $status = null, $exit = true)', $result);
- $this->assertPattern('/function startTest\(\)/', $result);
- $this->assertPattern("/\\\$this->TestTaskComments \=\& new TestTestTaskCommentsController\(\)/", $result);
- $this->assertPattern("/\\\$this->TestTaskComments->constructClasses\(\)/", $result);
+ $this->assertContains('function startTest()', $result);
+ $this->assertContains("\$this->TestTaskComments =& new TestTestTaskCommentsController()", $result);
+ $this->assertContains("\$this->TestTaskComments->constructClasses()", $result);
- $this->assertPattern('/function endTest\(\)/', $result);
- $this->assertPattern('/unset\(\$this->TestTaskComments\)/', $result);
+ $this->assertContains('function endTest()', $result);
+ $this->assertContains('unset($this->TestTaskComments)', $result);
- $this->assertPattern("/'app\.test_task_article'/", $result);
- $this->assertPattern("/'plugin\.test_task\.test_task_comment'/", $result);
- $this->assertPattern("/'app\.test_task_tag'/", $result);
- $this->assertPattern("/'app\.articles_tag'/", $result);
+ $this->assertContains("'app.test_task_article'", $result);
+ $this->assertContains("'plugin.test_task.test_task_comment'", $result);
+ $this->assertContains("'app.test_task_tag'", $result);
+ $this->assertContains("'app.articles_tag'", $result);
}
/**
diff --git a/cake/tests/cases/console/libs/tasks/view.test.php b/cake/tests/cases/console/libs/tasks/view.test.php
index dcce78240..9d25ba87d 100644
--- a/cake/tests/cases/console/libs/tasks/view.test.php
+++ b/cake/tests/cases/console/libs/tasks/view.test.php
@@ -224,15 +224,16 @@ class ViewTaskTest extends CakeTestCase {
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
/**
- * startTest method
+ * setUp method
*
* Ensure that the default theme is used
*
* @return void
*/
- public function startTest() {
+ public function setUp() {
+ parent::setUp();
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
- 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
+ 'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
$this->Task = $this->getMock('ViewTask',
array('in', 'err', 'createFile', '_stop'),
@@ -245,18 +246,16 @@ class ViewTaskTest extends CakeTestCase {
$this->Dispatcher->shellPaths = App::path('shells');
$this->Task->path = TMP;
$this->Task->Template->params['theme'] = 'default';
-
- $this->_routing = Configure::read('Routing');
}
/**
- * endTest method
+ * tearDown method
*
* @return void
*/
- public function endTest() {
- ClassRegistry::flush();
- Configure::write('Routing', $this->_routing);
+ public function tearDown() {
+ parent::tearDown();
+ unset($this->Task, $this->Dispatch);
}
/**
@@ -389,7 +388,7 @@ class ViewTaskTest extends CakeTestCase {
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
- $this->Task->expectNever('createFile');
+ $this->Task->expects($this->never())->method('createFile');
$this->Task->bake('delete', true);
}
@@ -613,7 +612,7 @@ class ViewTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteInteractive() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->args = array();
$this->Task->params = array();
@@ -658,7 +657,7 @@ class ViewTaskTest extends CakeTestCase {
* @return void
*/
public function testExecuteWithAlternateTemplates() {
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->args = array('ViewTaskComments', 'index', 'list');
$this->Task->params = array();
@@ -677,7 +676,7 @@ class ViewTaskTest extends CakeTestCase {
*/
public function testExecuteInteractiveWithAdmin() {
Configure::write('Routing.prefixes', array('admin'));
- $this->Task->connection = 'test_suite';
+ $this->Task->connection = 'test';
$this->Task->args = array();
$this->Task->Controller->expects($this->once())->method('getName')
diff --git a/cake/tests/cases/console/libs/testsuite.test.php b/cake/tests/cases/console/libs/testsuite.test.php
index d2be623f5..b790e72a6 100644
--- a/cake/tests/cases/console/libs/testsuite.test.php
+++ b/cake/tests/cases/console/libs/testsuite.test.php
@@ -44,7 +44,7 @@ class TestSuiteShellTest extends CakeTestCase {
public function setUp() {
$this->Dispatcher = $this->getMock(
'ShellDispatcher',
- array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
+ array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
);
$this->Shell = $this->getMock(
'TestSuiteShell',
diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php
index f6717e6bb..e8290eb7c 100644
--- a/cake/tests/cases/dispatcher.test.php
+++ b/cake/tests/cases/dispatcher.test.php
@@ -18,6 +18,7 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
require_once CAKE . 'dispatcher.php';
+App::import('Core', 'CakeResponse', false);
if (!class_exists('AppController')) {
require_once LIBS . 'controller' . DS . 'app_controller.php';
@@ -25,6 +26,17 @@ if (!class_exists('AppController')) {
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
*
@@ -50,16 +62,6 @@ class TestDispatcher extends Dispatcher {
return $controller;
}
-/**
- * cakeError method
- *
- * @param mixed $filename
- * @return void
- */
- public function cakeError($filename, $params) {
- return array($filename, $params);
- }
-
/**
* _stop method
*
@@ -69,15 +71,6 @@ class TestDispatcher extends Dispatcher {
$this->stopped = true;
return true;
}
-
-/**
- * header method
- *
- * @return void
- */
- public function header() {
-
- }
}
/**
@@ -413,7 +406,7 @@ class SomePostsController extends AppController {
* @package cake
* @subpackage cake.tests.cases
*/
-class TestCachedPagesController extends AppController {
+class TestCachedPagesController extends Controller {
/**
* name property
@@ -437,7 +430,7 @@ class TestCachedPagesController extends AppController {
* @var array
* @access public
*/
- public $helpers = array('Cache');
+ public $helpers = array('Cache', 'Html');
/**
* cacheAction property
@@ -451,6 +444,13 @@ class TestCachedPagesController extends AppController {
'view' => '+2 sec'
);
+/**
+ * Mock out the reponse object so it doesn't send headers.
+ *
+ * @var string
+ */
+ protected $_responseClass = 'DispatcherMockCakeResponse';
+
/**
* viewPath property
*
@@ -502,7 +502,7 @@ class TestCachedPagesController extends AppController {
* @package cake
* @subpackage cake.tests.cases
*/
-class TimesheetsController extends AppController {
+class TimesheetsController extends Controller {
/**
* name property
@@ -562,6 +562,7 @@ class DispatcherTest extends CakeTestCase {
$this->_debug = Configure::read('debug');
App::build(App::core());
+ App::objects('plugin', null, false);
}
/**
@@ -1272,8 +1273,6 @@ class DispatcherTest extends CakeTestCase {
$Dispatcher = new TestDispatcher();
$Dispatcher->response = $this->getMock('CakeResponse', array('_sendHeader'));
- $debug = Configure::read('debug');
- //Configure::write('debug', 0);
try {
$Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css');
@@ -1377,20 +1376,20 @@ class DispatcherTest extends CakeTestCase {
$result = ob_get_clean();
$expected = "alert('plugin one nested js file');";
$this->assertEqual($result, $expected);
- Configure::write('debug', $debug);
- //reset the
-
ob_start();
$Dispatcher->asset('test_plugin/css/unknown.extension');
$result = ob_get_clean();
$this->assertEqual('Testing a file with unknown extension to mime mapping.', $result);
-
ob_start();
$Dispatcher->asset('test_plugin/css/theme_one.htc');
$result = ob_get_clean();
$this->assertEqual('htc file', $result);
+
+ while (ob_get_level() > 0) {
+ ob_get_clean();
+ }
}
/**
@@ -1405,7 +1404,6 @@ class DispatcherTest extends CakeTestCase {
'js' => '',
'css' => null
));
- $this->assertNoErrors();
ob_start();
$Dispatcher->asset('ccss/cake.generic.css');
@@ -1471,7 +1469,6 @@ class DispatcherTest extends CakeTestCase {
), true);
$dispatcher = new TestDispatcher();
- $dispatcher->response = $this->getMock('CakeResponse', array('_sendHeader'));
$url = '/';
ob_start();
diff --git a/cake/tests/cases/libs/all_cache_engines.test.php b/cake/tests/cases/libs/all_cache_engines.test.php
index 70ef53fb8..64d2da93c 100644
--- a/cake/tests/cases/libs/all_cache_engines.test.php
+++ b/cake/tests/cases/libs/all_cache_engines.test.php
@@ -34,16 +34,10 @@ class AllCacheEnginesTest extends PHPUnit_Framework_TestSuite {
* @return void
*/
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');
-
- $cacheIterator = new DirectoryIterator(CORE_TEST_CASES . DS . 'libs' . DS . 'cache');
- foreach ($cacheIterator as $i => $file) {
- if (!$file->isDot()) {
- $suite->addTestfile($file->getPathname());
- }
- }
+ $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'cache');
return $suite;
}
}
diff --git a/cake/tests/cases/libs/all_components.test.php b/cake/tests/cases/libs/all_components.test.php
index 798e0a1d7..6724303ca 100644
--- a/cake/tests/cases/libs/all_components.test.php
+++ b/cake/tests/cases/libs/all_components.test.php
@@ -34,17 +34,11 @@ class AllComponentsTest extends PHPUnit_Framework_TestSuite {
* @return void
*/
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_collection.test.php');
-
- $iterator = new DirectoryIterator(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components');
- foreach ($iterator as $i => $file) {
- if (!$file->isDot()) {
- $suite->addTestfile($file->getPathname());
- }
- }
+ $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components');
return $suite;
}
}
diff --git a/cake/tests/cases/libs/all_helpers.test.php b/cake/tests/cases/libs/all_helpers.test.php
index 0b57fcdaf..389290d27 100644
--- a/cake/tests/cases/libs/all_helpers.test.php
+++ b/cake/tests/cases/libs/all_helpers.test.php
@@ -35,18 +35,11 @@ class AllHelpersTest extends PHPUnit_Framework_TestSuite {
* @return void
*/
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_collection.test.php');
-
- $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());
- }
- }
+ $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS);
return $suite;
}
}
diff --git a/cake/tests/cases/libs/all_libs.test.php b/cake/tests/cases/libs/all_libs.test.php
index 32a196953..3d334d72b 100644
--- a/cake/tests/cases/libs/all_libs.test.php
+++ b/cake/tests/cases/libs/all_libs.test.php
@@ -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 . 'file.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 . 'cake_log.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry.test.php');
diff --git a/cake/tests/cases/libs/all_model.test.php b/cake/tests/cases/libs/all_model.test.php
index 43ef7964b..fb99184c0 100644
--- a/cake/tests/cases/libs/all_model.test.php
+++ b/cake/tests/cases/libs/all_model.test.php
@@ -36,7 +36,7 @@ class AllModelTest extends PHPUnit_Framework_TestSuite {
public static function suite() {
$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_write.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model_validation.test.php');
diff --git a/cake/tests/cases/libs/all_routing.test.php b/cake/tests/cases/libs/all_routing.test.php
index ecf894e02..aaa3134f3 100644
--- a/cake/tests/cases/libs/all_routing.test.php
+++ b/cake/tests/cases/libs/all_routing.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 . '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 . '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');
return $suite;
}
diff --git a/cake/tests/cases/libs/all_tests.test.php b/cake/tests/cases/libs/all_tests.test.php
new file mode 100644
index 000000000..6982a1d3c
--- /dev/null
+++ b/cake/tests/cases/libs/all_tests.test.php
@@ -0,0 +1,61 @@
+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;
+ }
+}
diff --git a/cake/tests/cases/libs/cache.test.php b/cake/tests/cases/libs/cache.test.php
index 8c4d83b65..70c90c4a8 100644
--- a/cake/tests/cases/libs/cache.test.php
+++ b/cake/tests/cases/libs/cache.test.php
@@ -120,14 +120,15 @@ class CacheTest extends CakeTestCase {
*/
function testInvaidConfig() {
$this->expectError();
- Cache::config('Invalid', array(
+ Cache::config('invalid', array(
'engine' => 'File',
'duration' => '+1 year',
'prefix' => 'testing_invalid_',
'path' => 'data/',
- 'serialize' => true
+ 'serialize' => true,
+ 'random' => 'wii'
));
- $read = Cache::read('Test', 'Invalid');
+ $read = Cache::read('Test', 'invalid');
$this->assertEqual($read, null);
}
diff --git a/cake/tests/cases/libs/cache/apc.test.php b/cake/tests/cases/libs/cache/apc.test.php
index dfd86e47f..1991e679a 100644
--- a/cake/tests/cases/libs/cache/apc.test.php
+++ b/cake/tests/cases/libs/cache/apc.test.php
@@ -29,20 +29,6 @@ if (!class_exists('Cache')) {
*/
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
*
@@ -50,6 +36,7 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
function setUp() {
+ $this->skipIf(!function_exists('apc_store'), '%s Apc is not installed or configured properly');
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_'));
diff --git a/cake/tests/cases/libs/cache/file.test.php b/cake/tests/cases/libs/cache/file.test.php
index 038cbd23f..9c71aaf0b 100644
--- a/cake/tests/cases/libs/cache/file.test.php
+++ b/cake/tests/cases/libs/cache/file.test.php
@@ -38,12 +38,12 @@ class FileEngineTest extends CakeTestCase {
public $config = array();
/**
- * startCase method
+ * setUp method
*
* @access public
* @return void
*/
- function startCase() {
+ function setUp() {
$this->_cacheDisable = Configure::read('Cache.disable');
$this->_cacheConfig = Cache::config('default');
Configure::write('Cache.disable', false);
@@ -51,12 +51,13 @@ class FileEngineTest extends CakeTestCase {
}
/**
- * endCase method
+ * teardown method
*
* @access public
* @return void
*/
- function endCase() {
+ function tearDown() {
+ Cache::clear(false, 'default');
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default', $this->_cacheConfig['settings']);
}
diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/cake/tests/cases/libs/cache/memcache.test.php
index 819c15476..63d18485e 100644
--- a/cake/tests/cases/libs/cache/memcache.test.php
+++ b/cake/tests/cases/libs/cache/memcache.test.php
@@ -29,20 +29,6 @@ if (!class_exists('Cache')) {
*/
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
*
@@ -50,6 +36,7 @@ class MemcacheEngineTest extends CakeTestCase {
* @return void
*/
function setUp() {
+ $this->skipIf(!class_exists('Memcache'), '%s Apc is not installed or configured properly');
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('memcache', array(
@@ -315,4 +302,19 @@ class MemcacheEngineTest extends CakeTestCase {
$this->assertTrue($result);
$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!');
+
+ }
+
}
diff --git a/cake/tests/cases/libs/cake_log.test.php b/cake/tests/cases/libs/cake_log.test.php
index 12b787426..eaa1f9337 100644
--- a/cake/tests/cases/libs/cake_log.test.php
+++ b/cake/tests/cases/libs/cake_log.test.php
@@ -33,7 +33,8 @@ class CakeLogTest extends CakeTestCase {
*
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$streams = CakeLog::configured();
foreach ($streams as $stream) {
CakeLog::drop($stream);
diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php
index 550240baa..b42d9413d 100644
--- a/cake/tests/cases/libs/cake_request.test.php
+++ b/cake/tests/cases/libs/cake_request.test.php
@@ -28,25 +28,25 @@ class CakeRequestTestCase extends CakeTestCase {
*
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$this->_server = $_SERVER;
$this->_get = $_GET;
$this->_post = $_POST;
$this->_files = $_FILES;
- $this->_app = Configure::read('App');
}
/**
- * end test
+ * tearDown-
*
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
$_SERVER = $this->_server;
$_GET = $this->_get;
$_POST = $this->_post;
$_FILES = $this->_files;
- Configure::write('App', $this->_app);
}
/**
@@ -742,6 +742,8 @@ class CakeRequestTestCase extends CakeTestCase {
* @return void
*/
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);
$this->assertEquals($_SERVER['HTTP_HOST'], $request->header('host'));
diff --git a/cake/tests/cases/libs/cake_response.test.php b/cake/tests/cases/libs/cake_response.test.php
index 80c2a6a76..7e809cc80 100644
--- a/cake/tests/cases/libs/cake_response.test.php
+++ b/cake/tests/cases/libs/cake_response.test.php
@@ -4,7 +4,6 @@ App::import('Core', 'CakeResponse');
class CakeResponseTestCase extends CakeTestCase {
-
/**
* Tests the request object constructor
*
@@ -283,6 +282,8 @@ class CakeResponseTestCase extends CakeTestCase {
$result = $response->compress();
$this->assertTrue($result);
$this->assertTrue(in_array('ob_gzhandler', ob_list_handlers()));
+
+ ob_get_clean();
}
/**
diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php
index 02086b01f..f24fff1ec 100644
--- a/cake/tests/cases/libs/cake_session.test.php
+++ b/cake/tests/cases/libs/cake_session.test.php
@@ -116,7 +116,7 @@ class CakeSessionTest extends CakeTestCase {
$_SESSION = null;
Configure::write('Session', array(
- 'cookie' => 'test_suite',
+ 'cookie' => 'test',
'checkAgent' => false,
'timeout' => 86400,
'ini' => array(
@@ -127,7 +127,7 @@ class CakeSessionTest extends CakeTestCase {
TestCakeSession::start();
$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('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.handler.table', 'sessions');
Configure::write('Session.handler.model', 'Session');
- Configure::write('Session.handler.database', 'test_suite');
+ Configure::write('Session.handler.database', 'test');
TestCakeSession::init();
TestCakeSession::start();
diff --git a/cake/tests/cases/libs/cake_socket.test.php b/cake/tests/cases/libs/cake_socket.test.php
index 31f71b7f5..a2200d3e8 100644
--- a/cake/tests/cases/libs/cake_socket.test.php
+++ b/cake/tests/cases/libs/cake_socket.test.php
@@ -145,13 +145,13 @@ class CakeSocketTest extends CakeTestCase {
$this->Socket->connect();
$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->assertTrue($this->Socket->connect());
$this->assertFalse($this->Socket->read(1024 * 1024));
$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->assertTrue($this->Socket->connect());
$this->assertEqual($this->Socket->read(26), null);
diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/cake/tests/cases/libs/cake_test_case.test.php
index 9aa577be1..131430e7e 100644
--- a/cake/tests/cases/libs/cake_test_case.test.php
+++ b/cake/tests/cases/libs/cake_test_case.test.php
@@ -19,6 +19,8 @@
* @since CakePHP v 1.2.0.4487
* @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')) {
require_once LIBS . 'controller' . DS . 'app_controller.php';
diff --git a/cake/tests/cases/libs/cake_test_fixture.test.php b/cake/tests/cases/libs/cake_test_fixture.test.php
index a56bb94cf..c93317381 100644
--- a/cake/tests/cases/libs/cake_test_fixture.test.php
+++ b/cake/tests/cases/libs/cake_test_fixture.test.php
@@ -112,14 +112,14 @@ class CakeTestFixtureDefaultImportFixture extends CakeTestFixture {
class FixtureImportTestModel extends Model {
public $name = 'FixtureImport';
public $useTable = 'fixture_tests';
- public $useDbConfig = 'test_suite';
+ public $useDbConfig = 'test';
}
class FixturePrefixTest extends Model {
public $name = 'FixturePrefix';
public $useTable = '_tests';
public $tablePrefix = 'fixture';
- public $useDbConfig = 'test_suite';
+ public $useDbConfig = 'test';
}
/**
@@ -139,12 +139,8 @@ class CakeTestFixtureTest extends CakeTestCase {
function setUp() {
$this->criticDb = $this->getMock('DboSource');
$this->criticDb->fullDebug = true;
-
- $dbs = ConnectionManager::enumConnectionObjects();
- if (!isset($dbs['test_suite'])) {
- $db = ConnectionManager::getDatasource('test');
- ConnectionManager::create('test_suite', $db->config);
- }
+ $this->db = ConnectionManager::getDataSource('test');
+ $this->_backupConfig = $this->db->config;
}
/**
@@ -155,6 +151,7 @@ class CakeTestFixtureTest extends CakeTestCase {
*/
function tearDown() {
unset($this->criticDb);
+ $this->db->config = $this->_backupConfig;
}
/**
@@ -183,7 +180,7 @@ class CakeTestFixtureTest extends CakeTestCase {
* @return void
*/
function testInitDbPrefix() {
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$Source = new CakeTestFixtureTestFixture();
$Source->drop($db);
$Source->create($db);
@@ -198,14 +195,14 @@ class CakeTestFixtureTest extends CakeTestCase {
ConnectionManager::create('fixture_test_suite', $config);
$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();
$this->assertEqual(count($Fixture->records), count($Source->records));
$Fixture->create(ConnectionManager::getDataSource('fixture_test_suite'));
- $Fixture =& new CakeTestFixtureImportFixture();
+ $Fixture = new CakeTestFixtureImportFixture();
$Fixture->fields = $Fixture->records = $Fixture->table = null;
- $Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test_suite');
+ $Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test');
$Fixture->init();
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
$this->assertEqual($Fixture->table, 'fixture_tests');
@@ -223,24 +220,27 @@ class CakeTestFixtureTest extends CakeTestCase {
* @return void
*/
function testInitDbPrefixDuplication() {
- $this->_initDb();
- $backPrefix = $this->db->config['prefix'];
- $this->db->config['prefix'] = 'cake_fixture_test_';
+ $db = ConnectionManager::getDataSource('test');
+ $backPrefix = $db->config['prefix'];
+ $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->create($this->db);
- $Source->insert($this->db);
+ $Source = new CakeTestFixtureTestFixture();
+ $Source->create($db);
+ $Source->insert($db);
- $Fixture =& new CakeTestFixtureImportFixture();
+ $Fixture = new CakeTestFixtureImportFixture();
$Fixture->fields = $Fixture->records = $Fixture->table = null;
- $Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test_suite');
+ $Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test');
$Fixture->init();
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));
$this->assertEqual($Fixture->table, 'fixture_tests');
- $Source->drop($this->db);
- $this->db->config['prefix'] = $backPrefix;
+ $Source->drop($db);
+ $db->config['prefix'] = $backPrefix;
}
/**
@@ -249,26 +249,25 @@ class CakeTestFixtureTest extends CakeTestCase {
* @return void
*/
function testInitModelTablePrefix() {
- $this->_initDb();
$hasPrefix = !empty($this->db->config['prefix']);
if ($this->skipIf($hasPrefix, 'Cannot run this test, you have a database connection prefix.')) {
return;
}
- $Source =& new CakeTestFixtureTestFixture();
- $Source->create($db);
- $Source->insert($db);
+ $Source = new CakeTestFixtureTestFixture();
+ $Source->create($this->db);
+ $Source->insert($this->db);
- $Fixture =& new CakeTestFixtureTestFixture();
+ $Fixture = new CakeTestFixtureTestFixture();
unset($Fixture->table);
$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();
$this->assertEqual($Fixture->table, 'fixture_tests');
$keys = array_flip(ClassRegistry::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() {
$defaultDb = ConnectionManager::getDataSource('default');
- $testSuiteDb = ConnectionManager::getDataSource('test_suite');
+ $testSuiteDb = ConnectionManager::getDataSource('test');
$defaultConfig = $defaultDb->config;
$testSuiteConfig = $testSuiteDb->config;
ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix'])));
@@ -314,7 +313,7 @@ class CakeTestFixtureTest extends CakeTestCase {
function testImportWithRecords() {
$defaultDb = ConnectionManager::getDataSource('default');
- $testSuiteDb = ConnectionManager::getDataSource('test_suite');
+ $testSuiteDb = ConnectionManager::getDataSource('test');
$defaultConfig = $defaultDb->config;
$testSuiteConfig = $testSuiteDb->config;
ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix'])));
diff --git a/cake/tests/cases/libs/class_registry.test.php b/cake/tests/cases/libs/class_registry.test.php
index 6c8a00c58..ae40bb53e 100644
--- a/cake/tests/cases/libs/class_registry.test.php
+++ b/cake/tests/cases/libs/class_registry.test.php
@@ -211,6 +211,8 @@ class ClassRegistryTest extends CakeTestCase {
* @return void
*/
function testClassRegistryFlush() {
+ $Tag = ClassRegistry::init('RegisterArticleTag');
+
$ArticleTag = ClassRegistry::getObject('RegisterArticleTag');
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
ClassRegistry::flush();
diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php
index 729320151..61e7b1e5d 100644
--- a/cake/tests/cases/libs/configure.test.php
+++ b/cake/tests/cases/libs/configure.test.php
@@ -40,16 +40,8 @@ class ConfigureTest extends CakeTestCase {
$this->_debug = Configure::read('debug');
Configure::write('Cache.disable', true);
- }
-
-/**
- * endTest
- *
- * @access public
- * @return void
- */
- function endTest() {
App::build();
+ App::objects('plugin', null, true);
}
/**
@@ -397,27 +389,27 @@ class AppImportTest extends CakeTestCase {
* @return void
*/
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('Cache', $result));
$this->assertTrue(in_array('HttpSocket', $result));
- $result = App::objects('behavior');
+ $result = App::objects('behavior', null, false);
$this->assertTrue(in_array('Tree', $result));
- $result = App::objects('controller');
+ $result = App::objects('controller', null, false);
$this->assertTrue(in_array('Pages', $result));
- $result = App::objects('component');
+ $result = App::objects('component', null, false);
$this->assertTrue(in_array('Auth', $result));
- $result = App::objects('view');
+ $result = App::objects('view', null, false);
$this->assertTrue(in_array('Media', $result));
- $result = App::objects('helper');
+ $result = App::objects('helper', null, false);
$this->assertTrue(in_array('Html', $result));
- $result = App::objects('model');
+ $result = App::objects('model', null, false);
$notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
foreach ($notExpected as $class) {
$this->assertFalse(in_array($class, $result));
@@ -714,6 +706,9 @@ class AppImportTest extends CakeTestCase {
* @return void
*/
function testMultipleLoading() {
+ if (class_exists('I18n', false) || class_exists('CakeSocket', false)) {
+ $this->markTestSkipped('Cannot test loading of classes that exist.');
+ }
$toLoad = array('I18n', 'CakeSocket');
$classes = array_flip(get_declared_classes());
diff --git a/cake/tests/cases/libs/controller/components/acl.test.php b/cake/tests/cases/libs/controller/components/acl.test.php
index 9e66bde52..6d1ae1943 100644
--- a/cake/tests/cases/libs/controller/components/acl.test.php
+++ b/cake/tests/cases/libs/controller/components/acl.test.php
@@ -30,10 +30,10 @@ class AclNodeTwoTestBase extends AclNode {
/**
* useDbConfig property
*
- * @var string 'test_suite'
+ * @var string 'test'
* @access public
*/
- public $useDbConfig = 'test_suite';
+ public $useDbConfig = 'test';
/**
* cacheSources property
@@ -189,12 +189,12 @@ class DbAclTwoTest extends DbAcl {
*/
class AclComponentTest extends CakeTestCase {
/**
- * startTest method
+ * setUp method
*
- * @access public
* @return void
*/
function setUp() {
+ parent::setUp();
if (!class_exists('MockAclImplementation', false)) {
$this->getMock('AclInterface', array(), array(), 'MockAclImplementation');
}
@@ -206,10 +206,10 @@ class AclComponentTest extends CakeTestCase {
/**
* tearDown method
*
- * @access public
* @return void
*/
function tearDown() {
+ parent::tearDown();
unset($this->Acl);
}
@@ -347,16 +347,14 @@ class DbAclTest extends CakeTestCase {
public $fixtures = array('core.aro_two', 'core.aco_two', 'core.aros_aco_two');
/**
- * startTest method
+ * setUp method
*
- * @access public
* @return void
*/
- function startTest() {
- $this->_settings = Configure::read('Acl');
-
+ function setUp() {
+ parent::setUp();
Configure::write('Acl.classname', 'DbAclTwoTest');
- Configure::write('Acl.database', 'test_suite');
+ Configure::write('Acl.database', 'test');
$Collection = new ComponentCollection();
$this->Acl = new AclComponent($Collection);
}
@@ -367,9 +365,9 @@ class DbAclTest extends CakeTestCase {
* @access public
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->Acl);
- Configure::write('Acl', $this->_settings);
}
/**
diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php
index 275c1e884..a8d5bfbef 100644
--- a/cake/tests/cases/libs/controller/components/auth.test.php
+++ b/cake/tests/cases/libs/controller/components/auth.test.php
@@ -76,10 +76,10 @@ class AuthUser extends CakeTestModel {
/**
* useDbConfig property
*
- * @var string 'test_suite'
+ * @var string 'test'
* @access public
*/
- public $useDbConfig = 'test_suite';
+ public $useDbConfig = 'test';
/**
* parentNode method
@@ -155,10 +155,10 @@ class UuidUser extends CakeTestModel {
/**
* useDbConfig property
*
- * @var string 'test_suite'
+ * @var string 'test'
* @access public
*/
- public $useDbConfig = 'test_suite';
+ public $useDbConfig = 'test';
/**
* useTable property
@@ -473,22 +473,20 @@ class AuthTest extends CakeTestCase {
public $initialized = false;
/**
- * startTest method
+ * setUp method
*
* @access public
* @return void
*/
function setUp() {
+ parent::setUp();
$this->_server = $_SERVER;
$this->_env = $_ENV;
- $this->_securitySalt = Configure::read('Security.salt');
- $this->_securityCipher = Configure::read('Security.cipherSeed');
Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
Configure::write('Security.cipherSeed', 770011223369876);
- $this->_acl = Configure::read('Acl');
- Configure::write('Acl.database', 'test_suite');
+ Configure::write('Acl.database', 'test');
Configure::write('Acl.classname', 'DbAcl');
$request = new CakeRequest(null, false);
@@ -505,27 +503,22 @@ class AuthTest extends CakeTestCase {
$this->Controller->Session->delete('Auth');
$this->Controller->Session->delete('Message.auth');
- Router::reload();
-
$this->initialized = true;
+ Router::reload();
}
/**
- * endTest method
+ * tearDown method
*
- * @access public
* @return void
*/
function tearDown() {
+ parent::tearDown();
$_SERVER = $this->_server;
$_ENV = $this->_env;
- Configure::write('Acl', $this->_acl);
- Configure::write('Security.salt', $this->_securitySalt);
- Configure::write('Security.cipherSeed', $this->_securityCipher);
$this->Controller->Session->delete('Auth');
$this->Controller->Session->delete('Message.auth');
- ClassRegistry::flush();
unset($this->Controller, $this->AuthUser);
}
@@ -957,11 +950,9 @@ class AuthTest extends CakeTestCase {
* @return void
*/
function testLoginRedirect() {
- $backup = null;
- if (isset($_SERVER['HTTP_REFERER'])) {
- $backup = $_SERVER['HTTP_REFERER'];
- }
$_SERVER['HTTP_REFERER'] = false;
+ $_ENV['HTTP_REFERER'] = false;
+ putenv('HTTP_REFERER=');
$this->Controller->Session->write('Auth', array(
'AuthUser' => array('id' => '1', 'username' => 'nate')
@@ -1017,13 +1008,12 @@ class AuthTest extends CakeTestCase {
$expected = Router::normalize('/');
$this->assertEqual($expected, $this->Controller->testUrl);
-
$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(
'AuthUser' => array('id'=>'1', 'username' => 'nate')
));
+ $this->Controller->request->params['action'] = 'login';
$this->Controller->request->query['url'] = 'auth_test/login';
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = 'auth_test/login';
@@ -1124,7 +1114,6 @@ class AuthTest extends CakeTestCase {
$expected = Router::normalize('/');
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
- $_SERVER['HTTP_REFERER'] = $backup;
$this->Controller->Session->delete('Auth');
}
diff --git a/cake/tests/cases/libs/controller/components/cookie.test.php b/cake/tests/cases/libs/controller/components/cookie.test.php
index ebf7c08aa..b60ce792b 100644
--- a/cake/tests/cases/libs/controller/components/cookie.test.php
+++ b/cake/tests/cases/libs/controller/components/cookie.test.php
@@ -75,8 +75,9 @@ class CookieComponentTest extends CakeTestCase {
* @return void
*/
function setUp() {
+ $_COOKIE = array();
$Collection = new ComponentCollection();
- $this->Cookie = new CookieComponent($Collection);
+ $this->Cookie = $this->getMock('CookieComponent', array('_setcookie'), array($Collection));
$this->Controller = new CookieComponentTestController();
$this->Cookie->initialize($this->Controller);
@@ -86,7 +87,7 @@ class CookieComponentTest extends CakeTestCase {
$this->Cookie->domain = '';
$this->Cookie->secure = false;
$this->Cookie->key = 'somerandomhaskey';
-
+
$this->Cookie->startup($this->Controller);
}
@@ -100,6 +101,11 @@ class CookieComponentTest extends CakeTestCase {
$this->Cookie->destroy();
}
+/**
+ * sets up some default cookie data.
+ *
+ * @return void
+ */
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_multi_cookies.name' => 'CakePHP'));
@@ -172,6 +178,48 @@ class CookieComponentTest extends CakeTestCase {
$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
*
diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php
index bc8786cb5..f5e128ccf 100755
--- a/cake/tests/cases/libs/controller/components/email.test.php
+++ b/cake/tests/cases/libs/controller/components/email.test.php
@@ -19,6 +19,7 @@
* @since CakePHP(tm) v 1.2.0.5347
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
+App::import('Core', 'Controller');
App::import('Component', 'Email');
App::import('Core', 'CakeSocket');
@@ -895,6 +896,7 @@ HTMLBLOC;
if ($this->skipIf($skip, 'Missing mb_* functions, cannot run test.')) {
return;
}
+ $restore = mb_internal_encoding();
mb_internal_encoding('ISO-8859-1');
$this->Controller->charset = 'UTF-8';
@@ -915,6 +917,8 @@ HTMLBLOC;
$result = mb_internal_encoding();
$this->assertEqual($result, 'ISO-8859-1');
+
+ mb_internal_encoding($restore);
}
/**
diff --git a/cake/tests/cases/libs/controller/components/request_handler.test.php b/cake/tests/cases/libs/controller/components/request_handler.test.php
index 6e971b93e..1589278ca 100644
--- a/cake/tests/cases/libs/controller/components/request_handler.test.php
+++ b/cake/tests/cases/libs/controller/components/request_handler.test.php
@@ -264,6 +264,27 @@ class RequestHandlerComponentTest extends CakeTestCase {
$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
*
diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php
index fd6767950..b6b76cfbd 100644
--- a/cake/tests/cases/libs/controller/components/security.test.php
+++ b/cake/tests/cases/libs/controller/components/security.test.php
@@ -143,25 +143,26 @@ class SecurityComponentTest extends CakeTestCase {
* @access public
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
+
$request = new CakeRequest('posts/index', false);
$request->addParams(array('controller' => 'posts', 'action' => 'index'));
$this->Controller = new SecurityTestController($request);
$this->Controller->Components->init($this->Controller);
$this->Controller->Security = $this->Controller->TestSecurity;
$this->Controller->Security->blackHoleCallback = 'fail';
- $this->oldSalt = Configure::read('Security.salt');
+
Configure::write('Security.salt', 'foo!');
}
/**
* Tear-down method. Resets environment state.
*
- * @access public
* @return void
*/
- function endTest() {
- Configure::write('Security.salt', $this->oldSalt);
+ function tearDown() {
+ parent::tearDown();
$this->Controller->Session->delete('_Token');
unset($this->Controller->Security);
unset($this->Controller->Component);
diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/cake/tests/cases/libs/controller/components/session.test.php
index 5c9d2cf44..24779d843 100644
--- a/cake/tests/cases/libs/controller/components/session.test.php
+++ b/cake/tests/cases/libs/controller/components/session.test.php
@@ -99,7 +99,7 @@ class SessionComponentTest extends CakeTestCase {
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 100,
- 'cookie' => 'test_suite'
+ 'cookie' => 'test'
));
}
diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php
index 5ad875016..0f2e6d2fc 100644
--- a/cake/tests/cases/libs/controller/controller.test.php
+++ b/cake/tests/cases/libs/controller/controller.test.php
@@ -445,12 +445,23 @@ class ControllerTest extends CakeTestCase {
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
* @return void
*/
- function endTest() {
+ function teardown() {
App::build();
}
@@ -857,6 +868,8 @@ class ControllerTest extends CakeTestCase {
*/
function testFlash() {
$request = new CakeRequest('controller_posts/index');
+ $request->webroot = '/';
+ $request->base = '/';
$Controller = new Controller($request);
$Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
@@ -928,6 +941,13 @@ class ControllerTest extends CakeTestCase {
$expected = array('ModelName' => 'name', 'ModelName2' => 'name2');
$Controller->set(array('ModelName', 'ModelName2'), array('name', 'name2'));
$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);
$Controller = new TestController($request);
+ $Controller->helpers = array('Html');
$Controller->constructClasses();
$Controller->ControllerComment->validationErrors = array('title' => 'tooShort');
$expected = $Controller->ControllerComment->validationErrors;
diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php
index 65de0bb1b..65f574d56 100644
--- a/cake/tests/cases/libs/controller/scaffold.test.php
+++ b/cake/tests/cases/libs/controller/scaffold.test.php
@@ -275,14 +275,16 @@ class ScaffoldViewTest extends CakeTestCase {
public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag');
/**
- * startTest method
+ * setUp method
*
* @access public
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$this->request = new CakeRequest(null, false);
$this->Controller = new ScaffoldMockController($this->request);
+ $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
App::build(array(
'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
*/
- function endTest() {
- unset($this->Controller);
-
- App::build();
+ function tearDown() {
+ parent::tearDown();
+ unset($this->Controller, $this->request);
}
/**
@@ -579,23 +579,21 @@ class ScaffoldViewTest extends CakeTestCase {
* @return void
*/
function testAdminEditScaffold() {
- $_backAdmin = Configure::read('Routing.prefixes');
-
Configure::write('Routing.prefixes', array('admin'));
$params = array(
'plugin' => null,
- 'pass' => array(),
+ 'pass' => array(1),
'form' => array(),
'named' => array(),
'prefix' => 'admin',
- 'url' => array('url' =>'admin/scaffold_mock/edit'),
+ 'url' => array('url' =>'admin/scaffold_mock/edit/1'),
'controller' => 'scaffold_mock',
'action' => 'admin_edit',
'admin' => 1,
);
$this->Controller->request->base = '';
$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);
//reset, and set router.
@@ -611,8 +609,6 @@ class ScaffoldViewTest extends CakeTestCase {
$this->assertPattern('#admin/scaffold_mock/edit/1#', $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');
/**
- * startTest method
+ * setUp method
*
- * @access public
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$request = new CakeRequest(null, false);
$this->Controller = new ScaffoldMockController($request);
+ $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
}
/**
- * endTest method
+ * tearDown method
*
- * @access public
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->Controller);
}
@@ -776,9 +773,6 @@ class ScaffoldTest extends CakeTestCase {
$this->assertEqual($result['pluralVar'], 'scaffoldMock');
$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'
@@ -875,6 +869,8 @@ class ScaffoldTest extends CakeTestCase {
function testEditScaffoldWithScaffoldFields() {
$request = new CakeRequest(null, false);
$this->Controller = new ScaffoldMockControllerWithFields($request);
+ $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
+
$params = array(
'plugin' => null,
'pass' => array(1),
diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php
index ca332bd8c..b9af5f127 100644
--- a/cake/tests/cases/libs/debugger.test.php
+++ b/cake/tests/cases/libs/debugger.test.php
@@ -218,14 +218,9 @@ class DebuggerTest extends CakeTestCase {
$result = Debugger::exportVar($View);
$expected = 'View
View::$Helpers = HelperCollection object
- View::$base = NULL
- View::$here = NULL
View::$plugin = NULL
View::$name = ""
- View::$action = NULL
- View::$params = array
View::$passedArgs = array
- View::$data = array
View::$helpers = array
View::$viewPath = ""
View::$viewVars = array
@@ -247,7 +242,6 @@ class DebuggerTest extends CakeTestCase {
View::$modelId = NULL
View::$uuids = array
View::$output = false
- View::$webroot = NULL
View::$request = NULL';
$result = str_replace(array("\t", "\r\n", "\n"), "", strtolower($result));
$expected = str_replace(array("\t", "\r\n", "\n"), "", strtolower($expected));
diff --git a/cake/tests/cases/libs/error_handler.test.php b/cake/tests/cases/libs/error_handler.test.php
index a57de787d..eea5de049 100644
--- a/cake/tests/cases/libs/error_handler.test.php
+++ b/cake/tests/cases/libs/error_handler.test.php
@@ -44,52 +44,6 @@ class AuthBlueberryUser extends CakeTestModel {
*/
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
@@ -124,7 +78,7 @@ class BlueberryComponent extends Component {
* @package cake
* @subpackage cake.tests.cases.libs
*/
-class TestErrorController extends AppController {
+class TestErrorController extends Controller {
/**
* uses property
@@ -134,6 +88,24 @@ class TestErrorController extends AppController {
*/
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
*
@@ -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
*
@@ -204,31 +151,45 @@ class MissingWidgetThingException extends NotFoundException { }
*/
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.
*
* @return void
*/
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->base = '';
Router::setRequestInfo($request);
$this->_debug = Configure::read('debug');
}
+/**
+ * teardown
+ *
+ * @return void
+ */
function teardown() {
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.
@@ -239,6 +200,9 @@ class ErrorHandlerTest extends CakeTestCase {
if ($this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.')) {
return;
}
+ if ($this->skipIf(PHP_SAPI == 'cli', 'This integration test can not be run in cli.')) {
+ return;
+ }
$error = new NotFoundException('Kaboom!');
ob_start();
ErrorHandler::handleException($error);
@@ -256,7 +220,7 @@ class ErrorHandlerTest extends CakeTestCase {
Configure::write('debug', 2);
$exception = new MissingWidgetThingException('Widget not found');
- $ErrorHandler = new MyCustomErrorHandler($exception);
+ $ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception));
ob_start();
$ErrorHandler->render();
@@ -273,7 +237,7 @@ class ErrorHandlerTest extends CakeTestCase {
function testSubclassMethodsNotBeingConvertedDebug0() {
Configure::write('debug', 0);
$exception = new MissingWidgetThingException('Widget not found');
- $ErrorHandler = new MyCustomErrorHandler($exception);
+ $ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception));
$this->assertEqual('missingWidgetThing', $ErrorHandler->method);
@@ -293,7 +257,7 @@ class ErrorHandlerTest extends CakeTestCase {
Configure::write('debug', 0);
$exception = new MissingControllerException('PostsController');
- $ErrorHandler = new MyCustomErrorHandler($exception);
+ $ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception));
$this->assertEqual('error400', $ErrorHandler->method);
@@ -341,7 +305,7 @@ class ErrorHandlerTest extends CakeTestCase {
function testUnknownExceptionTypeWithExceptionThatHasA400Code() {
$exception = new MissingWidgetThingException('coding fail.');
$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);
ob_start();
@@ -360,7 +324,7 @@ class ErrorHandlerTest extends CakeTestCase {
function testUnknownExceptionTypeWithNoCodeIsA500() {
$exception = new OutOfBoundsException('foul ball.');
$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);
ob_start();
@@ -376,10 +340,7 @@ class ErrorHandlerTest extends CakeTestCase {
* @access public
* @return void
*/
- function testerror400() {
- App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)
- ), true);
+ function testError400() {
Router::reload();
$request = new CakeRequest('posts/view/1000', false);
@@ -387,7 +348,7 @@ class ErrorHandlerTest extends CakeTestCase {
$exception = new NotFoundException('Custom message');
$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);
ob_start();
@@ -396,8 +357,6 @@ class ErrorHandlerTest extends CakeTestCase {
$this->assertPattern('/Custom message<\/h2>/', $result);
$this->assertPattern("/'\/posts\/view\/1000'<\/strong>/", $result);
-
- App::build();
}
/**
@@ -409,7 +368,7 @@ class ErrorHandlerTest extends CakeTestCase {
Configure::write('debug', 0);
$exception = new NotFoundException('Custom message');
- $ErrorHandler = new ErrorHandler($exception);
+ $ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
ob_start();
$ErrorHandler->render();
@@ -417,7 +376,7 @@ class ErrorHandlerTest extends CakeTestCase {
$this->assertContains('Custom message', $result);
$exception = new MissingActionException(array('controller' => 'PostsController', 'action' => 'index'));
- $ErrorHandler = new ErrorHandler($exception);
+ $ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
ob_start();
$ErrorHandler->render();
@@ -436,7 +395,7 @@ class ErrorHandlerTest extends CakeTestCase {
Router::setRequestInfo($request);
$exception = new NotFoundException('Custom message');
- $ErrorHandler = new ErrorHandler($exception);
+ $ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
ob_start();
$ErrorHandler->render();
@@ -455,7 +414,7 @@ class ErrorHandlerTest extends CakeTestCase {
function testError500Message() {
$exception = new InternalErrorException('An Internal Error Has Occurred');
$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);
ob_start();
@@ -472,10 +431,8 @@ class ErrorHandlerTest extends CakeTestCase {
* @return void
*/
function testMissingController() {
- $this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController');
-
$exception = new MissingControllerException(array('controller' => 'PostsController'));
- $ErrorHandler = new ErrorHandler($exception);
+ $ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
ob_start();
$ErrorHandler->render();
@@ -483,20 +440,8 @@ class ErrorHandlerTest extends CakeTestCase {
$this->assertPattern('/Missing Controller<\/h2>/', $result);
$this->assertPattern('/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('/Missing Method in BlueberryController<\/h2>/', $result);
- $this->assertPattern('/BlueberryController::<\/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.
*
@@ -624,7 +569,7 @@ class ErrorHandlerTest extends CakeTestCase {
*/
function testCakeExceptionHandling($exception, $patterns, $code) {
$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($code);
diff --git a/cake/tests/cases/libs/i18n.test.php b/cake/tests/cases/libs/i18n.test.php
index ae99f99da..55f13095e 100644
--- a/cake/tests/cases/libs/i18n.test.php
+++ b/cake/tests/cases/libs/i18n.test.php
@@ -54,6 +54,50 @@ class I18nTest extends CakeTestCase {
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
*
diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php
index 4dab49f49..edf434e9b 100644
--- a/cake/tests/cases/libs/inflector.test.php
+++ b/cake/tests/cases/libs/inflector.test.php
@@ -35,12 +35,14 @@ App::import('Core', 'Inflector');
class InflectorTest extends CakeTestCase {
/**
- * Inflector property
+ * teardown
*
- * @var mixed null
- * @access public
+ * @return void
*/
- public $Inflector = null;
+ function tearDown() {
+ parent::tearDown();
+ Inflector::reset();
+ }
/**
* testInflectingSingulars method
diff --git a/cake/tests/cases/libs/model/behavior_collection.test.php b/cake/tests/cases/libs/model/behavior_collection.test.php
index ebfa9fcbb..fcdc414a3 100644
--- a/cake/tests/cases/libs/model/behavior_collection.test.php
+++ b/cake/tests/cases/libs/model/behavior_collection.test.php
@@ -918,23 +918,23 @@ class BehaviorCollectionTest extends CakeTestCase {
$this->assertIdentical($Apple->delete(4), false);
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'test2'));
- if (ob_start()) {
- $results = $Apple->delete(4);
- $this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success (cascading)');
- $this->assertIdentical($results, true);
- }
- if (ob_start()) {
- $results = $Apple->delete(3, false);
- $this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success');
- $this->assertIdentical($results, true);
- }
+
+ ob_start();
+ $results = $Apple->delete(4);
+ $this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success (cascading)');
+ $this->assertIdentical($results, true);
+
+ ob_start();
+ $results = $Apple->delete(3, false);
+ $this->assertIdentical(trim(ob_get_clean()), 'beforeDelete success');
+ $this->assertIdentical($results, true);
+
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on'));
- if (ob_start()) {
- $results = $Apple->delete(2, false);
- $this->assertIdentical(trim(ob_get_clean()), 'afterDelete success');
- $this->assertIdentical($results, true);
- }
+ ob_start();
+ $results = $Apple->delete(2, false);
+ $this->assertIdentical(trim(ob_get_clean()), 'afterDelete success');
+ $this->assertIdentical($results, true);
}
/**
* testBehaviorOnErrorCallback method
@@ -946,15 +946,9 @@ class BehaviorCollectionTest extends CakeTestCase {
$Apple = new Apple();
$Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'onError' => 'on'));
- if (ob_start()) {
- $Apple->Behaviors->Test->onError($Apple);
- $this->assertIdentical(trim(ob_get_clean()), 'onError trigger success');
- }
-
- if (ob_start()) {
- $Apple->delete(99);
- //$this->assertIdentical(trim(ob_get_clean()), 'onError trigger success');
- }
+ ob_start();
+ $Apple->Behaviors->Test->onError($Apple);
+ $this->assertIdentical(trim(ob_get_clean()), 'onError trigger success');
}
/**
* testBehaviorValidateCallback method
diff --git a/cake/tests/cases/libs/model/behaviors/acl.test.php b/cake/tests/cases/libs/model/behaviors/acl.test.php
index d688ae5eb..eca7dcabb 100644
--- a/cake/tests/cases/libs/model/behaviors/acl.test.php
+++ b/cake/tests/cases/libs/model/behaviors/acl.test.php
@@ -222,7 +222,7 @@ class AclBehaviorTest extends CakeTestCase {
* @return void
*/
public function setUp() {
- Configure::write('Acl.database', 'test_suite');
+ Configure::write('Acl.database', 'test');
$this->Aco = new Aco();
$this->Aro = new Aro();
@@ -347,7 +347,7 @@ class AclBehaviorTest extends CakeTestCase {
);
$this->Aro->save($aroData);
- $Person =& new AclPerson();
+ $Person = new AclPerson();
$data = array(
'AclPerson' => array(
'name' => 'Trent',
diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php
index d22f2b653..19a7d47b3 100644
--- a/cake/tests/cases/libs/model/cake_schema.test.php
+++ b/cake/tests/cases/libs/model/cake_schema.test.php
@@ -39,10 +39,10 @@ class MyAppSchema extends CakeSchema {
/**
* connection property
*
- * @var string 'test_suite'
+ * @var string 'test'
* @access public
*/
- public $connection = 'test_suite';
+ public $connection = 'test';
/**
* comments property
@@ -519,23 +519,22 @@ class CakeSchemaTest extends CakeTestCase {
/**
* setUp method
*
- * @access public
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$this->Schema = new TestAppSchema();
}
/**
* tearDown method
*
- * @access public
* @return void
*/
function tearDown() {
+ parent::tearDown();
@unlink(TMP . 'tests' . DS .'schema.php');
unset($this->Schema);
- ClassRegistry::flush();
}
/**
@@ -563,16 +562,18 @@ class CakeSchemaTest extends CakeTestCase {
*/
function testSchemaRead() {
$read = $this->Schema->read(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'TestApp',
'models' => array('SchemaPost', 'SchemaComment', 'SchemaTag', 'SchemaDatatype')
));
unset($read['tables']['missing']);
$expected = array('comments', 'datatypes', 'posts', 'posts_tags', 'tags');
- $this->assertEqual(array_keys($read['tables']), $expected);
- foreach ($read['tables'] as $table => $fields) {
- $this->assertEqual(array_keys($fields), array_keys($this->Schema->tables[$table]));
+ foreach ($expected as $table) {
+ $this->assertTrue(isset($read['tables'][$table]), 'Missing table ' . $table);
+ }
+ foreach ($this->Schema->tables as $table => $fields) {
+ $this->assertEqual(array_keys($fields), array_keys($read['tables'][$table]));
}
$this->assertEqual(
@@ -580,7 +581,7 @@ class CakeSchemaTest extends CakeTestCase {
$this->Schema->tables['datatypes']['float_field']
);
- $db =& ConnectionManager::getDataSource('test_suite');
+ $db =& ConnectionManager::getDataSource('test');
$config = $db->config;
$config['prefix'] = 'schema_test_prefix_';
ConnectionManager::create('schema_prefix', $config);
@@ -591,14 +592,14 @@ class CakeSchemaTest extends CakeTestCase {
$SchemaPost->table = 'sts';
$SchemaPost->tablePrefix = 'po';
$read = $this->Schema->read(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'TestApp',
'models' => array('SchemaPost')
));
$this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s');
$read = $this->Schema->read(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'TestApp',
'models' => array('SchemaComment', 'SchemaTag', 'SchemaPost')
));
@@ -615,7 +616,7 @@ class CakeSchemaTest extends CakeTestCase {
$Schema =& new CakeSchema();
$read = $Schema->read(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'TestApp',
'models' => array('SchemaPrefixAuthUser')
));
@@ -638,7 +639,7 @@ class CakeSchemaTest extends CakeTestCase {
$Schema =& new CakeSchema();
$Schema->plugin = 'TestPlugin';
$read = $Schema->read(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'TestApp',
'models' => true
));
@@ -647,7 +648,7 @@ class CakeSchemaTest extends CakeTestCase {
$this->assertTrue(isset($read['tables']['authors']));
$this->assertTrue(isset($read['tables']['test_plugin_comments']));
$this->assertTrue(isset($read['tables']['posts']));
- $this->assertEqual(count($read['tables']), 4);
+ $this->assertTrue(count($read['tables']) >= 4);
App::build();
}
@@ -675,7 +676,7 @@ class CakeSchemaTest extends CakeTestCase {
$fixture->insert($db2);
$read = $this->Schema->read(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'TestApp',
'models' => array('SchemaCrossDatabase', 'SchemaPost')
));
@@ -701,7 +702,7 @@ class CakeSchemaTest extends CakeTestCase {
* @return void
*/
function testGenerateTable() {
- $fields = array(
+ $posts = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
'author_id' => array('type' => 'integer', 'null' => false),
'title' => array('type' => 'string', 'null' => false),
@@ -711,11 +712,8 @@ class CakeSchemaTest extends CakeTestCase {
'updated' => array('type' => 'datetime', 'null' => true, 'default' => null),
'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);
-
- eval(substr($result, 4));
- $this->assertEqual($posts, $fields);
}
/**
* testSchemaWrite method
@@ -940,11 +938,11 @@ class CakeSchemaTest extends CakeTestCase {
* @return void
*/
function testSchemaCreateTable() {
- $db =& ConnectionManager::getDataSource('test_suite');
+ $db =& ConnectionManager::getDataSource('test');
$db->cacheSources = false;
$Schema =& new CakeSchema(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'testdescribes' => array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'int_null' => array('type' => 'integer', 'null' => true),
diff --git a/cake/tests/cases/libs/model/connection_manager.test.php b/cake/tests/cases/libs/model/connection_manager.test.php
index b48b328db..27f27b250 100644
--- a/cake/tests/cases/libs/model/connection_manager.test.php
+++ b/cake/tests/cases/libs/model/connection_manager.test.php
@@ -67,7 +67,7 @@ class ConnectionManagerTest extends CakeTestCase {
$sources = ConnectionManager::enumConnectionObjects();
$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);
}
@@ -194,7 +194,7 @@ class ConnectionManagerTest extends CakeTestCase {
$sources = ConnectionManager::sourceList();
$this->assertTrue(count($sources) >= 1);
- $connections = array('default', 'test', 'test_suite');
+ $connections = array('default', 'test', 'test');
$this->assertTrue(count(array_intersect($sources, $connections)) >= 1);
}
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
index d31a61a1c..705ebaade 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
@@ -328,7 +328,7 @@ class DboMssqlTest extends CakeTestCase {
*
*/
public function setUp() {
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$this->db = new DboMssqlTestDb($db->config);
$this->model = new MssqlTestModel();
}
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
index 0ade4be5c..6bcb0154b 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
@@ -172,7 +172,7 @@ class DboMysqlTest extends CakeTestCase {
*
*/
public function setUp() {
- $this->Dbo = ConnectionManager::getDataSource('test_suite');
+ $this->Dbo = ConnectionManager::getDataSource('test');
if ($this->Dbo->config['driver'] !== 'mysql') {
$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->model = new CakeTestModel(array(
- 'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test_suite'
+ 'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test'
));
$result = $this->model->schema();
@@ -561,7 +561,7 @@ class DboMysqlTest extends CakeTestCase {
$schema1 = new CakeSchema(array(
'name' => 'AlterTest1',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -572,7 +572,7 @@ class DboMysqlTest extends CakeTestCase {
$schema2 = new CakeSchema(array(
'name' => 'AlterTest2',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'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
$schema3 = new CakeSchema(array(
'name' => 'AlterTest3',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -633,7 +633,7 @@ class DboMysqlTest extends CakeTestCase {
¢îè©ÀÌ#¥⁄ã≥fi:¯Ü‚Héá¶jV∂ÓúÎL≥çÀóËıÎ…>ï ≈ vFE%ÒâLFI<†µw˝±≈£7˘ç^H“≤«>Éâ*∑Ç nÖA•Ù|flêèj£:=ÿ6óUàµ5'∂®àA¬ñ∆ˆGE(gt’≈àÚyÁó«7 ‚VìöÇ√˙Ç™
k”:;kÀAõ{*¡€Î˚˚[ ;;";
- $model = new AppModel(array('name' => 'BinaryTest', 'ds' => 'test_suite'));
+ $model = new AppModel(array('name' => 'BinaryTest', 'ds' => 'test'));
$model->save(compact('data'));
$result = $model->find('first');
@@ -651,7 +651,7 @@ class DboMysqlTest extends CakeTestCase {
$schema1 = new CakeSchema(array(
'name' => 'AlterTest1',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -665,7 +665,7 @@ class DboMysqlTest extends CakeTestCase {
$this->Dbo->query($this->Dbo->createSchema($schema1));
$schema2 = new CakeSchema(array(
'name' => 'AlterTest1',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -698,7 +698,7 @@ class DboMysqlTest extends CakeTestCase {
function testAlteringTwoTables() {
$schema1 =& new CakeSchema(array(
'name' => 'AlterTest1',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -710,7 +710,7 @@ class DboMysqlTest extends CakeTestCase {
));
$schema2 =& new CakeSchema(array(
'name' => 'AlterTest1',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'field_two' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -792,7 +792,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
function testVirtualFieldSeparators() {
- $model =& new CakeTestModel(array('table' => 'binary_tests', 'ds' => 'test_suite', 'name' => 'BinaryTest'));
+ $model =& new CakeTestModel(array('table' => 'binary_tests', 'ds' => 'test', 'name' => 'BinaryTest'));
$model->virtualFields = array(
'other__field' => 'SUM(id)'
);
@@ -810,7 +810,7 @@ class DboMysqlTest extends CakeTestCase {
*/
function testDescribeGettingFieldParameters() {
$schema =& new CakeSchema(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'testdescribes' => array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'stringy' => array(
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
index 70d54ce4d..ceee349de 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
@@ -147,7 +147,7 @@ class DboMysqliTest extends CakeTestCase {
*
*/
public function setUp() {
- $this->Dbo = ConnectionManager::getDataSource('test_suite');
+ $this->Dbo = ConnectionManager::getDataSource('test');
if ($this->Dbo->config['driver'] !== 'mysqli') {
$this->markTestSkipped('The MySQLi extension is not available.');
}
@@ -295,7 +295,7 @@ class DboMysqliTest extends CakeTestCase {
* @return void
*/
function testFloatParsing() {
- $model =& new Model(array('ds' => 'test_suite', 'table' => 'datatypes', 'name' => 'Datatype'));
+ $model =& new Model(array('ds' => 'test', 'table' => 'datatypes', 'name' => 'Datatype'));
$result = $this->Dbo->describe($model);
$this->assertEqual((string)$result['float_field']['length'], '5,2');
}
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
index ca64c3a47..5dca76b29 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
@@ -243,7 +243,7 @@ class DboPostgresTest extends CakeTestCase {
*/
public function setUp() {
Configure::write('Cache.disable', true);
- $this->Dbo = ConnectionManager::getDataSource('test_suite');
+ $this->Dbo = ConnectionManager::getDataSource('test');
$this->Dbo2 = new DboPostgresTestDb($this->Dbo->config, false);
$this->skipUnless($this->Dbo->config['driver'] == 'postgres', 'PostgreSQL connection not available');
$this->model = new PostgresTestModel();
@@ -423,7 +423,7 @@ class DboPostgresTest extends CakeTestCase {
*/
function testLastInsertIdMultipleInsert() {
$this->loadFixtures('User');
- $db1 = ConnectionManager::getDataSource('test_suite');
+ $db1 = ConnectionManager::getDataSource('test');
$db2 = clone $db1;
$db2->connect();
@@ -446,13 +446,13 @@ class DboPostgresTest extends CakeTestCase {
* @return void
*/
function testSchemaScoping() {
- $db1 = ConnectionManager::getDataSource('test_suite');
+ $db1 = ConnectionManager::getDataSource('test');
$db1->cacheSources = false;
$db1->reconnect(array('persistent' => false));
$db1->query('CREATE SCHEMA _scope_test');
$db2 = ConnectionManager::create(
- 'test_suite_2',
+ 'test_2',
array_merge($db1->config, array('driver' => 'postgres', 'schema' => '_scope_test'))
);
$db2->cacheSources = false;
@@ -504,7 +504,7 @@ class DboPostgresTest extends CakeTestCase {
ªºnh˚ºO^∏…®[Ó“‚ÅfıÌ≥∫F!Eœ(π∑T6`¬tΩÆ0ì»rTÎ`»Ñ«
]≈åp˝)=¿Ô0∆öVÂmˇˆ„ø~¯ÁÔ∏b*fc»‡Îı„Ú}∆tœs∂Y∫ÜaÆ˙X∏~<ÿ·Ùvé1‹p¿TD∆ÔîÄ“úhˆ*Ú€îe)K–p¨ÚJ3Ÿ∞ã>ÊuNê°“√Ü ‹Ê9iÙ0˙AAEÍ ˙`∂£\'ûce•åƒX›ŸÁ´1SK{qdá"tÏ[wQ#SµBe∞∑µó…ÌV`B"Ñ≥„!è_Óφ-º*ºú¿Ë0ˆeê∂´ë+HFj…‡zvHÓN|ÔL÷ûñ3õÜ$z%sá…pÎóV38âs Çoµ•ß3†<9B·¨û~¢3)ÂxóÿÁCÕòÆ∫Í=»ÿSπS;∆~±êÆTEp∑óÈ÷ÀuìDHÈ$ÉõæÜjû§"≤ÃONM®RËíRr{õS ∏Ê™op±W;ÂUÔ P∫kÔˇflTæ∑óflË”ÆC©Ô[≥◊HÁ˚¨hê"ÆbF?ú%h˙ˇ4xèÕ(ó2ÙáíM])Ñd|=fë-cI0ñL¢kÖêk‰Rƒ«ıÄWñ8mO3∏&√æËX¯Hó—ì]yF2»–˜ádàà‡‹Çο„≥7mªHAS∑¶.;Œx(1} _kd©.fidç48M\'àáªCp^Krí<ɉXÓıïl!Ì$N<ı∞B»G]…∂Ó¯>˛ÔbõÒπÀ•:ôO@È$pÖu‹Ê´-QqV ?V≥JÆÍqÛX8(lπï@zgÖ}Fe<ˇ‡Sñ“ÿ˜ê?6‡L∫Oß~µ –?ËeäÚ®YîÕ=Ü=¢DÁu*GvBk;)L¬N«î:flö∂≠ÇΩq„Ñm하Ë∂‚"û≥§:±≤i^ΩÑ!)Wıyŧô á„RÄ÷Òôc’≠—s™rı‚Pdêãh˘ßHVç5fifiÈF€çÌÛuçÖ/M=gëµ±ÿGû1coÔuñæ‘z®. õ∑7ÉÏÜÆ,°’H†ÍÉÌ∂7e º® íˆ⁄◊øNWK”ÂYµ‚ñé;µ¶gV-fl>µtË¥áßN2 ¯¶BaP-)eW.àôt^∏1›C∑Ö?L„&”5’4jvã–ªZ ÷+4% ´0l…»ú^°´© ûiπ∑é®óܱÒÿ‰ïˆÌ–dˆ◊Æ19rQ=Í|ı•rMæ¬;ò‰Y‰é9.”‹˝V«ã¯∏,+ë®j*¡·/';
- $model = new AppModel(array('name' => 'BinaryTest', 'ds' => 'test_suite'));
+ $model = new AppModel(array('name' => 'BinaryTest', 'ds' => 'test'));
$model->save(compact('data'));
$result = $model->find('first');
@@ -553,7 +553,7 @@ class DboPostgresTest extends CakeTestCase {
* @return void
*/
public function testCakeSchema() {
- $db1 = ConnectionManager::getDataSource('test_suite');
+ $db1 = ConnectionManager::getDataSource('test');
$db1->cacheSources = false;
$db1->reconnect(array('persistent' => false));
$db1->query('CREATE TABLE ' . $db1->fullTableName('datatypes') . ' (
@@ -562,12 +562,12 @@ class DboPostgresTest extends CakeTestCase {
"full_length" character varying NOT NULL,
"timestamp" timestamp without time zone,
date date,
- CONSTRAINT test_suite_data_types_pkey PRIMARY KEY (id)
+ CONSTRAINT test_data_types_pkey PRIMARY KEY (id)
)');
- $model = new Model(array('name' => 'Datatype', 'ds' => 'test_suite'));
- $schema = new CakeSchema(array('connection' => 'test_suite'));
+ $model = new Model(array('name' => 'Datatype', 'ds' => 'test'));
+ $schema = new CakeSchema(array('connection' => 'test'));
$result = $schema->read(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'models' => array('Datatype')
));
$schema->tables = array('datatypes' => $result['tables']['datatypes']);
@@ -581,7 +581,7 @@ class DboPostgresTest extends CakeTestCase {
$db1->query($result);
$result2 = $schema->read(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'models' => array('Datatype')
));
$schema->tables = array('datatypes' => $result2['tables']['datatypes']);
@@ -631,7 +631,7 @@ class DboPostgresTest extends CakeTestCase {
*/
function testAlterSchema() {
$Old = new CakeSchema(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'AlterPosts',
'alter_posts' => array(
'id' => array('type' => 'integer', 'key' => 'primary'),
@@ -646,7 +646,7 @@ class DboPostgresTest extends CakeTestCase {
$this->Dbo->query($this->Dbo->createSchema($Old));
$New = new CakeSchema(array(
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'name' => 'AlterPosts',
'alter_posts' => array(
'id' => array('type' => 'integer', 'key' => 'primary'),
@@ -660,7 +660,7 @@ class DboPostgresTest extends CakeTestCase {
));
$this->Dbo->query($this->Dbo->alterSchema($New->compare($Old), 'alter_posts'));
- $model = new CakeTestModel(array('table' => 'alter_posts', 'ds' => 'test_suite'));
+ $model = new CakeTestModel(array('table' => 'alter_posts', 'ds' => 'test'));
$result = $model->schema();
$this->assertTrue(isset($result['status']));
$this->assertFalse(isset($result['published']));
@@ -683,7 +683,7 @@ class DboPostgresTest extends CakeTestCase {
$schema1 = new CakeSchema(array(
'name' => 'AlterTest1',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -695,7 +695,7 @@ class DboPostgresTest extends CakeTestCase {
$schema2 = new CakeSchema(array(
'name' => 'AlterTest2',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -717,7 +717,7 @@ class DboPostgresTest extends CakeTestCase {
// Change three indexes, delete one and add another one
$schema3 = new CakeSchema(array(
'name' => 'AlterTest3',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -808,13 +808,13 @@ class DboPostgresTest extends CakeTestCase {
function testUpdateAllWithNonQualifiedConditions() {
$this->loadFixtures('Article');
$Article =& new Article();
- $result = $Article->updateAll(array('title' => "'Awesome'"), array('published' => 'Y'));
+ $result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article'));
$this->assertTrue($result);
$result = $Article->find('count', array(
'conditions' => array('Article.title' => 'Awesome')
));
- $this->assertEqual($result, 3, 'Article count is wrong or fixture has changed.');
+ $this->assertEqual($result, 1, 'Article count is wrong or fixture has changed.');
}
/**
@@ -825,7 +825,7 @@ class DboPostgresTest extends CakeTestCase {
function testAlteringTwoTables() {
$schema1 =& new CakeSchema(array(
'name' => 'AlterTest1',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
@@ -837,7 +837,7 @@ class DboPostgresTest extends CakeTestCase {
));
$schema2 =& new CakeSchema(array(
'name' => 'AlterTest1',
- 'connection' => 'test_suite',
+ 'connection' => 'test',
'altertest' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
'field_two' => array('type' => 'string', 'null' => false, 'length' => 50),
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
index 7affde55d..60dfb525d 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
@@ -104,7 +104,7 @@ class DboSqliteTest extends CakeTestCase {
*/
public function setUp() {
Configure::write('Cache.disable', true);
- $this->Dbo = ConnectionManager::getDataSource('test_suite');
+ $this->Dbo = ConnectionManager::getDataSource('test');
if ($this->Dbo->config['driver'] !== 'sqlite') {
$this->markTestSkipped('The Sqlite extension is not available.');
}
@@ -274,7 +274,7 @@ class DboSqliteTest extends CakeTestCase {
*/
function testDescribe() {
$this->loadFixtures('User');
- $Model = new Model(array('name' => 'User', 'ds' => 'test_suite', 'table' => 'users'));
+ $Model = new Model(array('name' => 'User', 'ds' => 'test', 'table' => 'users'));
$result = $this->Dbo->describe($Model);
$expected = array(
'id' => array(
@@ -320,7 +320,7 @@ class DboSqliteTest extends CakeTestCase {
function testDescribeWithUuidPrimaryKey() {
$tableName = 'uuid_tests';
$this->Dbo->query("CREATE TABLE {$tableName} (id VARCHAR(36) PRIMARY KEY, name VARCHAR, created DATETIME, modified DATETIME)");
- $Model = new Model(array('name' => 'UuidTest', 'ds' => 'test_suite', 'table' => 'uuid_tests'));
+ $Model = new Model(array('name' => 'UuidTest', 'ds' => 'test', 'table' => 'uuid_tests'));
$result = $this->Dbo->describe($Model);
$expected = array(
'type' => 'string',
diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
index b07abd32c..f96fa1cf6 100644
--- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php
+++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -1283,16 +1283,17 @@ class DboSourceTest extends CakeTestCase {
);
/**
- * startTest method
+ * setUp method
*
* @access public
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$this->__config = $this->db->config;
if (!class_exists('DboTest')) {
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$class = get_class($db);
eval("class DboTest extends $class {
var \$simulated = array();
@@ -1325,8 +1326,7 @@ class DboSourceTest extends CakeTestCase {
$this->testDb->cacheSources = false;
$this->testDb->startQuote = '`';
$this->testDb->endQuote = '`';
- Configure::write('debug', 1);
- $this->debug = Configure::read('debug');
+
$this->Model = new TestModel();
}
@@ -1336,11 +1336,9 @@ class DboSourceTest extends CakeTestCase {
* @access public
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->Model);
- Configure::write('debug', $this->debug);
- ClassRegistry::flush();
- unset($this->debug);
}
/**
@@ -4154,18 +4152,21 @@ class DboSourceTest extends CakeTestCase {
$oldDebug = Configure::read('debug');
Configure::write('debug', 2);
- $this->testDb->error = true;
- $this->expectError();
- ob_start();
- $this->testDb->showQuery('Error 2');
- $contents = ob_get_clean();
-
- $this->assertPattern('/Error 2/s', $contents);
-
$this->testDb->error = $oldError;
Configure::write('debug', $oldDebug);
}
+ function testShowQueryError() {
+ $this->testDb->error = true;
+ try {
+ $this->testDb->showQuery('Error 2');
+ $this->fail('No exception');
+ } catch (Exception $e) {
+ $this->assertPattern('/SQL Error/', $e->getMessage());
+ $this->assertTrue(true, 'Exception thrown');
+ }
+ }
+
/**
* test getting the query log as an array.
*
@@ -4240,16 +4241,6 @@ class DboSourceTest extends CakeTestCase {
$this->assertPattern('/Aff:/s', $contents);
$this->assertPattern('/Num:/s', $contents);
$this->assertPattern('/Took:/s', $contents);
-
- $this->expectError();
- $this->testDb->error = true;
- ob_start();
- $this->testDb->showQuery('Another Query');
- $contents = ob_get_clean();
- $this->assertPattern('/Another Query/s', $contents);
- $this->assertNoPattern('/Aff:/s', $contents);
- $this->assertNoPattern('/Num:/s', $contents);
- $this->assertNoPattern('/Took:/s', $contents);
}
/**
@@ -4508,6 +4499,24 @@ class DboSourceTest extends CakeTestCase {
$this->assertPattern('/[`\'"]Article[`\'"].[`\'"]longitude[`\'"]/', $result[1]);
}
+/**
+ * test reading virtual fields containing newlines when recursive > 0
+ *
+ * @return void
+ */
+ function testReadVirtualFieldsWithNewLines() {
+ $Article =& new Article();
+ $Article->recursive = 1;
+ $Article->virtualFields = array(
+ 'test' => '
+ User.id + User.id
+ '
+ );
+ $result = $this->db->fields($Article, null, array());
+ $result = $this->db->fields($Article, $Article->alias, $result);
+ $this->assertPattern('/[`\"]User[`\"]\.[`\"]id[`\"] \+ [`\"]User[`\"]\.[`\"]id[`\"]/', $result[7]);
+ }
+
/**
* test group to generate GROUP BY statements on virtual fields
*
@@ -4538,6 +4547,11 @@ class DboSourceTest extends CakeTestCase {
$Article->tablePrefix = 'tbl_';
$result = $this->testDb->fullTableName($Article, false);
$this->assertEqual($result, 'tbl_articles');
+
+ $Article->useTable = $Article->table = 'with spaces';
+ $Article->tablePrefix = '';
+ $result = $this->testDb->fullTableName($Article);
+ $this->assertEqual($result, '`with spaces`');
}
/**
diff --git a/cake/tests/cases/libs/model/db_acl.test.php b/cake/tests/cases/libs/model/db_acl.test.php
index 36dc97a74..890a1f877 100644
--- a/cake/tests/cases/libs/model/db_acl.test.php
+++ b/cake/tests/cases/libs/model/db_acl.test.php
@@ -17,9 +17,6 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
-if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
- define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
-}
App::import('Component', 'Acl');
App::import('Core', 'db_acl');
@@ -34,10 +31,10 @@ class DbAclNodeTestBase extends AclNode {
/**
* useDbConfig property
*
- * @var string 'test_suite'
+ * @var string 'test'
* @access public
*/
- public $useDbConfig = 'test_suite';
+ public $useDbConfig = 'test';
/**
* cacheSources property
@@ -228,12 +225,12 @@ class DbAroUserTest extends CakeTestModel {
}
/**
- * DbAclTest class
+ * TestDbAcl class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
-class DbAclTest extends DbAcl {
+class TestDbAcl extends DbAcl {
/**
* construct method
@@ -272,8 +269,8 @@ class AclNodeTest extends CakeTestCase {
* @return void
*/
function setUp() {
- Configure::write('Acl.classname', 'DbAclTest');
- Configure::write('Acl.database', 'test_suite');
+ Configure::write('Acl.classname', 'TestDbAcl');
+ Configure::write('Acl.database', 'test');
}
/**
@@ -376,7 +373,7 @@ class AclNodeTest extends CakeTestCase {
*/
function testNodeAliasParenting() {
$Aco = new DbAcoTest();
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$db->truncate($Aco);
$Aco->create(array('model' => null, 'foreign_key' => null, 'parent_id' => null, 'alias' => 'Application'));
diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php
index 63370a696..dc1b5f4d6 100644
--- a/cake/tests/cases/libs/model/model_integration.test.php
+++ b/cake/tests/cases/libs/model/model_integration.test.php
@@ -249,15 +249,11 @@ class ModelIntegrationTest extends BaseModelTest {
function testCrossDatabaseJoins() {
$config = new DATABASE_CONFIG();
- $skip = $this->skipIf(
- !isset($config->test) || !isset($config->test2),
- '%s Primary and secondary test databases not configured, skipping cross-database '
- .'join tests.'
- .' To run these tests, you must define $test and $test2 in your database configuration.'
- );
-
+ $skip = (!isset($config->test) || !isset($config->test2));
if ($skip) {
- return;
+ $this->markTestSkipped('Primary and secondary test databases not configured, skipping cross-database
+ join tests. To run theses tests defined $test and $test2 in your database configuration.'
+ );
}
$this->loadFixtures('Article', 'Tag', 'ArticlesTag', 'User', 'Comment');
@@ -710,7 +706,7 @@ class ModelIntegrationTest extends BaseModelTest {
$expected = array('Apple'=> array('mytime'=> '03:04:04'));
$this->assertEqual($TestModel->data, $expected);
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$data = array();
$data['Apple']['mytime'] = $db->expression('NOW()');
$TestModel->data = null;
@@ -887,7 +883,7 @@ class ModelIntegrationTest extends BaseModelTest {
$expected = array('Apple'=> array('date'=> '2006-12-25'));
$this->assertEqual($TestModel->data, $expected);
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$data = array();
$data['Apple']['modified'] = $db->expression('NOW()');
$TestModel->data = null;
@@ -1332,9 +1328,9 @@ class ModelIntegrationTest extends BaseModelTest {
*/
function testConstructWithAlternateDataSource() {
$TestModel = ClassRegistry::init(array(
- 'class' => 'DoesntMatter', 'ds' => 'test_suite', 'table' => false
+ 'class' => 'DoesntMatter', 'ds' => 'test', 'table' => false
));
- $this->assertEqual('test_suite', $TestModel->useDbConfig);
+ $this->assertEqual('test', $TestModel->useDbConfig);
//deprecated but test it anyway
$NewVoid = new TheVoid(null, false, 'other');
diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php
index 83d52ca22..9462b7f2a 100755
--- a/cake/tests/cases/libs/model/model_read.test.php
+++ b/cake/tests/cases/libs/model/model_read.test.php
@@ -78,7 +78,7 @@ class ModelReadTest extends BaseModelTest {
* @return void
*/
function testGroupBy() {
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle'));
$message = '%s Postgres and Oracle have strict GROUP BY and are incompatible with this test.';
@@ -6286,7 +6286,7 @@ class ModelReadTest extends BaseModelTest {
);
$this->assertEqual($result, $expected);
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
if ($db->config['driver'] == 'mysql') {
$result = $TestModel->find('list', array(
'order' => array('FIELD(Article.id, 3, 2) ASC', 'Article.title ASC')
@@ -6666,7 +6666,7 @@ class ModelReadTest extends BaseModelTest {
return;
}
$this->loadFixtures('Project');
- $db = ConnectionManager::getDataSource('test_suite');
+ $db = ConnectionManager::getDataSource('test');
$TestModel = new Project();
$result = $TestModel->find('count', array('conditions' => array(
diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php
index d05eba1cc..75a6fa1bf 100644
--- a/cake/tests/cases/libs/model/model_write.test.php
+++ b/cake/tests/cases/libs/model/model_write.test.php
@@ -3576,6 +3576,7 @@ class ModelWriteTest extends BaseModelTest {
function testUpdateWithCalculation() {
$this->loadFixtures('DataTest');
$model = new DataTest();
+ $model->deleteAll(true);
$result = $model->saveAll(array(
array('count' => 5, 'float' => 1.1),
array('count' => 3, 'float' => 1.2),
diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php
index 1a7c2982d..066c44d27 100644
--- a/cake/tests/cases/libs/model/models.php
+++ b/cake/tests/cases/libs/model/models.php
@@ -907,7 +907,7 @@ class Post extends CakeTestModel {
}
function afterFind($results) {
- $this->useDbConfig = 'test_suite';
+ $this->useDbConfig = 'test';
return $results;
}
}
diff --git a/cake/tests/cases/libs/multibyte.test.php b/cake/tests/cases/libs/multibyte.test.php
index aeb6ca50a..04b991ef2 100644
--- a/cake/tests/cases/libs/multibyte.test.php
+++ b/cake/tests/cases/libs/multibyte.test.php
@@ -4532,8 +4532,7 @@ class MultibyteTest extends CakeTestCase {
$string = 'državni';
$find = 'dž';
$result = mb_strripos($string, $find);
- $expected = 0;
- $this->assertEqual($result, $expected);
+ $this->assertFalse($result);
}
/**
diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php
index 47fdef0f9..21f02ec56 100644
--- a/cake/tests/cases/libs/route/cake_route.test.php
+++ b/cake/tests/cases/libs/route/cake_route.test.php
@@ -10,24 +10,14 @@ App::import('Core', 'Router');
**/
class CakeRouteTestCase extends CakeTestCase {
/**
- * startTest method
+ * setUp method
*
* @access public
* @return void
*/
- function startTest() {
- $this->_routing = Configure::read('Routing');
+ function setUp() {
+ parent::setUp();
Configure::write('Routing', array('admin' => null, 'prefixes' => array()));
- Router::reload();
- }
-
-/**
- * end the test and reset the environment
- *
- * @return void
- **/
- function endTest() {
- Configure::write('Routing', $this->_routing);
}
/**
diff --git a/cake/tests/cases/libs/route/plugin_short_route.test.php b/cake/tests/cases/libs/route/plugin_short_route.test.php
index d52061844..4edda72b1 100644
--- a/cake/tests/cases/libs/route/plugin_short_route.test.php
+++ b/cake/tests/cases/libs/route/plugin_short_route.test.php
@@ -7,26 +7,16 @@ App::import('Core', 'route/PluginShortRoute');
*/
class PluginShortRouteTestCase extends CakeTestCase {
/**
- * startTest method
+ * setUp method
*
- * @access public
* @return void
*/
- function startTest() {
- $this->_routing = Configure::read('Routing');
+ function setUp() {
+ parent::setUp();
Configure::write('Routing', array('admin' => null, 'prefixes' => array()));
Router::reload();
}
-/**
- * end the test and reset the environment
- *
- * @return void
- **/
- function endTest() {
- Configure::write('Routing', $this->_routing);
- }
-
/**
* test the parsing of routes.
*
diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php
index d1b2dd980..7b176a8d5 100644
--- a/cake/tests/cases/libs/router.test.php
+++ b/cake/tests/cases/libs/router.test.php
@@ -38,18 +38,8 @@ class RouterTest extends CakeTestCase {
* @return void
*/
function setUp() {
- $this->_routing = Configure::read('Routing');
+ parent::setUp();
Configure::write('Routing', array('admin' => null, 'prefixes' => array()));
- Router::reload();
- }
-
-/**
- * end the test and reset the environment
- *
- * @return void
- */
- function endTest() {
- Configure::write('Routing', $this->_routing);
}
/**
@@ -59,6 +49,10 @@ class RouterTest extends CakeTestCase {
* @return void
*/
function testFullBaseURL() {
+ $skip = PHP_SAPI == 'cli';
+ if ($skip) {
+ $this->markTestSkipped('Cannot validate base urls in CLI');
+ }
$this->assertPattern('/^http(s)?:\/\//', Router::url('/', true));
$this->assertPattern('/^http(s)?:\/\//', Router::url(null, true));
}
diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php
index 6bed4f586..c002d272f 100644
--- a/cake/tests/cases/libs/sanitize.test.php
+++ b/cake/tests/cases/libs/sanitize.test.php
@@ -100,28 +100,28 @@ class SanitizeTest extends CakeTestCase {
* @return void
*/
function testEscapeAlphaNumeric() {
- $resultAlpha = Sanitize::escape('abc', 'test_suite');
+ $resultAlpha = Sanitize::escape('abc', 'test');
$this->assertEqual($resultAlpha, 'abc');
- $resultNumeric = Sanitize::escape('123', 'test_suite');
+ $resultNumeric = Sanitize::escape('123', 'test');
$this->assertEqual($resultNumeric, '123');
- $resultNumeric = Sanitize::escape(1234, 'test_suite');
+ $resultNumeric = Sanitize::escape(1234, 'test');
$this->assertEqual($resultNumeric, 1234);
- $resultNumeric = Sanitize::escape(1234.23, 'test_suite');
+ $resultNumeric = Sanitize::escape(1234.23, 'test');
$this->assertEqual($resultNumeric, 1234.23);
- $resultNumeric = Sanitize::escape('#1234.23', 'test_suite');
+ $resultNumeric = Sanitize::escape('#1234.23', 'test');
$this->assertEqual($resultNumeric, '#1234.23');
- $resultNull = Sanitize::escape(null, 'test_suite');
+ $resultNull = Sanitize::escape(null, 'test');
$this->assertEqual($resultNull, null);
- $resultNull = Sanitize::escape(false, 'test_suite');
+ $resultNull = Sanitize::escape(false, 'test');
$this->assertEqual($resultNull, false);
- $resultNull = Sanitize::escape(true, 'test_suite');
+ $resultNull = Sanitize::escape(true, 'test');
$this->assertEqual($resultNull, true);
}
@@ -134,42 +134,42 @@ class SanitizeTest extends CakeTestCase {
function testClean() {
$string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
$expected = 'test & "quote" 'other' ;.$ symbol.another line';
- $result = Sanitize::clean($string, array('connection' => 'test_suite'));
+ $result = Sanitize::clean($string, array('connection' => 'test'));
$this->assertEqual($result, $expected);
$string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
- $expected = 'test & ' . Sanitize::escape('"quote"', 'test_suite') . ' ' . Sanitize::escape('\'other\'', 'test_suite') . ' ;.$ symbol.another line';
- $result = Sanitize::clean($string, array('encode' => false, 'connection' => 'test_suite'));
+ $expected = 'test & ' . Sanitize::escape('"quote"', 'test') . ' ' . Sanitize::escape('\'other\'', 'test') . ' ;.$ symbol.another line';
+ $result = Sanitize::clean($string, array('encode' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected);
$string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line';
$expected = 'test & "quote" \'other\' ;.$ $ symbol.another line';
- $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'connection' => 'test_suite'));
+ $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected);
$string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line';
$expected = 'test & "quote" \'other\' ;.$ \\$ symbol.another line';
- $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'dollar' => false, 'connection' => 'test_suite'));
+ $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'dollar' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected);
$string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
$expected = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
- $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false, 'connection' => 'test_suite'));
+ $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected);
$array = array(array('test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'));
$expected = array(array('test & "quote" 'other' ;.$ symbol.another line'));
- $result = Sanitize::clean($array, array('connection' => 'test_suite'));
+ $result = Sanitize::clean($array, array('connection' => 'test'));
$this->assertEqual($result, $expected);
$array = array(array('test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'));
$expected = array(array('test & "quote" \'other\' ;.$ $ symbol.another line'));
- $result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test_suite'));
+ $result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected);
$array = array(array('test odd Ä spacesé'));
$expected = array(array('test odd Ä spacesé'));
- $result = Sanitize::clean($array, array('odd_spaces' => false, 'escape' => false, 'connection' => 'test_suite'));
+ $result = Sanitize::clean($array, array('odd_spaces' => false, 'escape' => false, 'connection' => 'test'));
$this->assertEqual($result, $expected);
$array = array(array('\\$', array('key' => 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line')));
diff --git a/cake/tests/cases/libs/session/cache_session.test.php b/cake/tests/cases/libs/session/cache_session.test.php
index 4b45eb7cc..eb3be0fc5 100644
--- a/cake/tests/cases/libs/session/cache_session.test.php
+++ b/cake/tests/cases/libs/session/cache_session.test.php
@@ -57,7 +57,8 @@ class CacheSessionTest extends CakeTestCase {
*
* @return void
*/
- function setup() {
+ function setUp() {
+ parent::setUp()
$this->storage = new CacheSession();
}
@@ -66,7 +67,8 @@ class CacheSessionTest extends CakeTestCase {
*
* @return void
*/
- function teardown() {
+ function tearDown() {
+ parent::tearDown();
unset($this->storage);
}
diff --git a/cake/tests/cases/libs/session/database_session.test.php b/cake/tests/cases/libs/session/database_session.test.php
index 24d12b3b6..309994353 100644
--- a/cake/tests/cases/libs/session/database_session.test.php
+++ b/cake/tests/cases/libs/session/database_session.test.php
@@ -52,7 +52,7 @@ class DatabaseSessionTest extends CakeTestCase {
self::$_sessionBackup = Configure::read('Session');
Configure::write('Session.handler', array(
'model' => 'SessionTestModel',
- 'database' => 'test_suite',
+ 'database' => 'test',
'table' => 'sessions'
));
Configure::write('Session.timeout', 100);
@@ -98,7 +98,7 @@ class DatabaseSessionTest extends CakeTestCase {
$session = ClassRegistry::getObject('session');
$this->assertType('SessionTestModel', $session);
$this->assertEquals('Session', $session->alias);
- $this->assertEquals('test_suite', $session->useDbConfig);
+ $this->assertEquals('test', $session->useDbConfig);
}
/**
diff --git a/cake/tests/cases/libs/test_manager.test.php b/cake/tests/cases/libs/test_manager.test.php
index 1f9ec0a41..5e3f9c652 100644
--- a/cake/tests/cases/libs/test_manager.test.php
+++ b/cake/tests/cases/libs/test_manager.test.php
@@ -48,6 +48,7 @@ class TestManagerTest extends CakeTestCase {
* @return void
*/
public function setUp() {
+ parent::setUp();
$this->_countFiles = 0;
$this->TestManager = new TestTestManager();
$this->testSuiteStub = $this->getMock('CakeTestSuite');
@@ -87,20 +88,6 @@ class TestManagerTest extends CakeTestCase {
return $files;
}
-/**
- * testRunAllTests method
- *
- * @return void
- */
- public function testRunAllTests() {
- $this->Reporter->params = array('show' => 'cases');
- $files = $this->_getAllTestFiles();
- $result = $this->TestManager->runAllTests($this->Reporter, true);
-
- $this->assertEquals(count($files), $this->_countFiles);
- $this->assertType('PHPUnit_Framework_TestResult', $result);
- }
-
/**
* Tests that trying to run an unexistent file throws an exception
* @expectedException InvalidArgumentException
@@ -116,46 +103,10 @@ class TestManagerTest extends CakeTestCase {
* @return void
*/
public function testRunTestCase() {
- $file = __FILE__;
+ $file = 'libs/test_manager.test.php';
$result = $this->TestManager->runTestCase($file, $this->Reporter, true);
$this->assertEquals(1, $this->_countFiles);
$this->assertType('PHPUnit_Framework_TestResult', $result);
}
-/**
- * testAddTestCasesFromDirectory method
- *
- * @return void
- */
- public function testAddTestCasesFromDirectory() {
- $this->TestManager->addTestCasesFromDirectory($this->testSuiteStub, CORE_TEST_CASES);
- $this->assertEquals(count($this->_getAllTestFiles()), $this->_countFiles);
- }
-
-/**
- * testAddTestFile method
- *
- * @return void
- */
- public function testAddTestFile() {
- $file = str_replace(CORE_TEST_CASES, '', __FILE__);
- $this->TestManager->addTestFile($this->testSuiteStub, $file);
- $this->assertEquals(1, $this->_countFiles);
- }
-
-/**
- * testGetTestCaseList method
- *
- * @return void
- */
- public function testGetTestCaseList() {
- }
-
-/**
- * testGetGroupTestList method
- *
- * @return void
- */
- public function testGetGroupTestList() {
- }
}
diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php
index 755b298bc..cf14ed441 100644
--- a/cake/tests/cases/libs/view/helpers/html.test.php
+++ b/cake/tests/cases/libs/view/helpers/html.test.php
@@ -63,12 +63,14 @@ class HtmlHelperTest extends CakeTestCase {
* @var string
*/
public $cDataStart = 'preg:/^\/\/[\s\r\n]*/';
+
/**
* html property
*
@@ -77,57 +79,26 @@ class HtmlHelperTest extends CakeTestCase {
*/
public $Html = null;
-/**
- * Backup of app encoding configuration setting
- *
- * @var string
- * @access protected
- */
- protected $_appEncoding;
-
-/**
- * Backup of asset configuration settings
- *
- * @var string
- * @access protected
- */
- protected $_asset;
-
-/**
- * Backup of debug configuration setting
- *
- * @var integer
- * @access protected
- */
- protected $_debug;
-
/**
* setUp method
*
- * @access public
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$this->View = $this->getMock('View', array('addScript'), array(new TheHtmlTestController()));
$this->Html = new HtmlHelper($this->View);
$this->Html->request = new CakeRequest(null, false);
$this->Html->request->webroot = '';
- $this->_appEncoding = Configure::read('App.encoding');
- $this->_asset = Configure::read('Asset');
- $this->_debug = Configure::read('debug');
}
/**
- * endTest method
+ * tearDown method
*
- * @access public
* @return void
*/
- function endTest() {
- Configure::write('App.encoding', $this->_appEncoding);
- Configure::write('Asset', $this->_asset);
- Configure::write('debug', $this->_debug);
- ClassRegistry::flush();
+ function tearDown() {
+ parent::tearDown();
unset($this->Html, $this->View);
}
@@ -643,6 +614,9 @@ class HtmlHelperTest extends CakeTestCase {
'script' => array('src' => '/theme/test_theme/js/__test_js.js', 'type' => 'text/javascript')
);
$this->assertTags($result, $expected);
+
+ $folder = new Folder(WWW_ROOT . 'theme' . DS . 'test_theme');
+ $folder->delete();
App::build();
}
diff --git a/cake/tests/cases/libs/view/helpers/jquery_engine.test.php b/cake/tests/cases/libs/view/helpers/jquery_engine.test.php
index 643665545..12716099a 100644
--- a/cake/tests/cases/libs/view/helpers/jquery_engine.test.php
+++ b/cake/tests/cases/libs/view/helpers/jquery_engine.test.php
@@ -22,22 +22,24 @@ App::import('Helper', array('Html', 'Js', 'JqueryEngine'));
class JqueryEngineHelperTest extends CakeTestCase {
/**
- * startTest
+ * setUp
*
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$controller = null;
$View = new View($controller);
$this->Jquery = new JqueryEngineHelper($View);
}
/**
- * end test
+ * tearDown
*
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->Jquery);
}
diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php
index 317921490..039d6ef4a 100644
--- a/cake/tests/cases/libs/view/helpers/js.test.php
+++ b/cake/tests/cases/libs/view/helpers/js.test.php
@@ -685,24 +685,23 @@ class JsHelperTest extends CakeTestCase {
*/
class JsBaseEngineTest extends CakeTestCase {
/**
- * startTest method
+ * setUp method
*
- * @access public
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$controller = null;
$this->View = new View($controller);
$this->JsEngine = new OptionEngineHelper($this->View);
}
/**
- * endTest method
+ * tearDown method
*
- * @access public
* @return void
*/
- function endTest() {
- ClassRegistry::removeObject('view');
+ function tearDown() {
+ parent::tearDown();
unset($this->JsEngine);
}
diff --git a/cake/tests/cases/libs/view/helpers/mootools_engine.test.php b/cake/tests/cases/libs/view/helpers/mootools_engine.test.php
index 8b3d682fa..01b1b643b 100644
--- a/cake/tests/cases/libs/view/helpers/mootools_engine.test.php
+++ b/cake/tests/cases/libs/view/helpers/mootools_engine.test.php
@@ -24,21 +24,25 @@ App::import('Helper', array('Html', 'Js', 'MootoolsEngine'));
class MooEngineHelperTest extends CakeTestCase {
/**
- * startTest
+ * setUp
*
* @return void
*/
- function startTest() {
- $this->Moo =& new MootoolsEngineHelper();
+ function setUp() {
+ parent::setUp();
+ $this->Moo = new MootoolsEngineHelper();
}
+
/**
- * end test
+ * tearDown
*
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->Moo);
}
+
/**
* test selector method
*
diff --git a/cake/tests/cases/libs/view/helpers/number.test.php b/cake/tests/cases/libs/view/helpers/number.test.php
index af15d0086..6d66d5930 100644
--- a/cake/tests/cases/libs/view/helpers/number.test.php
+++ b/cake/tests/cases/libs/view/helpers/number.test.php
@@ -31,17 +31,16 @@ class NumberHelperTest extends CakeTestCase {
* helper property
*
* @var mixed null
- * @access public
*/
public $helper = null;
/**
* setUp method
*
- * @access public
* @return void
*/
- function startTest() {
+ function setUp() {
+ parent::setUp();
$view = $this->getMock('View', array(), array(), '', false);
$this->Number = new NumberHelper($view);
}
@@ -52,7 +51,8 @@ class NumberHelperTest extends CakeTestCase {
* @access public
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->Number);
}
diff --git a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php
index 4485a28f0..610e8d23a 100644
--- a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php
+++ b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php
@@ -22,20 +22,22 @@ App::import('Helper', array('Html', 'Js', 'PrototypeEngine'));
class PrototypeEngineHelperTest extends CakeTestCase {
/**
- * startTest
+ * setUp
*
* @return void
*/
- function startTest() {
- $this->Proto =& new PrototypeEngineHelper();
+ function setUp() {
+ parent::setUp();
+ $this->Proto = new PrototypeEngineHelper();
}
/**
- * end test
+ * tearDown
*
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->Proto);
}
diff --git a/cake/tests/cases/libs/view/media.test.php b/cake/tests/cases/libs/view/media.test.php
index 1fee29c22..36dbf1e6f 100644
--- a/cake/tests/cases/libs/view/media.test.php
+++ b/cake/tests/cases/libs/view/media.test.php
@@ -124,13 +124,12 @@ class TestMediaView extends MediaView {
class MediaViewTest extends CakeTestCase {
/**
- * startTest method
+ * setUp method
*
- * @access public
* @return void
*/
- function startTest() {
- Router::reload();
+ function setUp() {
+ parent::setUp();
$this->Controller =& new Controller();
$this->MediaController =& new MediaController();
$this->MediaController->viewPath = 'posts';
@@ -144,11 +143,11 @@ class MediaViewTest extends CakeTestCase {
* @access public
* @return void
*/
- function endTest() {
+ function tearDown() {
+ parent::tearDown();
unset($this->MediaView);
unset($this->MediaController);
unset($this->Controller);
- ClassRegistry::flush();
}
/**
diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php
index 9972d1dcd..b1b9531ab 100644
--- a/cake/tests/cases/libs/view/view.test.php
+++ b/cake/tests/cases/libs/view/view.test.php
@@ -224,7 +224,7 @@ class ViewTest extends CakeTestCase {
* @return void
*/
function setUp() {
- Router::reload();
+ parent::setUp();
$request = $this->getMock('CakeRequest');
$this->Controller = new Controller($request);
@@ -239,6 +239,8 @@ class ViewTest extends CakeTestCase {
TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS
)
), true);
+
+ Configure::write('debug', 2);
}
/**
@@ -248,10 +250,10 @@ class ViewTest extends CakeTestCase {
* @return void
*/
function tearDown() {
+ parent::tearDown();
unset($this->View);
unset($this->PostsController);
unset($this->Controller);
- App::build();
}
/**
@@ -821,6 +823,12 @@ class ViewTest extends CakeTestCase {
$View->set(array('key3' => 'value3'));
$this->assertIdentical($View->getVar('key3'), 'value3');
+
+ $View->viewVars = array();
+ $View->set(array(3 => 'three', 4 => 'four'));
+ $View->set(array(1 => 'one', 2 => 'two'));
+ $expected = array(3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two');
+ $this->assertEqual($View->viewVars, $expected);
}
/**
diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php
index 5a9cb87ed..353243485 100644
--- a/cake/tests/cases/libs/xml.test.php
+++ b/cake/tests/cases/libs/xml.test.php
@@ -52,7 +52,8 @@ class XmlTest extends CakeTestCase {
* @return void
*/
function setUp() {
- $manager =& new XmlManager();
+ parent::setUp();
+ $manager = new XmlManager();
$manager->namespaces = array();
}
diff --git a/cake/tests/lib/cake_fixture_manager.php b/cake/tests/lib/cake_fixture_manager.php
index 0d2a1ae2b..2643335f3 100644
--- a/cake/tests/lib/cake_fixture_manager.php
+++ b/cake/tests/lib/cake_fixture_manager.php
@@ -89,23 +89,16 @@ class CakeFixtureManager {
// Try for test DB
@$db = ConnectionManager::getDataSource('test');
$testDbAvailable = $db->isConnected();
+ } else {
+ throw new MissingConnectionException(__('You need to create a $test datasource connection to start using fixtures'));
}
- // Try for default DB
if (!$testDbAvailable) {
- $db = ConnectionManager::getDataSource('default');
- $_prefix = $db->config['prefix'];
- $db->config['prefix'] = 'test_suite_';
+ throw new MissingConnectionException(__('Unable to connect to the $test datasource'));
}
- ConnectionManager::create('test_suite', $db->config);
- $db->config['prefix'] = $_prefix;
-
- // Get db connection
- $this->_db = ConnectionManager::getDataSource('test_suite');
- $this->_db->cacheSources = false;
-
- ClassRegistry::config(array('ds' => 'test_suite'));
+ $this->_db = $db;
+ ClassRegistry::config(array('ds' => 'test'));
$this->_initialized = true;
}
@@ -229,13 +222,7 @@ class CakeFixtureManager {
* @return void
*/
public function unload(CakeTestCase $test) {
- if (empty($test->fixtures)) {
- return;
- }
- $fixtures = $test->fixtures;
- if (empty($fixtures)) {
- return;
- }
+ $fixtures = !empty($test->fixtures) ? $test->fixtures : array();
foreach ($fixtures as $f) {
if (isset($this->_loaded[$f])) {
$fixture = $this->_loaded[$f];
diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php
index 7b9b58199..b33f107ab 100644
--- a/cake/tests/lib/cake_test_case.php
+++ b/cake/tests/lib/cake_test_case.php
@@ -60,6 +60,13 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
*/
private $fixtures = array();
+/**
+ * Configure values to restore at end of test.
+ *
+ * @var array
+ */
+ protected $_configure = array();
+
/**
* Runs the test case and collects the results in a TestResult object.
* If no TestResult object is passed a new one will be created.
@@ -71,7 +78,7 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
*/
public function run(PHPUnit_Framework_TestResult $result = NULL) {
if (!empty($this->sharedFixture)) {
- $this->sharedFixture->load($this);
+ $this->sharedFixture->load($this);
}
$result = parent::run($result);
if (!empty($this->sharedFixture)) {
@@ -112,6 +119,33 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
return $shouldSkip;
}
+/**
+ * setup the test case, backup the static object values so they can be restored.
+ *
+ * @return void
+ */
+ public function setUp() {
+ parent::setUp();
+ $this->_configure = Configure::read();
+ if (class_exists('Router', false)) {
+ Router::reload();
+ }
+ }
+
+/**
+ * teardown any static object changes and restore them.
+ *
+ * @return void
+ */
+ public function tearDown() {
+ parent::tearDown();
+ App::build();
+ if (class_exists('ClassRegistry', false)) {
+ ClassRegistry::flush();
+ }
+ Configure::write($this->_configure);
+ }
+
/**
* Announces the start of a test.
*
diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php
index 70712a779..c88c675dc 100644
--- a/cake/tests/lib/cake_test_fixture.php
+++ b/cake/tests/lib/cake_test_fixture.php
@@ -53,14 +53,13 @@ class CakeTestFixture {
*/
public function __construct() {
App::import('Model', 'CakeSchema');
- $this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test_suite'));
+ $this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test'));
$this->init();
}
/**
* Initialize the fixture.
*
- * @param object Cake's DBO driver (e.g: DboMysql).
*/
public function init() {
if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
@@ -70,14 +69,17 @@ class CakeTestFixture {
);
if (isset($import['model']) && App::import('Model', $import['model'])) {
- ClassRegistry::config(array('ds' => $import['connection']));
- $model = ClassRegistry::init($import['model']);
- $db = ConnectionManager::getDataSource($model->useDbConfig);
- $db->cacheSources = false;
+ App::import('Model', $import['model']);
+ list(, $modelClass) = pluginSplit($import['model']);
+ $model = new $modelClass(null, null, $import['connection']);
+ $db = $model->getDataSource();
+ if (empty($model->tablePrefix)) {
+ $model->tablePrefix = $db->config['prefix'];
+ }
$this->fields = $model->schema(true);
$this->fields[$model->primaryKey]['key'] = 'primary';
$this->table = $db->fullTableName($model, false);
- ClassRegistry::config(array('ds' => 'test_suite'));
+ ClassRegistry::config(array('ds' => 'test'));
ClassRegistry::flush();
} elseif (isset($import['table'])) {
$model = new Model(null, $import['table'], $import['connection']);
diff --git a/cake/tests/lib/cake_test_model.php b/cake/tests/lib/cake_test_model.php
index de4f1be8d..52affed27 100644
--- a/cake/tests/lib/cake_test_model.php
+++ b/cake/tests/lib/cake_test_model.php
@@ -26,6 +26,6 @@ require_once LIBS.'model'.DS.'model.php';
* @subpackage cake.cake.tests.lib
*/
class CakeTestModel extends Model {
- public $useDbConfig = 'test_suite';
+ public $useDbConfig = 'test';
public $cacheSources = false;
}
diff --git a/cake/tests/lib/cake_test_suite.php b/cake/tests/lib/cake_test_suite.php
index 414fd8ace..0bfb74d8e 100644
--- a/cake/tests/lib/cake_test_suite.php
+++ b/cake/tests/lib/cake_test_suite.php
@@ -26,7 +26,8 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
protected $_fixtureManager = null;
/**
- * Sets the intances for the fixture manager that will be used by this class
+ * Sets the intances for the fixture manager that will be used by this class.
+ *
* @param CakeFixtureManager $manager the instance of the manager class
* @return void
* @access public
@@ -35,9 +36,46 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
$this->_fixtureManager = $manager;
}
+/**
+ * Adds all the files in a directory to the test suite. Does not recurse through directories.
+ *
+ * @param string $directory The directory to add tests from.
+ * @return void
+ */
+ public function addTestDirectory($directory = '.') {
+ $files = new DirectoryIterator($directory);
+
+ foreach ($files as $file) {
+ if (!$file->isFile()) {
+ continue;
+ }
+ $file = $file->getRealPath();
+ $this->addTestFile($file);
+ }
+ }
+
+/**
+ * Recursively adds all the files in a directory to the test suite.
+ *
+ * @param string $directory The directory subtree to add tests from.
+ * @return void
+ */
+ public function addTestDirectoryRecursive($directory = '.') {
+ $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
+
+ foreach ($files as $file) {
+ if (!$file->isFile()) {
+ continue;
+ }
+ $file = $file->getRealPath();
+ $this->addTestFile($file);
+ }
+ }
+
/**
* Method that is called before the tests of this test suite are run.
- * It will load fixtures accordingly for each test
+ * It will load fixtures accordingly for each test.
+ *
* @return void
* @access protected
*/
@@ -55,6 +93,7 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
/**
* Method that is called after all the tests of this test suite are run.
+ *
* @return void
* @access protected
*/
@@ -63,7 +102,5 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
if ($this->_fixtureManager) {
$this->_fixtureManager->shutDown();
}
- $this->_fixtureManager = null;
- $this->sharedFixture = null;
}
}
\ No newline at end of file
diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php
index ef8cdc741..95b204eac 100644
--- a/cake/tests/lib/cake_test_suite_dispatcher.php
+++ b/cake/tests/lib/cake_test_suite_dispatcher.php
@@ -272,7 +272,14 @@ class CakeTestSuiteDispatcher {
* @return void
*/
function _runTestCase() {
- $Reporter = CakeTestSuiteDispatcher::getReporter();
- return $this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']);
+ try {
+ $Reporter = CakeTestSuiteDispatcher::getReporter();
+ return $this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']);
+ } catch (MissingConnectionException $exception) {
+ ob_end_clean();
+ $baseDir = $this->_baseDir;
+ include CAKE_TESTS_LIB . 'templates' . DS . 'missing_conenction.php';
+ exit();
+ }
}
}
diff --git a/cake/tests/lib/templates/missing_conenction.php b/cake/tests/lib/templates/missing_conenction.php
new file mode 100644
index 000000000..c77210f95
--- /dev/null
+++ b/cake/tests/lib/templates/missing_conenction.php
@@ -0,0 +1,27 @@
+
+ * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
+ *
+ * Licensed under The Open Group Test Suite License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
+ * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
+ * @package cake
+ * @subpackage cake.cake.tests.libs
+ * @since CakePHP(tm) v 1.2.0.4433
+ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
+ */
+?>
+
+
+
Missing Test Database Connection
+
getMessage(); ?>
+
getTraceAsString(); ?>
+
+
\ No newline at end of file
diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php
index d7bdd966e..598379fda 100644
--- a/cake/tests/lib/test_manager.php
+++ b/cake/tests/lib/test_manager.php
@@ -106,30 +106,6 @@ class TestManager {
}
}
-/**
- * Runs all tests in the Application depending on the current appTest setting
- *
- * @param PHPUnit_Framework_TestListener $reporter Reporter instance to attach to the test case.
- * @return mixed
- */
- public function runAllTests(&$reporter) {
- $testCases = $this->_getTestFileList($this->_getTestsPath($reporter->params));
-
- if ($this->appTest) {
- $test = $this->getTestSuite(__('All App Tests', true));
- } else if ($this->pluginTest) {
- $test = $this->getTestSuite(sprintf(__('All %s Plugin Tests', true), Inflector::humanize($this->pluginTest)));
- } else {
- $test = $this->getTestSuite(__('All Core Tests', true));
- }
-
- foreach ($testCases as $testCase) {
- $test->addTestFile($testCase);
- }
-
- return $this->run($reporter);
- }
-
/**
* Runs a specific test case file
*
@@ -186,40 +162,6 @@ class TestManager {
return $suite;
}
-/**
- * Adds all testcases in a given directory to a given GroupTest object
- *
- * @param object $groupTest Instance of TestSuite/GroupTest that files are to be added to.
- * @param string $directory The directory to add tests from.
- * @return void
- * @access public
- * @static
- */
- public static function addTestCasesFromDirectory(&$groupTest, $directory = '.') {
- $testCases = self::_getTestFileList($directory);
- foreach ($testCases as $testCase) {
- $groupTest->addTestFile($testCase);
- }
- }
-
-/**
- * Adds a specific test file and thereby all of its test cases and group tests to a given group test file
- *
- * @param object $groupTest Instance of TestSuite/GroupTest that a file should be added to.
- * @param string $file The file name, minus the suffix to add.
- * @return void
- * @access public
- * @static
- */
- public static function addTestFile(&$groupTest, $file) {
- if (file_exists($file . self::$_testExtension)) {
- $file .= self::$_testExtension;
- } elseif (file_exists($file . self::$_groupExtension)) {
- $file .= self::$_groupExtension;
- }
- $groupTest->addTestFile($file);
- }
-
/**
* Returns a list of test cases found in the current valid test case path
*
diff --git a/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/default.po b/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/default.po
new file mode 100644
index 000000000..426b6f055
--- /dev/null
+++ b/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/default.po
@@ -0,0 +1,5 @@
+msgid "default.foo"
+msgstr "Default Foo"
+
+msgid "default.bar"
+msgstr "Default Bar"
diff --git a/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom1.po b/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom1.po
new file mode 100644
index 000000000..86fbb7f19
--- /dev/null
+++ b/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom1.po
@@ -0,0 +1,8 @@
+msgid ""
+msgstr "Test Domain 1"
+
+msgid "dom1.foo"
+msgstr "Dom 1 Foo"
+
+msgid "dom1.bar"
+msgstr "Dom 1 Bar"
diff --git a/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom2.po b/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom2.po
new file mode 100644
index 000000000..40c017c93
--- /dev/null
+++ b/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom2.po
@@ -0,0 +1,8 @@
+msgid ""
+msgstr "Test Domain"
+
+msgid "dom2.foo"
+msgstr "Dom 2 Foo"
+
+msgid "dom2.bar"
+msgstr "Dom 2 Bar"
diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php
index c6ad3b1e3..bfd6bb938 100644
--- a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php
+++ b/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php
@@ -39,8 +39,8 @@ class TestPluginAuthUser extends TestPluginAppModel {
/**
* useDbConfig property
*
- * @var string 'test_suite'
+ * @var string 'test'
* @access public
*/
- public $useDbConfig = 'test_suite';
+ public $useDbConfig = 'test';
}
diff --git a/cake/tests/test_app/views/layouts/default.ctp b/cake/tests/test_app/views/layouts/default.ctp
index df808691a..747832e5d 100644
--- a/cake/tests/test_app/views/layouts/default.ctp
+++ b/cake/tests/test_app/views/layouts/default.ctp
@@ -16,6 +16,7 @@
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+$this->loadHelper('Html');
?>
@@ -26,8 +27,6 @@
-
-
Html->css('cake.generic');?>
@@ -38,8 +37,6 @@
- Session->flash();?>
-