Merge branch '2.1' into 2.2

Conflicts:
	lib/Cake/Test/Case/Model/ModelWriteTest.php
This commit is contained in:
mark_story 2012-03-18 21:26:45 -04:00
commit c58b61c17b
128 changed files with 1342 additions and 1072 deletions

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
################################################################################
#
# Bake is a shell script for running CakePHP bake script

View file

@ -2,5 +2,5 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

View file

@ -137,11 +137,17 @@
<package name="PHPUnit" channel="pear.phpunit.de" minimum_version="3.5.0" type="optional" />
</dependencies>
<dirroles key="bin">script</dirroles>
<dirroles key="Cake/Test">php</dirroles>
<dirroles key="Cake/Console/Templates/skel">php</dirroles>
<dirroles key="Cake/Console/Templates/default">php</dirroles>
<dirroles key="Cake/View">php</dirroles>
<release>
<install as="cake" name="bin/cake" />
<install as="cake.php" name="bin/cake.php" />
<install as="cake.bat" name="bin/cake.bat" />
</release>
<exceptions key="Cake/VERSION.txt">php</exceptions>
<exceptions key="Cake/LICENSE.txt">php</exceptions>
</d51pearpkg2>
</target>

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
################################################################################
#
# Bake is a shell script for running CakePHP bake script
@ -30,4 +30,4 @@ APP=`pwd`
exec php -q "$LIB"cake.php -working "$APP" "$@"
exit;
exit;

View file

@ -2,5 +2,5 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
################################################################################
#
# Bake is a shell script for running CakePHP bake script

View file

@ -190,8 +190,9 @@ class CookieComponent extends Component {
public function startup(Controller $controller) {
$this->_expire($this->time);
$this->_values[$this->name] = array();
if (isset($_COOKIE[$this->name])) {
$this->_values = $this->_decrypt($_COOKIE[$this->name]);
$this->_values[$this->name] = $this->_decrypt($_COOKIE[$this->name]);
}
}
@ -215,6 +216,10 @@ class CookieComponent extends Component {
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::write
*/
public function write($key, $value = null, $encrypt = true, $expires = null) {
if (empty($this->_values[$this->name])) {
$this->read();
}
if (is_null($encrypt)) {
$encrypt = true;
}
@ -227,14 +232,14 @@ class CookieComponent extends Component {
foreach ($key as $name => $value) {
if (strpos($name, '.') === false) {
$this->_values[$name] = $value;
$this->_values[$this->name][$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[$this->name][$names[0]])) {
$this->_values[$this->name][$names[0]] = array();
}
$this->_values[$names[0]] = Set::insert($this->_values[$names[0]], $names[1], $value);
$this->_values[$this->name][$names[0]] = Set::insert($this->_values[$this->name][$names[0]], $names[1], $value);
$this->_write('[' . implode('][', $names) . ']', $value);
}
}
@ -252,26 +257,28 @@ class CookieComponent extends Component {
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::read
*/
public function read($key = null) {
if (empty($this->_values) && isset($_COOKIE[$this->name])) {
$this->_values = $this->_decrypt($_COOKIE[$this->name]);
if (empty($this->_values[$this->name]) && isset($_COOKIE[$this->name])) {
$this->_values[$this->name] = $this->_decrypt($_COOKIE[$this->name]);
}
if (empty($this->_values[$this->name])) {
$this->_values[$this->name] = array();
}
if (is_null($key)) {
return $this->_values;
return $this->_values[$this->name];
}
if (strpos($key, '.') !== false) {
$names = explode('.', $key, 2);
$key = $names[0];
}
if (!isset($this->_values[$key])) {
if (!isset($this->_values[$this->name][$key])) {
return null;
}
if (!empty($names[1])) {
return Set::extract($this->_values[$key], $names[1]);
return Set::extract($this->_values[$this->name][$key], $names[1]);
}
return $this->_values[$key];
return $this->_values[$this->name][$key];
}
/**
@ -288,22 +295,22 @@ class CookieComponent extends Component {
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::delete
*/
public function delete($key) {
if (empty($this->_values)) {
if (empty($this->_values[$this->name])) {
$this->read();
}
if (strpos($key, '.') === false) {
if (isset($this->_values[$key]) && is_array($this->_values[$key])) {
foreach ($this->_values[$key] as $idx => $val) {
if (isset($this->_values[$this->name][$key]) && is_array($this->_values[$this->name][$key])) {
foreach ($this->_values[$this->name][$key] as $idx => $val) {
$this->_delete("[$key][$idx]");
}
}
$this->_delete("[$key]");
unset($this->_values[$key]);
unset($this->_values[$this->name][$key]);
return;
}
$names = explode('.', $key, 2);
if (isset($this->_values[$names[0]])) {
$this->_values[$names[0]] = Set::remove($this->_values[$names[0]], $names[1]);
if (isset($this->_values[$this->name][$names[0]])) {
$this->_values[$this->name][$names[0]] = Set::remove($this->_values[$this->name][$names[0]], $names[1]);
}
$this->_delete('[' . implode('][', $names) . ']');
}
@ -319,17 +326,17 @@ class CookieComponent extends Component {
*/
public function destroy() {
if (isset($_COOKIE[$this->name])) {
$this->_values = $this->_decrypt($_COOKIE[$this->name]);
$this->_values[$this->name] = $this->_decrypt($_COOKIE[$this->name]);
}
foreach ($this->_values as $name => $value) {
foreach ($this->_values[$this->name] as $name => $value) {
if (is_array($value)) {
foreach ($value as $key => $val) {
unset($this->_values[$name][$key]);
unset($this->_values[$this->name][$name][$key]);
$this->_delete("[$name][$key]");
}
}
unset($this->_values[$name]);
unset($this->_values[$this->name][$name]);
$this->_delete("[$name]");
}
}
@ -503,5 +510,5 @@ class CookieComponent extends Component {
}
return $array;
}
}

View file

@ -581,9 +581,11 @@ class RequestHandlerComponent extends Component {
$controller->ext = '.ctp';
$viewClass = Inflector::classify($type);
App::uses($viewClass . 'View', 'View');
if (class_exists($viewClass . 'View')) {
$viewName = $viewClass . 'View';
if (!class_exists($viewName)) {
App::uses($viewName, 'View');
}
if (class_exists($viewName)) {
$controller->viewClass = $viewClass;
} elseif (empty($this->_renderType)) {
$controller->viewPath .= DS . $type;

View file

@ -75,20 +75,26 @@ class Configure {
App::$bootstrapping = false;
App::init();
App::build();
$level = -1;
if (isset(self::$_values['Error']['level'])) {
error_reporting(self::$_values['Error']['level']);
$level = self::$_values['Error']['level'];
}
if (!empty(self::$_values['Error']['handler'])) {
set_error_handler(self::$_values['Error']['handler'], $level);
}
if (!empty(self::$_values['Exception']['handler'])) {
set_exception_handler(self::$_values['Exception']['handler']);
}
$exception = array(
'handler' => 'ErrorHandler::handleException',
);
$error = array(
'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED,
);
self::_setErrorHandlers($error, $exception);
if (!include APP . 'Config' . DS . 'bootstrap.php') {
trigger_error(__d('cake_dev', "Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", APP . 'Config' . DS), E_USER_ERROR);
}
restore_error_handler();
self::_setErrorHandlers(
self::$_values['Error'],
self::$_values['Exception']
);
unset($error, $exception);
}
}
@ -336,4 +342,24 @@ class Configure {
return false;
}
/**
* Set the error and exception handlers.
*
* @param array $error The Error handling configuration.
* @param array $exception The exception handling configuration.
* @return void
*/
protected static function _setErrorHandlers($error, $exception) {
$level = -1;
if (isset($error['level'])) {
error_reporting($error['level']);
$level = $error['level'];
}
if (!empty($error['handler'])) {
set_error_handler($error['handler'], $level);
}
if (!empty($exception['handler'])) {
set_exception_handler($exception['handler']);
}
}
}

View file

@ -607,7 +607,7 @@ class TreeBehavior extends ModelBehavior {
$rght = $count++;
$Model->create(false);
$Model->id = $array[$Model->alias][$Model->primaryKey];
$Model->save(array($left => $lft, $right => $rght), array('callbacks' => false));
$Model->save(array($left => $lft, $right => $rght), array('callbacks' => false, 'validate' => false));
}
foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey, $parent), 'order' => $left)) as $array) {
$Model->create(false);
@ -744,7 +744,7 @@ class TreeBehavior extends ModelBehavior {
$Model->id = $id;
return $Model->save(
array($left => $edge + 1, $right => $edge + 2, $parent => null),
array('callbacks' => false)
array('callbacks' => false, 'validate' => false)
);
}
}

View file

@ -1792,8 +1792,14 @@ class Model extends Object implements CakeEventListener {
$newValues[$row] = $values;
unset($values);
} elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
if (!empty($row[$this->{$join}->primaryKey])) {
$newJoins[] = $row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']];
}
$newData[] = $row;
} elseif (isset($row[$join]) && isset($row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
if (!empty($row[$join][$this->{$join}->primaryKey])) {
$newJoins[] = $row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']];
}
$newData[] = $row[$join];
}
}
@ -1827,8 +1833,10 @@ class Model extends Object implements CakeEventListener {
if (!empty($newData)) {
foreach ($newData as $data) {
$data[$this->hasAndBelongsToMany[$assoc]['foreignKey']] = $id;
$this->{$join}->create($data);
$this->{$join}->save();
if (empty($data[$this->{$join}->primaryKey])) {
$this->{$join}->create();
}
$this->{$join}->save($data);
}
}

View file

@ -51,7 +51,7 @@ class AllTests extends PHPUnit_Framework_TestSuite {
$suite->addTestFile($path . 'Model' . DS . 'ModelTest.php');
$suite->addTestFile($path . 'AllRoutingTest.php');
$suite->addTestFile($path . 'AllNetworkTest.php');
$suite->addTestFile($path . 'AllTestSuiteTest.php');;
$suite->addTestFile($path . 'AllTestSuiteTest.php');
$suite->addTestFile($path . 'AllUtilityTest.php');
$suite->addTestFile($path . 'AllViewTest.php');
$suite->addTestFile($path . 'AllI18nTest.php');

View file

@ -685,7 +685,7 @@ class BasicsTest extends CakeTestCase {
ob_start();
debug('this-is-a-test', false);
$result = ob_get_clean();
$expectedText = <<<EXPECTED
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'this-is-a-test'
@ -697,7 +697,7 @@ EXPECTED;
ob_start();
debug('<div>this-is-a-test</div>', true);
$result = ob_get_clean();
$expectedHtml = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
@ -709,9 +709,9 @@ EXPECTED;
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', true, true);
debug('<div>this-is-a-test</div>', true, true);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expected = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
@ -723,9 +723,9 @@ EXPECTED;
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', true, false);
debug('<div>this-is-a-test</div>', true, false);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expected = <<<EXPECTED
<div class="cake-debug-output">
<pre class="cake-debug">
@ -737,9 +737,9 @@ EXPECTED;
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', null);
debug('<div>this-is-a-test</div>', null);
$result = ob_get_clean();
$expectedHtml = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
@ -747,7 +747,7 @@ $expectedHtml = <<<EXPECTED
</pre>
</div>
EXPECTED;
$expectedText = <<<EXPECTED
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
@ -761,9 +761,9 @@ EXPECTED;
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', null, false);
debug('<div>this-is-a-test</div>', null, false);
$result = ob_get_clean();
$expectedHtml = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<pre class="cake-debug">
@ -771,7 +771,7 @@ $expectedHtml = <<<EXPECTED
</pre>
</div>
EXPECTED;
$expectedText = <<<EXPECTED
$expectedText = <<<EXPECTED
########## DEBUG ##########
'<div>this-is-a-test</div>'
@ -785,9 +785,9 @@ EXPECTED;
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', false);
debug('<div>this-is-a-test</div>', false);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expected = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
@ -797,9 +797,9 @@ EXPECTED;
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', false, true);
debug('<div>this-is-a-test</div>', false, true);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expected = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
@ -809,9 +809,9 @@ EXPECTED;
$this->assertEquals($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', false, false);
debug('<div>this-is-a-test</div>', false, false);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expected = <<<EXPECTED
########## DEBUG ##########
'<div>this-is-a-test</div>'
@ -828,13 +828,13 @@ EXPECTED;
*/
public function testPr() {
ob_start();
pr('this is a test');
pr('this is a test');
$result = ob_get_clean();
$expected = "<pre>this is a test</pre>";
$this->assertEquals($expected, $result);
ob_start();
pr(array('this' => 'is', 'a' => 'test'));
pr(array('this' => 'is', 'a' => 'test'));
$result = ob_get_clean();
$expected = "<pre>Array\n(\n [this] => is\n [a] => test\n)\n</pre>";
$this->assertEquals($expected, $result);

View file

@ -160,7 +160,6 @@ class CookieComponentTest extends CakeTestCase {
*/
public function testReadPlainCookieData() {
$this->_setCookieData();
$data = $this->Cookie->read('Plain_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
$this->assertEquals($data, $expected);
@ -170,6 +169,26 @@ class CookieComponentTest extends CakeTestCase {
$this->assertEquals($data, $expected);
}
/**
* test read() after switching the cookie name.
*
* @return void
*/
public function testReadWithNameSwitch() {
$_COOKIE = array(
'CakeTestCookie' => array(
'key' => 'value'
),
'OtherTestCookie' => array(
'key' => 'other value'
)
);
$this->assertEquals('value', $this->Cookie->read('key'));
$this->Cookie->name = 'OtherTestCookie';
$this->assertEquals('other value', $this->Cookie->read('key'));
}
/**
* test a simple write()
*

View file

@ -353,5 +353,5 @@ class ConfigureTest extends CakeTestCase {
$reader = new StdClass();
Configure::config('test', $reader);
}
}
}

View file

@ -2668,7 +2668,7 @@ class I18nTest extends CakeTestCase {
private function __domainCategoryPlural($domain = 'test_plugin', $category = 3) {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category), (float)$number);
$plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category), (float)$number);
}
return $plurals;
}
@ -2691,7 +2691,7 @@ class I18nTest extends CakeTestCase {
private function __domainPlural($domain = 'test_plugin') {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number), (float)$number );
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number), (float)$number );
}
return $plurals;
}
@ -2724,7 +2724,7 @@ class I18nTest extends CakeTestCase {
private function __plural() {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number), (float)$number);
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number), (float)$number);
}
return $plurals;
}
@ -2747,7 +2747,7 @@ class I18nTest extends CakeTestCase {
private function __pluralFromCore() {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number), (float)$number );
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number), (float)$number );
}
return $plurals;
}

View file

@ -67,7 +67,6 @@ class L10nTest extends CakeTestCase {
$l10n->get('');
$this->assertEquals($l10n->lang, 'en-us');
// Using $this->default
$l10n = new L10n();
@ -83,7 +82,7 @@ class L10nTest extends CakeTestCase {
* @return void
*/
public function testGetAutoLanguage() {
$__SERVER = $_SERVER;
$serverBackup = $_SERVER;
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'inexistent,en-ca';
$l10n = new L10n();
@ -107,7 +106,7 @@ class L10nTest extends CakeTestCase {
$this->assertEquals($l10n->languagePath, array('eng', 'eng', 'eng'));
$this->assertEquals($l10n->locale, 'eng');
$_SERVER = $__SERVER;
$_SERVER = $serverBackup;
}
/**
@ -895,7 +894,7 @@ class L10nTest extends CakeTestCase {
$result = $l10n->catalog(array('cy'));
$expected = array(
'cy' => array('language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8',
'direction' => 'ltr')
'direction' => 'ltr')
);
$this->assertEquals($expected, $result);

View file

@ -159,14 +159,12 @@ class MultibyteTest extends CakeTestCase {
65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276);
$this->assertEquals($expected, $result);
$string = '';
$result = Multibyte::utf8($string);
$expected = array(65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360,
65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370);
$this->assertEquals($expected, $result);
$string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク';
$result = Multibyte::utf8($string);
$expected = array(65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392,
@ -341,7 +339,6 @@ class MultibyteTest extends CakeTestCase {
11489, 11491);
$this->assertEquals($expected, $result);
$string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';
$result = Multibyte::utf8($string);
$expected = array(64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279);
@ -6566,57 +6563,7 @@ class MultibyteTest extends CakeTestCase {
$result = mb_strtolower($string);
$expected = 'ἀι';
$this->assertEquals($expected, $result);
/*
The tests below are flaky across different platforms.
$string = 'ԀԂԄԆԈԊԌԎԐԒ';
$result = mb_strtolower($string);
$expected = 'ԁԃԅԇԉԋԍԏԑԓ';
$this->assertEquals($expected, $result);
$string = 'ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖև';
$result = mb_strtolower($string);
$expected = 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև';
$this->assertEquals($expected, $result);
$string = 'ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẖẗẘẙẚẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ';
$result = mb_strtolower($string);
$expected = 'ḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ';
$this->assertEquals($expected, $result);
$string = 'ΩKÅ';
$result = mb_strtolower($string);
$expected = 'ωkå';
$this->assertEquals($expected, $result);
$string = 'ΩKÅ';
$result = mb_strtolower($string);
$expected = 'ωkå';
$this->assertEquals($expected, $result);
/*
mb_strtolower does not work for these strings.
$string = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃ';
$result = mb_strtolower($string);
$expected = 'ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↄ';
$this->assertEquals($expected, $result);
$string = 'ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ';
$result = mb_strtolower($string);
$expected = 'ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ';
$this->assertEquals($expected, $result);
$string = 'ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮ';
$result = mb_strtolower($string);
$expected = 'ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞ';
$this->assertEquals($expected, $result);
$string = 'ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢ';
$result = mb_strtolower($string);
$expected = 'ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ';
$this->assertEquals($expected, $result);
*/
$string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';
$result = mb_strtolower($string);
$expected = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';
@ -7696,29 +7643,6 @@ mb_strtolower does not work for these strings.
$expected = 'ΩKÅ';
$this->assertEquals($expected, $result);
/*
mb_strtoupper does not work for these strings.
$string = 'ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↄ';
$result = mb_strtoupper($string);
$expected = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃ';
$this->assertEquals($expected, $result);
$string = 'ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ';
$result = mb_strtoupper($string);
$expected = 'ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ';
$this->assertEquals($expected, $result);
$string = 'ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞ';
$result = mb_strtoupper($string);
$expected = 'ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮ';
$this->assertEquals($expected, $result);
$string = 'ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ';
$result = mb_strtoupper($string);
$expected = 'ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢ';
$this->assertEquals($expected, $result);
*/
$string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';
$result = mb_strtoupper($string);
$expected = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';

View file

@ -198,6 +198,7 @@ class DbAroUserTest extends CakeTestModel {
return array('DbAroTest' => array('DbAroTest.model' => 'AuthUser', 'DbAroTest.foreign_key' => 2));
}
}
}
/**
@ -218,6 +219,7 @@ class TestDbAcl extends DbAcl {
$this->Aco = new DbAcoTest();
$this->Aro->Permission = new DbPermissionTest();
}
}
/**
@ -332,7 +334,6 @@ class AclNodeTest extends CakeTestCase {
$result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id');
$expected = array(4, 2, 1);
$this->assertEquals($expected, $result);
}
/**

View file

@ -27,10 +27,10 @@ App::uses('DbAcl', 'Model');
/**
* Test Person class - self joined model
*
* @package Cake.Test.Case.Model.Behavior
*/
* Test Person class - self joined model
*
* @package Cake.Test.Case.Model.Behavior
*/
class AclPerson extends CakeTestModel {
/**
@ -98,13 +98,14 @@ class AclPerson extends CakeTestModel {
return array('AclPerson' => array('id' => $motherId));
}
}
}
/**
* AclUser class
*
* @package Cake.Test.Case.Model.Behavior
*/
* AclUser class
*
* @package Cake.Test.Case.Model.Behavior
*/
class AclUser extends CakeTestModel {
/**
@ -135,13 +136,14 @@ class AclUser extends CakeTestModel {
public function parentNode() {
return null;
}
}
/**
* AclPost class
*
* @package Cake.Test.Case.Model.Behavior
*/
* AclPost class
*
* @package Cake.Test.Case.Model.Behavior
*/
class AclPost extends CakeTestModel {
/**
@ -172,13 +174,14 @@ class AclPost extends CakeTestModel {
public function parentNode() {
return null;
}
}
/**
* AclBehaviorTest class
*
* @package Cake.Test.Case.Model.Behavior
*/
* AclBehaviorTest class
*
* @package Cake.Test.Case.Model.Behavior
*/
class AclBehaviorTest extends CakeTestCase {
/**
@ -342,7 +345,7 @@ class AclBehaviorTest extends CakeTestCase {
$this->assertEquals($result['Aro']['parent_id'], 7);
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro');
$this->assertEquals(sizeof($node), 2);
$this->assertEquals(count($node), 2);
$this->assertEquals($node[0]['Aro']['parent_id'], 7);
$this->assertEquals($node[1]['Aro']['parent_id'], null);
}
@ -362,7 +365,6 @@ class AclBehaviorTest extends CakeTestCase {
);
$this->Aro->save($aroData);
$acoData = array(
'Aco' => array(
'model' => 'AclPerson',

View file

@ -19,7 +19,7 @@
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/**
* ContainableTest class
@ -3553,8 +3553,10 @@ class ContainableBehaviorTest extends CakeTestCase {
$this->skipIf(
!isset($config->test) || !isset($config->test2),
'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.'
'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.'
);
$db = ConnectionManager::getDataSource('test2');

View file

@ -22,7 +22,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/**
* TranslateBehaviorTest class
@ -351,7 +351,6 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel = new TranslatedItem();
$TestModel->locale = array('deu', 'eng', 'cze');
$result = $TestModel->read(null, 1);
$expected = array(
'TranslatedItem' => array(

View file

@ -19,7 +19,7 @@
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/**

View file

@ -21,7 +21,7 @@
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/**
* TreeBehaviorNumberTest class
@ -42,7 +42,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
*
* @var array
*/
protected $settings = array(
public $settings = array(
'modelClass' => 'NumberTree',
'leftField' => 'lft',
'rightField' => 'rght',
@ -410,7 +410,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$validTree = $this->Tree->verify();
$this->assertSame($validTree, true);
}
}
/**
* testMovePromote method
@ -424,12 +424,12 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];
$parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id= $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id);
$direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parentId);
$direct = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField));
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
@ -450,14 +450,14 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];
$parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->whitelist = array($parentField, 'name', 'description');
$this->Tree->saveField($parentField, $parent_id);
$this->Tree->saveField($parentField, $parentId);
$result = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField));
$result = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField));
$expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)),
array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)),
array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13)));
@ -495,13 +495,13 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
$parent_id = $parent[$modelClass]['id'];
$parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id);
$this->Tree->saveField($parentField, $parentId);
$result = $this->Tree->children($parent_id, true, array('name'));
$result = $this->Tree->children($parentId, true, array('name'));
$expects = array(array($modelClass => array('name' => '1.1.1')),
array($modelClass => array('name' => '1.1.2')),
array($modelClass => array('name' => '1.2')));
@ -523,13 +523,13 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
$parent_id = $parent[$modelClass]['id'];
$parentId = $parent[$modelClass]['id'];
$data= $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id);
$this->Tree->saveField($parentField, $parentId);
$result = $this->Tree->children($parent_id, true, array('name'));
$result = $this->Tree->children($parentId, true, array('name'));
$expects = array(array($modelClass => array('name' => '1.2.1')),
array($modelClass => array('name' => '1.2.2')),
array($modelClass => array('name' => '1.1')));
@ -551,15 +551,14 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];
$parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$expects = $this->Tree->find('all');
$before = $this->Tree->read(null, $data[$modelClass]['id']);
$this->Tree->id = $parent_id;
//$this->expectError('Trying to save a node under itself in TreeBehavior::beforeSave');
$this->Tree->id = $parentId;
$this->Tree->saveField($parentField, $data[$modelClass]['id']);
$results = $this->Tree->find('all');
@ -584,13 +583,11 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null;
$initialCount = $this->Tree->find('count');
$data= $this->Tree->findByName('1.1');
$data = $this->Tree->findByName('1.1');
//$this->expectError('Trying to save a node under a none-existant node in TreeBehavior::beforeSave');
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, 999999);
//$this->assertSame($saveSuccess, false);
$laterCount = $this->Tree->find('count');
$this->assertSame($initialCount, $laterCount);
@ -610,9 +607,8 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->id = null;
$initialCount = $this->Tree->find('count');
$data= $this->Tree->findByName('1.1');
$data = $this->Tree->findByName('1.1');
//$this->expectError('Trying to set a node to be the parent of itself in TreeBehavior::beforeSave');
$this->Tree->id = $data[$modelClass]['id'];
$saveSuccess = $this->Tree->saveField($parentField, $this->Tree->id);
@ -902,11 +898,11 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$laterCount = $this->Tree->find('count');
$this->assertEquals($initialCount - 1, $laterCount);
$validTree= $this->Tree->verify();
$validTree = $this->Tree->verify();
$this->assertSame($validTree, true);
$initialCount = $this->Tree->find('count');
$result= $this->Tree->findByName('1.1');
$result = $this->Tree->findByName('1.1');
$return = $this->Tree->delete($result[$modelClass]['id']);
$this->assertEquals($return, true);
@ -1033,12 +1029,14 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->removeFromTree($result[$modelClass]['id'], true);
$laterCount = $this->Tree->find('count');
$this->assertEquals($initialCount-1, $laterCount);
$this->assertEquals($initialCount - 1, $laterCount);
$children = $this->Tree->children($result[$modelClass][$parentField], true, array('name'), $leftField . ' asc');
$expects= array(array($modelClass => array('name' => '1.1.1')),
$expects = array(
array($modelClass => array('name' => '1.1.1')),
array($modelClass => array('name' => '1.1.2')),
array($modelClass => array('name' => '1.2')));
array($modelClass => array('name' => '1.2'))
);
$this->assertEquals($children, $expects);
$topNodes = $this->Tree->children(false, true,array('name'));
@ -1092,7 +1090,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$this->Tree->id= $data[$modelClass]['id'];
$this->Tree->id = $data[$modelClass]['id'];
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)),
@ -1147,7 +1145,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
$this->Tree->id= $data[$modelClass]['id'];
$this->Tree->id = $data[$modelClass]['id'];
$result = $this->Tree->getParentNode(null, array('name'));
$expects = array($modelClass => array('name' => '1.2'));
@ -1165,7 +1163,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
$this->Tree->id= $data[$modelClass]['id'];
$this->Tree->id = $data[$modelClass]['id'];
$result = $this->Tree->getPath(null, array('name'));
$expects = array(array($modelClass => array('name' => '1. Root')),
@ -1187,7 +1185,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
$this->Tree->initialize(2, 2);
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$this->Tree->id= $data[$modelClass]['id'];
$this->Tree->id = $data[$modelClass]['id'];
$direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField));
$expects = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)),

View file

@ -21,7 +21,7 @@
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/**
* TreeBehaviorScopedTest class

View file

@ -21,7 +21,7 @@
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/**
* TreeBehaviorUuidTest class
@ -68,12 +68,12 @@ class TreeBehaviorUuidTest extends CakeTestCase {
$this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];
$parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id= $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parent_id);
$direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->saveField($parentField, $parentId);
$direct = $this->Tree->children($parentId, true, array('name', $leftField, $rightField));
$expects = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));
@ -94,14 +94,14 @@ class TreeBehaviorUuidTest extends CakeTestCase {
$this->Tree->id = null;
$parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
$parent_id = $parent[$modelClass]['id'];
$parentId = $parent[$modelClass]['id'];
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1')));
$this->Tree->id = $data[$modelClass]['id'];
$this->Tree->whitelist = array($parentField, 'name', 'description');
$this->Tree->saveField($parentField, $parent_id);
$this->Tree->saveField($parentField, $parentId);
$result = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField));
$result = $this->Tree->children($parentId, true, array('name', $leftField, $rightField));
$expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)),
array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)),
array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13)));

View file

@ -320,6 +320,7 @@ class TestBehavior extends ModelBehavior {
$query = preg_replace('/^in\s+/', 'Location.name = \'', $query);
return $method . '\' AND ' . $query . '\'';
}
}
/**
@ -328,15 +329,15 @@ class TestBehavior extends ModelBehavior {
* @package Cake.Test.Case.Model
*/
class Test2Behavior extends TestBehavior {
public $mapMethods = array('/mappingRobot(\w+)/' => 'mapped');
public function resolveMethod(Model $model, $stuff) {
}
public function mapped(Model $model, $method, $query) {
}
}
/**
@ -353,11 +354,13 @@ class Test3Behavior extends TestBehavior{
* @package Cake.Test.Case.Model
*/
class Test4Behavior extends ModelBehavior{
public function setup(Model $model, $config = null) {
$model->bindModel(
array('hasMany' => array('Comment'))
);
}
}
/**
@ -366,11 +369,13 @@ class Test4Behavior extends ModelBehavior{
* @package Cake.Test.Case.Model
*/
class Test5Behavior extends ModelBehavior{
public function setup(Model $model, $config = null) {
$model->bindModel(
array('belongsTo' => array('User'))
);
}
}
/**
@ -379,11 +384,13 @@ class Test5Behavior extends ModelBehavior{
* @package Cake.Test.Case.Model
*/
class Test6Behavior extends ModelBehavior{
public function setup(Model $model, $config = null) {
$model->bindModel(
array('hasAndBelongsToMany' => array('Tag'))
);
}
}
/**
@ -392,11 +399,13 @@ class Test6Behavior extends ModelBehavior{
* @package Cake.Test.Case.Model
*/
class Test7Behavior extends ModelBehavior{
public function setup(Model $model, $config = null) {
$model->bindModel(
array('hasOne' => array('Attachment'))
);
}
}
/**
@ -693,14 +702,12 @@ class BehaviorCollectionTest extends CakeTestCase {
$Apple->Child->Behaviors->attach('Test', array('before' => 'modify'));
$result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4')));
//$this->assertEquals($expected, $result2);
$Apple->Child->Behaviors->disable('Test');
$result = $Apple->find('all');
$this->assertEquals($expected, $result);
$Apple->Child->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on'));
//$this->assertSame($Apple->find('all'), array());
$Apple->Child->Behaviors->attach('Test', array('after' => 'off'));
$this->assertEquals($Apple->find('all'), $expected);
@ -710,21 +717,9 @@ class BehaviorCollectionTest extends CakeTestCase {
$Apple->Child->Behaviors->attach('Test', array('after' => 'test2'));
$this->assertEquals($Apple->find('all'), $expected);
$Apple->Child->Behaviors->attach('Test', array('after' => 'modify'));
$expected = array(
array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'),
array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'),
array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'),
array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'),
array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'),
array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17')
);
//$this->assertEquals($Apple->find('all'), $expected);
}
/**
/**
* testBehaviorHasOneFindCallbacks method
*
* @return void
@ -746,32 +741,10 @@ class BehaviorCollectionTest extends CakeTestCase {
$Apple->Sample->Behaviors->attach('Test', array('before' => 'test'));
$this->assertSame($Apple->find('all'), $expected);
$Apple->Sample->Behaviors->attach('Test', array('before' => 'modify'));
$expected2 = array(
array(
'Apple' => array('id' => 1),
'Child' => array(
array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17'))),
array(
'Apple' => array('id' => 2),
'Child' => array(
array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17'),
array('id' => 3, 'name' => 'green blue', 'mytime' => '22:57:17'),
array('id' => 4, 'name' => 'Test Name', 'mytime' => '22:57:17'))),
array(
'Apple' => array('id' => 3),
'Child' => array())
);
$result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4')));
//$this->assertEquals($expected, $result2);
$Apple->Sample->Behaviors->disable('Test');
$result = $Apple->find('all');
$this->assertEquals($expected, $result);
$Apple->Sample->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on'));
//$this->assertSame($Apple->find('all'), array());
$Apple->Sample->Behaviors->attach('Test', array('after' => 'off'));
$this->assertEquals($Apple->find('all'), $expected);
@ -780,18 +753,6 @@ class BehaviorCollectionTest extends CakeTestCase {
$Apple->Sample->Behaviors->attach('Test', array('after' => 'test2'));
$this->assertEquals($Apple->find('all'), $expected);
$Apple->Sample->Behaviors->attach('Test', array('after' => 'modify'));
$expected = array(
array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'),
array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'),
array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'),
array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'),
array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'),
array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17')
);
//$this->assertEquals($Apple->find('all'), $expected);
}
/**
@ -848,18 +809,6 @@ class BehaviorCollectionTest extends CakeTestCase {
$Apple->Parent->Behaviors->attach('Test', array('after' => 'test2'));
$this->assertEquals($Apple->find('all'), $expected);
$Apple->Parent->Behaviors->attach('Test', array('after' => 'modify'));
$expected = array(
array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'),
array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'),
array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'),
array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'),
array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'),
array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'),
array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17')
);
//$this->assertEquals($Apple->find('all'), $expected);
}
/**
@ -968,7 +917,6 @@ class BehaviorCollectionTest extends CakeTestCase {
$this->assertSame(trim(ob_get_clean()), 'beforeDelete success');
$this->assertSame($results, true);
$Apple->Behaviors->attach('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on'));
ob_start();
$results = $Apple->delete(2, false);
@ -1190,5 +1138,4 @@ class BehaviorCollectionTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
}

View file

@ -113,6 +113,7 @@ class MyAppSchema extends CakeSchema {
}
return $this->$var;
}
}
/**
@ -219,6 +220,7 @@ class TestAppSchema extends CakeSchema {
*/
public function teardown($version) {
}
}
/**
@ -434,6 +436,7 @@ class SchemaCrossDatabaseFixture extends CakeTestFixture {
* @package Cake.Test.Case.Model
*/
class SchemaPrefixAuthUser extends CakeTestModel {
/**
* name property
*
@ -493,8 +496,8 @@ class CakeSchemaTest extends CakeTestCase {
*/
public function tearDown() {
parent::tearDown();
if (file_exists(TMP . 'tests' . DS .'schema.php')) {
unlink(TMP . 'tests' . DS .'schema.php');
if (file_exists(TMP . 'tests' . DS . 'schema.php')) {
unlink(TMP . 'tests' . DS . 'schema.php');
}
unset($this->Schema);
CakePlugin::unload();
@ -570,20 +573,20 @@ class CakeSchemaTest extends CakeTestCase {
}
/**
* testSchemaReadWithAppModel method
*
* @access public
* @return void
*/
* testSchemaReadWithAppModel method
*
* @access public
* @return void
*/
public function testSchemaReadWithAppModel() {
$connections = ConnectionManager::enumConnectionObjects();
ConnectionManager::drop('default');
ConnectionManager::create('default', $connections['test']);
try {
$read = $this->Schema->read(array(
'connection' => 'default',
'name' => 'TestApp',
'models' => array('AppModel')
'connection' => 'default',
'name' => 'TestApp',
'models' => array('AppModel')
));
} catch(MissingTableException $mte) {
ConnectionManager::drop('default');
@ -632,7 +635,6 @@ class CakeSchemaTest extends CakeTestCase {
));
unset($read['tables']['missing']);
$this->assertTrue(isset($read['tables']['auth_users']), 'auth_users key missing %s');
}
/**
@ -699,14 +701,15 @@ class CakeSchemaTest extends CakeTestCase {
$config = ConnectionManager::enumConnectionObjects();
$this->skipIf(
!isset($config['test']) || !isset($config['test2']),
'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.'
'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.'
);
$db2 = ConnectionManager::getDataSource('test2');
$db = ConnectionManager::getDataSource('test2');
$fixture = new SchemaCrossDatabaseFixture();
$fixture->create($db2);
$fixture->insert($db2);
$fixture->create($db);
$fixture->insert($db);
$read = $this->Schema->read(array(
'connection' => 'test',
@ -726,7 +729,7 @@ class CakeSchemaTest extends CakeTestCase {
$this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear');
$this->assertTrue(isset($read['tables']['cross_database']));
$fixture->drop($db2);
$fixture->drop($db);
}
/**
@ -755,11 +758,15 @@ class CakeSchemaTest extends CakeTestCase {
* @return void
*/
public function testSchemaWrite() {
$write = $this->Schema->write(array('name' => 'MyOtherApp', 'tables' => $this->Schema->tables, 'path' => TMP . 'tests'));
$file = file_get_contents(TMP . 'tests' . DS .'schema.php');
$write = $this->Schema->write(array(
'name' => 'MyOtherApp',
'tables' => $this->Schema->tables,
'path' => TMP . 'tests'
));
$file = file_get_contents(TMP . 'tests' . DS . 'schema.php');
$this->assertEquals($write, $file);
require_once( TMP . 'tests' . DS .'schema.php');
require_once TMP . 'tests' . DS . 'schema.php';
$OtherSchema = new MyOtherAppSchema();
$this->assertEquals($this->Schema->tables, $OtherSchema->tables);
}
@ -807,21 +814,21 @@ class CakeSchemaTest extends CakeTestCase {
$tables = array(
'missing' => array(
'categories' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'name' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 100),
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'created' => array('type' => 'datetime', 'null' => false, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => null),
'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 100),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
),
'ratings' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => NULL),
'model' => array('type' => 'varchar', 'null' => false, 'default' => NULL),
'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => NULL),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => null),
'model' => array('type' => 'varchar', 'null' => false, 'default' => null),
'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => null),
'created' => array('type' => 'datetime', 'null' => false, 'default' => null),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => null),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
@ -830,12 +837,12 @@ class CakeSchemaTest extends CakeTestCase {
$expected = array(
'ratings' => array(
'add' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'after' => 'id'),
'model' => array('type' => 'varchar', 'null' => false, 'default' => NULL, 'after' => 'foreign_key'),
'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => NULL, 'after' => 'model'),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL, 'after' => 'value'),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL, 'after' => 'created'),
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => null, 'after' => 'id'),
'model' => array('type' => 'varchar', 'null' => false, 'default' => null, 'after' => 'foreign_key'),
'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => null, 'after' => 'model'),
'created' => array('type' => 'datetime', 'null' => false, 'default' => null, 'after' => 'value'),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => null, 'after' => 'created'),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
@ -852,13 +859,13 @@ class CakeSchemaTest extends CakeTestCase {
public function testCompareEmptyStringAndNull() {
$One = new CakeSchema(array(
'posts' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => false, 'default' => '')
)
));
$Two = new CakeSchema(array(
'posts' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => false, 'default' => null)
)
));

View file

@ -208,8 +208,8 @@ class ConnectionManagerTest extends CakeTestCase {
*/
public function testLoadDataSource() {
$connections = array(
array('classname' => 'Mysql', 'filename' => 'Mysql', 'package' => 'Database'),
array('classname' => 'Postgres', 'filename' => 'Postgres', 'package' => 'Database'),
array('classname' => 'Mysql', 'filename' => 'Mysql', 'package' => 'Database'),
array('classname' => 'Postgres', 'filename' => 'Postgres', 'package' => 'Database'),
array('classname' => 'Sqlite', 'filename' => 'Sqlite', 'package' => 'Database'),
);

View file

@ -29,6 +29,7 @@ require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
* @package Cake.Test.Case.Model.Datasource.Database
*/
class MysqlTest extends CakeTestCase {
/**
* autoFixtures property
*
@ -267,7 +268,6 @@ class MysqlTest extends CakeTestCase {
$this->Dbo->rawQuery('DROP TABLE ' . $name);
$this->assertEquals($expected, $result);
$name = $this->Dbo->fullTableName('with_a_key');
$this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ));');
$expected = array(
@ -370,8 +370,8 @@ class MysqlTest extends CakeTestCase {
'Column_name' => 'id',
'Collation' => 'A',
'Cardinality' => '0',
'Sub_part' => NULL,
'Packed' => NULL,
'Sub_part' => null,
'Packed' => null,
'Null' => '',
'Index_type' => 'BTREE',
'Comment' => ''
@ -383,9 +383,9 @@ class MysqlTest extends CakeTestCase {
'Seq_in_index' => '1',
'Column_name' => 'bool',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Cardinality' => null,
'Sub_part' => null,
'Packed' => null,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
@ -397,9 +397,9 @@ class MysqlTest extends CakeTestCase {
'Seq_in_index' => '1',
'Column_name' => 'small_int',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Cardinality' => null,
'Sub_part' => null,
'Packed' => null,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
@ -411,9 +411,9 @@ class MysqlTest extends CakeTestCase {
'Seq_in_index' => '1',
'Column_name' => 'bool',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Cardinality' => null,
'Sub_part' => null,
'Packed' => null,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
@ -425,9 +425,9 @@ class MysqlTest extends CakeTestCase {
'Seq_in_index' => '2',
'Column_name' => 'small_int',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Cardinality' => null,
'Sub_part' => null,
'Packed' => null,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
@ -442,7 +442,7 @@ class MysqlTest extends CakeTestCase {
->will($this->returnValue($resultMock));
foreach ($columnData as $i => $data) {
$resultMock->expects($this->at($i))->method('fetch')->will($this->returnValue((object) $data));
$resultMock->expects($this->at($i))->method('fetch')->will($this->returnValue((object)$data));
}
$result = $mockDbo->index($name, false);
@ -512,7 +512,7 @@ class MysqlTest extends CakeTestCase {
$this->Dbo->cacheSources = $this->Dbo->testing = false;
$table = $this->Dbo->fullTableName('altertest');
$schema1 = new CakeSchema(array(
$schemaA = new CakeSchema(array(
'name' => 'AlterTest1',
'connection' => 'test',
'altertest' => array(
@ -521,7 +521,7 @@ class MysqlTest extends CakeTestCase {
'group1' => array('type' => 'integer', 'null' => true),
'group2' => array('type' => 'integer', 'null' => true)
)));
$result = $this->Dbo->createSchema($schema1);
$result = $this->Dbo->createSchema($schemaA);
$this->assertContains('`id` int(11) DEFAULT 0 NOT NULL,', $result);
$this->assertContains('`name` varchar(50) NOT NULL,', $result);
$this->assertContains('`group1` int(11) DEFAULT NULL', $result);
@ -531,7 +531,7 @@ class MysqlTest extends CakeTestCase {
$query = $this->Dbo->getConnection()->prepare($result);
$this->assertEquals($result, $query->queryString);
$schema2 = new CakeSchema(array(
$schemaB = new CakeSchema(array(
'name' => 'AlterTest2',
'connection' => 'test',
'altertest' => array(
@ -546,7 +546,7 @@ class MysqlTest extends CakeTestCase {
'PRIMARY' => array('column' => 'id', 'unique' => 1))
)));
$result = $this->Dbo->alterSchema($schema2->compare($schema1));
$result = $this->Dbo->alterSchema($schemaB->compare($schemaA));
$this->assertContains("ALTER TABLE $table", $result);
$this->assertContains('ADD KEY name_idx (`name`),', $result);
$this->assertContains('ADD KEY group_idx (`group1`),', $result);
@ -558,7 +558,7 @@ class MysqlTest extends CakeTestCase {
$this->assertEquals($result, $query->queryString);
// Change three indexes, delete one and add another one
$schema3 = new CakeSchema(array(
$schemaC = new CakeSchema(array(
'name' => 'AlterTest3',
'connection' => 'test',
'altertest' => array(
@ -573,7 +573,7 @@ class MysqlTest extends CakeTestCase {
'id_name_idx' => array('column' => array('id', 'name'), 'unique' => 0))
)));
$result = $this->Dbo->alterSchema($schema3->compare($schema2));
$result = $this->Dbo->alterSchema($schemaC->compare($schemaB));
$this->assertContains("ALTER TABLE $table", $result);
$this->assertContains('DROP PRIMARY KEY,', $result);
$this->assertContains('DROP KEY name_idx,', $result);
@ -588,10 +588,10 @@ class MysqlTest extends CakeTestCase {
$this->assertEquals($result, $query->queryString);
// Compare us to ourself.
$this->assertEquals($schema3->compare($schema3), array());
$this->assertEquals($schemaC->compare($schemaC), array());
// Drop the indexes
$result = $this->Dbo->alterSchema($schema1->compare($schema3));
$result = $this->Dbo->alterSchema($schemaA->compare($schemaC));
$this->assertContains("ALTER TABLE $table", $result);
$this->assertContains('DROP KEY name_idx,', $result);
@ -628,7 +628,7 @@ class MysqlTest extends CakeTestCase {
public function testAlteringTableParameters() {
$this->Dbo->cacheSources = $this->Dbo->testing = false;
$schema1 = new CakeSchema(array(
$schemaA = new CakeSchema(array(
'name' => 'AlterTest1',
'connection' => 'test',
'altertest' => array(
@ -641,8 +641,8 @@ class MysqlTest extends CakeTestCase {
)
)
));
$this->Dbo->rawQuery($this->Dbo->createSchema($schema1));
$schema2 = new CakeSchema(array(
$this->Dbo->rawQuery($this->Dbo->createSchema($schemaA));
$schemaB = new CakeSchema(array(
'name' => 'AlterTest1',
'connection' => 'test',
'altertest' => array(
@ -655,7 +655,7 @@ class MysqlTest extends CakeTestCase {
)
)
));
$result = $this->Dbo->alterSchema($schema2->compare($schema1));
$result = $this->Dbo->alterSchema($schemaB->compare($schemaA));
$this->assertContains('DEFAULT CHARSET=utf8', $result);
$this->assertContains('ENGINE=InnoDB', $result);
$this->assertContains('COLLATE=utf8_general_ci', $result);
@ -666,7 +666,7 @@ class MysqlTest extends CakeTestCase {
$this->assertEquals($result['Engine'], 'InnoDB');
$this->assertEquals($result['charset'], 'utf8');
$this->Dbo->rawQuery($this->Dbo->dropSchema($schema1));
$this->Dbo->rawQuery($this->Dbo->dropSchema($schemaA));
}
/**
@ -828,7 +828,6 @@ class MysqlTest extends CakeTestCase {
)
));
$this->Dbo->execute($this->Dbo->createSchema($schema));
$model = new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes'));
$result = $model->getDataSource()->describe($model);
@ -932,7 +931,7 @@ class MysqlTest extends CakeTestCase {
$this->assertEquals($result, array('`Article`.`id`'));
$test->expects($this->at(0))->method('execute')
->with('SELECT `Article`.`id` FROM ' . $test->fullTableName('articles'). ' AS `Article` WHERE 1 = 1');
->with('SELECT `Article`.`id` FROM ' . $test->fullTableName('articles') . ' AS `Article` WHERE 1 = 1');
$result = $test->read($this->Model, array(
'fields' => $this->Model->escapeField(),
@ -1097,7 +1096,7 @@ class MysqlTest extends CakeTestCase {
* @param array $data
* @return array
*/
function _scrubQueryData($data) {
protected function _scrubQueryData($data) {
static $base = null;
if ($base === null) {
$base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array());
@ -1243,7 +1242,7 @@ class MysqlTest extends CakeTestCase {
$result = $this->Dbo->generateAssociationQuery($this->Featured2, $null, null, null, null, $queryData, false, $null);
$this->assertRegExp(
'/^SELECT\s+`Featured2`\.`id`, `Featured2`\.`article_id`, `Featured2`\.`category_id`, `Featured2`\.`name`,\s+'.
'/^SELECT\s+`Featured2`\.`id`, `Featured2`\.`article_id`, `Featured2`\.`category_id`, `Featured2`\.`name`,\s+' .
'`ArticleFeatured2`\.`id`, `ArticleFeatured2`\.`title`, `ArticleFeatured2`\.`user_id`, `ArticleFeatured2`\.`published`\s+' .
'FROM\s+\S+`featured2` AS `Featured2`\s+LEFT JOIN\s+\S+`article_featured` AS `ArticleFeatured2`' .
'\s+ON\s+\(`ArticleFeatured2`.`published` = \'Y\'\s+AND\s+`Featured2`\.`article_featured2_id` = `ArticleFeatured2`\.`id`\)' .
@ -1336,7 +1335,7 @@ class MysqlTest extends CakeTestCase {
$testModel4Table = $this->Dbo->fullTableName($this->Model->TestModel4, true, true);
$result = $this->Dbo->buildJoinStatement($queryData['joins'][0]);
$expected = ' LEFT JOIN ' .$testModel4Table. ' AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)';
$expected = ' LEFT JOIN ' . $testModel4Table . ' AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)';
$this->assertEquals(trim($result), trim($expected));
$result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null);
@ -1368,7 +1367,7 @@ class MysqlTest extends CakeTestCase {
$testModel4Table = $this->Dbo->fullTableName($this->Model->TestModel4, true, true);
$result = $this->Dbo->buildJoinStatement($queryData['joins'][0]);
$expected = ' LEFT JOIN ' .$testModel4Table. ' AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)';
$expected = ' LEFT JOIN ' . $testModel4Table . ' AS `TestModel4` ON (`TestModel5`.`test_model4_id` = `TestModel4`.`id`)';
$this->assertEquals(trim($result), trim($expected));
$result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null);
@ -1429,19 +1428,19 @@ class MysqlTest extends CakeTestCase {
$result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet);
$this->assertRegExp(
'/^SELECT\s+' .
'`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+'.
'`TestModel6`\.`id`, `TestModel6`\.`test_model5_id`, `TestModel6`\.`name`, `TestModel6`\.`created`, `TestModel6`\.`updated`\s+' .
'FROM\s+\S+`test_model6` AS `TestModel6`\s+WHERE\s+' .
'`TestModel6`.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)\s*'.
'LIMIT \d*'.
'`TestModel6`.`test_model5_id`\s+=\s+\({\$__cakeID__\$}\)\s*' .
'LIMIT \d*' .
'\s*$/', $result
);
$result = $this->Dbo->generateAssociationQuery($this->Model, $null, null, null, null, $queryData, false, $null);
$this->assertRegExp(
'/^SELECT\s+'.
'`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+'.
'FROM\s+\S+`test_model5` AS `TestModel5`\s+WHERE\s+'.
'(?:\()?\s*1 = 1\s*(?:\))?'.
'/^SELECT\s+' .
'`TestModel5`\.`id`, `TestModel5`\.`test_model4_id`, `TestModel5`\.`name`, `TestModel5`\.`created`, `TestModel5`\.`updated`\s+' .
'FROM\s+\S+`test_model5` AS `TestModel5`\s+WHERE\s+' .
'(?:\()?\s*1 = 1\s*(?:\))?' .
'\s*$/', $result
);
}
@ -1484,7 +1483,7 @@ class MysqlTest extends CakeTestCase {
$this->Model->schema();
$this->_buildRelatedModels($this->Model);
$__backup = $this->Model->hasMany['TestModel6'];
$backup = $this->Model->hasMany['TestModel6'];
$this->Model->hasMany['TestModel6']['offset'] = 2;
$this->Model->hasMany['TestModel6']['limit'] = 5;
@ -1508,7 +1507,7 @@ class MysqlTest extends CakeTestCase {
$this->assertRegExp('/\s+FROM\s+\S+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result);
$this->assertRegExp('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result);
$this->Model->hasMany['TestModel6'] = $__backup;
$this->Model->hasMany['TestModel6'] = $backup;
}
/**
@ -1521,7 +1520,7 @@ class MysqlTest extends CakeTestCase {
$this->Model->schema();
$this->_buildRelatedModels($this->Model);
$__backup = $this->Model->hasMany['TestModel6'];
$backup = $this->Model->hasMany['TestModel6'];
$this->Model->hasMany['TestModel6']['page'] = 2;
$this->Model->hasMany['TestModel6']['limit'] = 5;
@ -1544,7 +1543,7 @@ class MysqlTest extends CakeTestCase {
$this->assertRegExp('/\s+FROM\s+\S+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result);
$this->assertRegExp('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result);
$this->Model->hasMany['TestModel6'] = $__backup;
$this->Model->hasMany['TestModel6'] = $backup;
}
/**
@ -1763,7 +1762,7 @@ class MysqlTest extends CakeTestCase {
$this->Model->schema();
$this->_buildRelatedModels($this->Model);
$__backup = $this->Model->hasAndBelongsToMany['TestModel7'];
$backup = $this->Model->hasAndBelongsToMany['TestModel7'];
$this->Model->hasAndBelongsToMany['TestModel7']['offset'] = 2;
$this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5;
@ -1786,7 +1785,7 @@ class MysqlTest extends CakeTestCase {
$this->assertRegExp('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result);
$this->assertRegExp('/\s+FROM\s+\S+`test_model4` AS `TestModel4`\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result);
$this->Model->hasAndBelongsToMany['TestModel7'] = $__backup;
$this->Model->hasAndBelongsToMany['TestModel7'] = $backup;
}
/**
@ -1799,7 +1798,7 @@ class MysqlTest extends CakeTestCase {
$this->Model->schema();
$this->_buildRelatedModels($this->Model);
$__backup = $this->Model->hasAndBelongsToMany['TestModel7'];
$backup = $this->Model->hasAndBelongsToMany['TestModel7'];
$this->Model->hasAndBelongsToMany['TestModel7']['page'] = 2;
$this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5;
@ -1822,7 +1821,7 @@ class MysqlTest extends CakeTestCase {
$this->assertRegExp('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`\s+/', $result);
$this->assertRegExp('/\s+FROM\s+\S+`test_model4` AS `TestModel4`\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result);
$this->Model->hasAndBelongsToMany['TestModel7'] = $__backup;
$this->Model->hasAndBelongsToMany['TestModel7'] = $backup;
}
/**
@ -1976,7 +1975,6 @@ class MysqlTest extends CakeTestCase {
$expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\' AND `Member`.`user` LIKE \'mariano.iglesias%\'';
$this->assertEquals($expected, $result);
$result = $this->Dbo->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"');
$expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"';
$this->assertEquals($expected, $result);
@ -2125,7 +2123,7 @@ class MysqlTest extends CakeTestCase {
$expected = " WHERE MAX(`Post`.`rating`) > '50'";
$this->assertEquals($expected, $result);
$result = $this->Dbo->conditions(array('lower(Article.title)' => 'secrets'));
$result = $this->Dbo->conditions(array('lower(Article.title)' => 'secrets'));
$expected = " WHERE lower(`Article`.`title`) = 'secrets'";
$this->assertEquals($expected, $result);
@ -2943,13 +2941,12 @@ class MysqlTest extends CakeTestCase {
$modelTable = $this->Dbo->fullTableName($this->Model);
$this->Dbo->expects($this->at(1))->method('execute')
->with('SELECT COUNT(`TestModel`.`id`) AS count FROM ' .$modelTable. ' AS `TestModel` WHERE `TestModel`.`name` = \'harry\'');
->with('SELECT COUNT(`TestModel`.`id`) AS count FROM ' . $modelTable . ' AS `TestModel` WHERE `TestModel`.`name` = \'harry\'');
$this->Dbo->expects($this->at(2))->method('execute')
->with('SELECT COUNT(`TestModel`.`id`) AS count FROM ' .$modelTable. ' AS `TestModel` WHERE 1 = 1');
->with('SELECT COUNT(`TestModel`.`id`) AS count FROM ' . $modelTable . ' AS `TestModel` WHERE 1 = 1');
$this->Dbo->hasAny($this->Model, array('TestModel.name' => 'harry'));
$this->Dbo->hasAny($this->Model, array());
}
/**
@ -3205,7 +3202,7 @@ class MysqlTest extends CakeTestCase {
$conditions = array('comment_count >' => 2);
$query = 'SELECT ' . join(',', $this->Dbo->fields($Article, null, array('id', 'comment_count'))) .
' FROM ' . $this->Dbo->fullTableName($Article) . ' Article ' . $this->Dbo->conditions($conditions, true, true, $Article);
' FROM ' . $this->Dbo->fullTableName($Article) . ' Article ' . $this->Dbo->conditions($conditions, true, true, $Article);
$result = $this->Dbo->fetchAll($query);
$expected = array(array(
'Article' => array('id' => 1, 'comment_count' => 4)
@ -3308,8 +3305,7 @@ class MysqlTest extends CakeTestCase {
$data = array(2, 2.2);
$this->assertEquals($this->Dbo->introspectType($data), 'integer');
// NULL
// null
$result = $this->Dbo->value(null, 'boolean');
$this->assertEquals($result, 'NULL');
@ -3317,7 +3313,6 @@ class MysqlTest extends CakeTestCase {
$result = $this->Dbo->value('', 'boolean');
$this->assertEquals($result, "'0'");
// BOOLEAN
$result = $this->Dbo->value('true', 'boolean');
$this->assertEquals($result, "'1'");
@ -3519,7 +3514,6 @@ class MysqlTest extends CakeTestCase {
$this->Dbo->update($Article, array('field1'), array('value1'));
$this->Dbo->update($Article, array('field1'), array('2'), '2=2');
$this->Dbo->update($Article, array('field1'), array("'value'"), array('index' => 'val'));
}
/**

View file

@ -56,6 +56,7 @@ class DboPostgresTestDb extends Postgres {
public function getLastQuery() {
return $this->simulated[count($this->simulated) - 1];
}
}
/**
@ -123,26 +124,27 @@ class PostgresTestModel extends Model {
*/
public function schema($field = false) {
return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
}
}
/**
@ -173,13 +175,14 @@ class PostgresClientTestModel extends Model {
*/
public function schema($field = false) {
return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
}
}
/**
@ -523,7 +526,7 @@ class PostgresTest extends CakeTestCase {
$db1 = ConnectionManager::getDataSource('test');
$db1->cacheSources = false;
$db1->rawQuery('CREATE TABLE ' . $db1->fullTableName('datatype_tests') . ' (
$db1->rawQuery('CREATE TABLE ' . $db1->fullTableName('datatype_tests') . ' (
id serial NOT NULL,
"varchar" character varying(40) NOT NULL,
"full_length" character varying NOT NULL,
@ -541,12 +544,10 @@ class PostgresTest extends CakeTestCase {
$schema->tables = array('datatype_tests' => $result['tables']['missing']['datatype_tests']);
$result = $db1->createSchema($schema, 'datatype_tests');
$this->assertNotRegExp('/timestamp DEFAULT/', $result);
$this->assertRegExp('/\"full_length\"\s*text\s.*,/', $result);
$this->assertRegExp('/timestamp\s*,/', $result);
$db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests'));
$db1->query($result);
@ -731,7 +732,7 @@ class PostgresTest extends CakeTestCase {
$this->Dbo->query($this->Dbo->dropSchema($schema1));
}
/*
/**
* Test it is possible to use virtual field with postgresql
*
* @return void
@ -783,8 +784,11 @@ class PostgresTest extends CakeTestCase {
}
/**
* Test it is possible to do a SELECT COUNT(DISTINCT Model.field) query in postgres and it gets correctly quoted
*/
* Test it is possible to do a SELECT COUNT(DISTINCT Model.field)
* query in postgres and it gets correctly quoted
*
* @return void
*/
public function testQuoteDistinctInFunction() {
$this->loadFixtures('Article');
$Article = new Article;
@ -860,16 +864,16 @@ class PostgresTest extends CakeTestCase {
*/
public function testEncoding() {
$result = $this->Dbo->setEncoding('UTF8');
$this->assertTrue($result) ;
$this->assertTrue($result);
$result = $this->Dbo->getEncoding();
$this->assertEquals('UTF8', $result) ;
$this->assertEquals('UTF8', $result);
$result = $this->Dbo->setEncoding('EUC_JP'); /* 'EUC_JP' is right character code name in PostgreSQL */
$this->assertTrue($result) ;
$this->assertTrue($result);
$result = $this->Dbo->getEncoding();
$this->assertEquals('EUC_JP', $result) ;
$this->assertEquals('EUC_JP', $result);
}
/**

View file

@ -55,6 +55,7 @@ class DboSqliteTestDb extends Sqlite {
public function getLastQuery() {
return $this->simulated[count($this->simulated) - 1];
}
}
/**

View file

@ -104,6 +104,7 @@ class SqlserverTestDb extends Sqlserver {
public function describe($model) {
return empty($this->describe) ? parent::describe($model) : $this->describe;
}
}
/**
@ -133,24 +134,24 @@ class SqlserverTestModel extends CakeTestModel {
* @var array
*/
protected $_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
/**
@ -176,6 +177,7 @@ class SqlserverTestModel extends CakeTestModel {
public function find($conditions = null, $fields = null, $order = null, $recursive = null) {
return $conditions;
}
}
/**
@ -184,6 +186,7 @@ class SqlserverTestModel extends CakeTestModel {
* @package Cake.Test.Case.Model.Datasource.Database
*/
class SqlserverClientTestModel extends CakeTestModel {
/**
* name property
*
@ -218,12 +221,14 @@ class SqlserverClientTestModel extends CakeTestModel {
* @package Cake.Test.Case.Model.Datasource.Database
*/
class SqlserverTestResultIterator extends ArrayIterator {
/**
* closeCursor method
*
* @return void
*/
public function closeCursor() {}
public function closeCursor() {
}
/**
* fetch method
@ -238,6 +243,7 @@ class SqlserverTestResultIterator extends ArrayIterator {
$this->next();
return $current;
}
}
/**
@ -408,7 +414,7 @@ class SqlserverTest extends CakeTestCase {
*/
public function testDescribe() {
$SqlserverTableDescription = new SqlserverTestResultIterator(array(
(object) array(
(object)array(
'Default' => '((0))',
'Field' => 'count',
'Key' => 0,
@ -416,7 +422,7 @@ class SqlserverTest extends CakeTestCase {
'Null' => 'NO',
'Type' => 'integer'
),
(object) array(
(object)array(
'Default' => '',
'Field' => 'body',
'Key' => 0,
@ -424,7 +430,7 @@ class SqlserverTest extends CakeTestCase {
'Null' => 'YES',
'Type' => 'nvarchar'
),
(object) array(
(object)array(
'Default' => '',
'Field' => 'published',
'Key' => 0,
@ -433,7 +439,7 @@ class SqlserverTest extends CakeTestCase {
'Null' => 'YES',
'Size' => ''
),
(object) array(
(object)array(
'Default' => '',
'Field' => 'id',
'Key' => 1,

View file

@ -27,6 +27,7 @@ class MockPDO extends PDO {
public function __construct() {
}
}
class MockDataSource extends DataSource {
@ -49,6 +50,7 @@ class DboTestSource extends DboSource {
public function setConnection($conn) {
$this->_connection = $conn;
}
}
/**
@ -109,7 +111,6 @@ class DboSourceTest extends CakeTestCase {
unset($this->Model);
}
/**
* test that booleans and null make logical condition strings.
*
@ -420,7 +421,6 @@ class DboSourceTest extends CakeTestCase {
$this->assertEquals($data, $expected);
}
/**
* testMagicMethodQuerying method
*
@ -492,7 +492,6 @@ class DboSourceTest extends CakeTestCase {
$result = $this->db->query('directCall', array(), $this->Model);
}
/**
* testValue method
*
@ -659,7 +658,6 @@ class DboSourceTest extends CakeTestCase {
$expected = array('query' => 'Error 1', 'affected' => '', 'numRows' => '', 'took' => '');
}
/**
* test getting the query log as an array, setting bind params.
*
@ -676,7 +674,6 @@ class DboSourceTest extends CakeTestCase {
$this->assertEquals($log['log'][1], $expected);
}
/**
* test that query() returns boolean values from operations like CREATE TABLE
*
@ -693,7 +690,6 @@ class DboSourceTest extends CakeTestCase {
$this->assertTrue($result, 'Query did not return a boolean');
}
/**
* test order to generate query order clause for virtual fields
*
@ -716,8 +712,6 @@ class DboSourceTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* test the permutations of fullTableName()
*
@ -784,7 +778,6 @@ class DboSourceTest extends CakeTestCase {
$this->assertTrue(empty(DboTestSource::$methodCache['fields']), 'Cache not empty');
}
/**
* Test that group works without a model
*

View file

@ -23,8 +23,11 @@ App::uses('DatabaseSession', 'Model/Datasource/Session');
class_exists('CakeSession');
class SessionTestModel extends Model {
public $name = 'SessionTestModel';
public $useTable = 'sessions';
}
/**
@ -182,4 +185,4 @@ class DatabaseSessionTest extends CakeTestCase {
$storage->gc();
$this->assertFalse($storage->read('foo'));
}
}
}

View file

@ -66,8 +66,9 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest {
$this->skipIf($this->db instanceof Sqlite, 'This test is not compatible with Sqlite.');
$this->skipIf(
!isset($config['test']) || !isset($config['test2']),
'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.'
'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.'
);
}
@ -176,8 +177,9 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest {
$config = ConnectionManager::enumConnectionObjects();
$this->skipIf(
!isset($config['test']) || !isset($config['test2']) || !isset($config['test_database_three']),
'Primary, secondary, and tertiary test databases not configured, skipping test.'
. ' To run these tests, you must define $test, $test2, and $test_database_three in your database configuration.'
'Primary, secondary, and tertiary test databases not configured,' .
' skipping test. To run these tests, you must define ' .
'$test, $test2, and $test_database_three in your database configuration.'
);
$this->loadFixtures('Player', 'Guild', 'GuildsPlayer', 'Armor', 'ArmorsPlayer');

View file

@ -260,7 +260,6 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertEquals($expected, $result);
}
/**
* test that delete() updates the correct records counterCache() records.
*
@ -688,7 +687,6 @@ class ModelDeleteTest extends BaseModelTest {
* @return void
*/
public function testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable() {
$this->loadFixtures('Apple', 'Device', 'ThePaperMonkies');
$ThePaper = new ThePaper();
$ThePaper->id = 1;
@ -792,25 +790,26 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertEquals(count($before[0]['Tag']), 2, 'Tag count for Article.id = 1 is incorrect, should be 2 %s');
// From now on, Tag #1 is only associated with Post #1
$submitted_data = array(
$submittedData = array(
"Tag" => array("id" => 1, 'tag' => 'tag1'),
"Article" => array(
"Article" => array(1)
)
);
$Tag->save($submitted_data);
$Tag->save($submittedData);
// One more submission (The other way around) to make sure the reverse save looks good.
$submitted_data = array(
$submittedData = array(
"Article" => array("id" => 2, 'title' => 'second article'),
"Tag" => array(
"Tag" => array(2, 3)
)
);
// ERROR:
// Postgresql: DELETE FROM "articles_tags" WHERE tag_id IN ('1', '3')
// MySQL: DELETE `ArticlesTag` FROM `articles_tags` AS `ArticlesTag` WHERE `ArticlesTag`.`article_id` = 2 AND `ArticlesTag`.`tag_id` IN (1, 3)
$Article->save($submitted_data);
$Article->save($submittedData);
// Want to make sure Article #1 has Tag #1 and Tag #2 still.
$after = $Article->find("all", array(

View file

@ -27,18 +27,19 @@ App::uses('DboSource', 'Model/Datasource');
class DboMock extends DboSource {
/**
* Returns the $field without modifications
*/
* Returns the $field without modifications
*/
public function name($field) {
return $field;
}
/**
* Returns true to fake a database connection
*/
* Returns true to fake a database connection
*/
public function connect() {
return true;
}
}
/**
@ -149,8 +150,8 @@ class ModelIntegrationTest extends BaseModelTest {
*/
public function testPkInHabtmLinkModelArticleB() {
$this->loadFixtures('Article', 'Tag', 'ArticlesTag');
$TestModel2 = new ArticleB();
$this->assertEquals($TestModel2->ArticlesTag->primaryKey, 'article_id');
$TestModel = new ArticleB();
$this->assertEquals($TestModel->ArticlesTag->primaryKey, 'article_id');
}
/**
@ -176,7 +177,7 @@ class ModelIntegrationTest extends BaseModelTest {
/**
* testPkInHabtmLinkModel method
*
* @return void
* @return void
*/
public function testPkInHabtmLinkModel() {
//Test Nonconformant Models
@ -186,18 +187,17 @@ class ModelIntegrationTest extends BaseModelTest {
//test conformant models with no PK in the join table
$this->loadFixtures('Article', 'Tag');
$TestModel2 = new Article();
$this->assertEquals($TestModel2->ArticlesTag->primaryKey, 'article_id');
$TestModel = new Article();
$this->assertEquals($TestModel->ArticlesTag->primaryKey, 'article_id');
//test conformant models with PK in join table
$TestModel3 = new Portfolio();
$this->assertEquals($TestModel3->ItemsPortfolio->primaryKey, 'id');
$TestModel = new Portfolio();
$this->assertEquals($TestModel->ItemsPortfolio->primaryKey, 'id');
//test conformant models with PK in join table - join table contains extra field
$this->loadFixtures('JoinA', 'JoinB', 'JoinAB');
$TestModel4 = new JoinA();
$this->assertEquals($TestModel4->JoinAsJoinB->primaryKey, 'id');
$TestModel = new JoinA();
$this->assertEquals($TestModel->JoinAsJoinB->primaryKey, 'id');
}
/**
@ -645,7 +645,6 @@ class ModelIntegrationTest extends BaseModelTest {
$expected = 3; // 3 domains belonging to cakephp
$this->assertEquals($expected, count($results['Domain']));
$Site->id = 2;
$results = $Site->read();
$expected = 2; // 2 domains belonging to markstory
@ -710,6 +709,102 @@ class ModelIntegrationTest extends BaseModelTest {
$this->assertEquals($activated['DomainsSite'], $results['Domain'][0]['DomainsSite']);
}
/**
* testHABTMKeepExistingAlternateDataFormat
*
* @return void
*/
public function testHABTMKeepExistingAlternateDataFormat() {
$this->loadFixtures('Site', 'Domain', 'DomainsSite');
$Site = new Site();
$expected = array(
array(
'DomainsSite' => array(
'id' => 1,
'site_id' => 1,
'domain_id' => 1,
'active' => true,
'created' => '2007-03-17 01:16:23'
)
),
array(
'DomainsSite' => array(
'id' => 2,
'site_id' => 1,
'domain_id' => 2,
'active' => true,
'created' => '2007-03-17 01:16:23'
)
)
);
$result = $Site->DomainsSite->find('all', array(
'conditions' => array('DomainsSite.site_id' => 1),
'fields' => array(
'DomainsSite.id',
'DomainsSite.site_id',
'DomainsSite.domain_id',
'DomainsSite.active',
'DomainsSite.created'
),
'order' => 'DomainsSite.id'
));
$this->assertEquals($expected, $result);
$time = date('Y-m-d H:i:s');
$data = array(
'Site' => array(
'id' => 1
),
'Domain' => array(
array(
'site_id' => 1,
'domain_id' => 3,
'created' => $time,
),
array(
'id' => 2,
'site_id' => 1,
'domain_id' => 2
),
)
);
$Site->save($data);
$expected = array(
array(
'DomainsSite' => array(
'id' => 2,
'site_id' => 1,
'domain_id' => 2,
'active' => true,
'created' => '2007-03-17 01:16:23'
)
),
array(
'DomainsSite' => array(
'id' => 7,
'site_id' => 1,
'domain_id' => 3,
'active' => false,
'created' => $time
)
)
);
$result = $Site->DomainsSite->find('all', array(
'conditions' => array('DomainsSite.site_id' => 1),
'fields' => array(
'DomainsSite.id',
'DomainsSite.site_id',
'DomainsSite.domain_id',
'DomainsSite.active',
'DomainsSite.created'
),
'order' => 'DomainsSite.id'
));
$this->assertEquals($expected, $result);
}
/**
* test HABM operations without clobbering existing records #275
*
@ -2249,7 +2344,6 @@ class ModelIntegrationTest extends BaseModelTest {
* @return void
*/
public function testMultischemaFixture() {
$config = ConnectionManager::enumConnectionObjects();
$this->skipIf($this->db instanceof Sqlite, 'This test is not compatible with Sqlite.');
$this->skipIf(!isset($config['test']) || !isset($config['test2']),
@ -2279,7 +2373,6 @@ class ModelIntegrationTest extends BaseModelTest {
* @return void
*/
public function testMultischemaFixtureWithThreeDatabases() {
$config = ConnectionManager::enumConnectionObjects();
$this->skipIf($this->db instanceof Sqlite, 'This test is not compatible with Sqlite.');
$this->skipIf(

View file

@ -68,7 +68,6 @@ class ModelReadTest extends BaseModelTest {
)
);
$Something->JoinThing->create($joinThingData);
$Something->JoinThing->save();
@ -347,7 +346,6 @@ class ModelReadTest extends BaseModelTest {
$result = $this->db->getQueryCache($query, $params);
$this->assertFalse($result === false);
}
/**
@ -6199,17 +6197,20 @@ class ModelReadTest extends BaseModelTest {
$expected = array(
'conditions' => array(
'user' => 'larry'),
'fields' => NULL,
'user' => 'larry'
),
'fields' => null,
'joins' => array(),
'limit' => NULL,
'offset' => NULL,
'limit' => null,
'offset' => null,
'order' => array(
0 => NULL),
0 => null
),
'page' => 1,
'group' => NULL,
'group' => null,
'callbacks' => true,
'returnQuery' => true);
'returnQuery' => true
);
$result = $TestModel->buildQuery('all', array('returnQuery' => true, 'conditions' => array('user' => 'larry')));
$this->assertEquals($expected, $result);
}
@ -7736,7 +7737,6 @@ class ModelReadTest extends BaseModelTest {
$this->assertEquals($result, $expectation);
$Author = ClassRegistry::init('Author');
$Author->virtualFields = array(
'full_name' => 'CONCAT(Author.user, " ", Author.id)'
@ -7804,7 +7804,6 @@ class ModelReadTest extends BaseModelTest {
$this->assertEquals($Post->getVirtualField('Post.other_field'), $Post->virtualFields['other_field']);
}
/**
* test that checks for error when NOT condition passed in key and a 1 element array value
*
@ -7823,9 +7822,8 @@ class ModelReadTest extends BaseModelTest {
)
)
);
$this->assertTrue(is_array($result) && !empty($result));
}
}
/**
* test custom find method
@ -7845,5 +7843,6 @@ class ModelReadTest extends BaseModelTest {
$result = $Article->find('unPublished');
$this->assertEquals(1, count($result));
}
}
}

View file

@ -51,7 +51,7 @@ class ModelValidationTest extends BaseModelTest {
'required' => true
),
'or' => true,
'ignore_on_same' => 'id'
'ignoreOnSame' => 'id'
);
$this->assertEquals($TestModel->validatorParams, $expected);

View file

@ -109,7 +109,6 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEquals($testResult['Article']['title'], $data['Article']['title']);
$this->assertEquals($testResult['Article']['created'], '2008-01-01 00:00:00');
}
/**
@ -403,7 +402,7 @@ class ModelWriteTest extends BaseModelTest {
$column = '';
}
$column .= $this->db->buildColumn(array('name' => 'child_count', 'type' => 'integer'));
$this->db->query('ALTER TABLE '. $this->db->fullTableName('category_threads') . ' ADD ' . $column);
$this->db->query('ALTER TABLE ' . $this->db->fullTableName('category_threads') . ' ADD ' . $column);
$this->db->flushMethodCache();
$Category = new CategoryThread();
$result = $Category->updateAll(array('CategoryThread.name' => "'updated'"), array('CategoryThread.parent_id' => 5));
@ -617,7 +616,6 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->saveField('title', '', true);
$this->assertFalse($result);
$TestModel->recursive = -1;
$TestModel->id = 1;
$result = $TestModel->saveField('user_id', 9999);
@ -630,7 +628,6 @@ class ModelWriteTest extends BaseModelTest {
));
$this->assertEquals($expected, $result);
$this->loadFixtures('Node', 'Dependency');
$Node = new Node();
$Node->set('id', 1);
@ -1512,12 +1509,16 @@ class ModelWriteTest extends BaseModelTest {
),
'Tag' => array(
'Tag' => array(1, 2, 3)
));
$result = $TestModel->create()
)
);
$result = $TestModel->create()
&& $TestModel->save($data, true, array('user_id', 'title', 'published'));
$this->assertFalse(empty($result));
$TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')));
$TestModel->unbindModel(array(
'belongsTo' => array('User'),
'hasMany' => array('Comment')
));
$result = $TestModel->read();
$expected = array(
'Article' => array(
@ -1550,7 +1551,6 @@ class ModelWriteTest extends BaseModelTest {
)));
$this->assertEquals($expected, $result);
$this->loadFixtures('JoinA', 'JoinC', 'JoinAC', 'JoinB', 'JoinAB');
$TestModel = new JoinA();
$TestModel->hasBelongsToMany = array('JoinC' => array('unique' => true));
@ -2133,7 +2133,6 @@ class ModelWriteTest extends BaseModelTest {
'id' => 3,
'title' => 'Third Article'
)));
$this->assertEquals($expected, $articles);
$comments = $Comment->find('all', array(
@ -2754,7 +2753,6 @@ class ModelWriteTest extends BaseModelTest {
unset($result[6]['Comment']['created'], $result[6]['Comment']['updated']);
$this->assertEquals($result[6]['Comment'], $expected);
$expected = array(
'id' => '2',
'comment_id' => '7',
@ -2878,7 +2876,6 @@ class ModelWriteTest extends BaseModelTest {
)));
$this->assertEquals($expected, $result);
$model->Attachment->bindModel(array('belongsTo' => array('Comment')), false);
$data = array(
'Comment' => array(
@ -4545,7 +4542,6 @@ class ModelWriteTest extends BaseModelTest {
$result = Set::extract('/Comment/article_id', $result);
$this->assertEquals($result[0], 4);
$model->deleteAll(true);
$data = array(
'Article' => array(
@ -4801,7 +4797,6 @@ class ModelWriteTest extends BaseModelTest {
unset($result[6]['Comment']['updated'], $result[6]['Comment']['created']);
$this->assertEquals($result[6]['Comment'], $expected);
$expected = array(
'id' => '2',
'comment_id' => '7',
@ -4985,7 +4980,6 @@ class ModelWriteTest extends BaseModelTest {
)));
$this->assertEquals($expected, $result);
$model->Attachment->bindModel(array('belongsTo' => array('Comment')), false);
$data = array(
'Comment' => array(
@ -5155,7 +5149,6 @@ class ModelWriteTest extends BaseModelTest {
), array('validate' => true, 'atomic' => false));
$this->assertSame($result, array(true, false));
}
/**
@ -5850,7 +5843,6 @@ class ModelWriteTest extends BaseModelTest {
$result = Set::extract('/Comment/article_id', $result);
$this->assertEquals($result[0], 4);
$model->deleteAll(true);
$data = array(
'Article' => array(
@ -6335,7 +6327,7 @@ class ModelWriteTest extends BaseModelTest {
'id' => '4',
'author_id' => '5',
'title' => 'Post without body',
'body' => NULL,
'body' => null,
'published' => 'N',
'created' => $ts,
'updated' => $ts,
@ -6343,7 +6335,7 @@ class ModelWriteTest extends BaseModelTest {
'Author' => array (
'id' => '5',
'user' => 'bob',
'password' => NULL,
'password' => null,
'created' => $ts,
'updated' => $ts,
'test' => 'working',
@ -6560,4 +6552,56 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEquals($expected, $result);
}
/**
* testSaveAllDeepHasManyBelongsTo method
*
* return @void
*/
public function testSaveAllDeepHasManyBelongsTo() {
$this->loadFixtures('Article', 'Comment', 'User');
$TestModel = new Article();
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
$this->db->truncate($TestModel);
$this->db->truncate(new Comment());
$result = $TestModel->saveAll(array(
'Article' => array('id' => 2, 'title' => 'I will not save'),
'Comment' => array(
array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1),
array(
'comment' => 'belongsto', 'published' => 'Y',
'User' => array('user' => 'findme', 'password' => 'somepass')
)
)
), array('deep' => true));
$result = $TestModel->Comment->User->find('first', array(
'conditions' => array('User.user' => 'findme'),
'fields' => array('id', 'user', 'password')
));
$expected = array(
'User' => array(
'id' => 5,
'user' => 'findme',
'password' => 'somepass',
)
);
$this->assertEquals($expected, $result);
$result = $TestModel->Comment->find('first', array(
'conditions' => array('Comment.user_id' => 5),
'fields' => array('id', 'comment', 'published', 'user_id')
));
$expected = array(
'Comment' => array(
'id' => 2,
'comment' => 'belongsto',
'published' => 'Y',
'user_id' => 5
)
);
$this->assertEquals($expected, $result);
}
}

View file

@ -45,13 +45,14 @@ class AppModel extends Model {
*
* @return array
*/
public function _findPublished($state, $query, $results = array()) {
if ($state === 'before') {
$query['conditions']['published'] = 'Y';
return $query;
}
return $results;
protected function _findPublished($state, $query, $results = array()) {
if ($state === 'before') {
$query['conditions']['published'] = 'Y';
return $query;
}
return $results;
}
}
/**
@ -88,6 +89,7 @@ class Test extends CakeTestModel {
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
}
/**
@ -190,6 +192,7 @@ class TestValidate extends CakeTestModel {
public function validateTitle($value) {
return (!empty($value) && strpos(strtolower($value['title']), 'title-') === 0);
}
}
/**
@ -217,7 +220,8 @@ class User extends CakeTestModel {
* beforeFind() callback used to run ContainableBehaviorTest::testLazyLoad()
*
* @return bool
*/
* @throws Exception
*/
public function beforeFind($queryData) {
if (!empty($queryData['lazyLoad'])) {
if (!isset($this->Article, $this->Comment, $this->ArticleFeatured)) {
@ -226,6 +230,7 @@ class User extends CakeTestModel {
}
return true;
}
}
/**
@ -292,12 +297,13 @@ class Article extends CakeTestModel {
* @param mixed $title
* @return void
*/
static function titleDuplicate($title) {
public static function titleDuplicate($title) {
if ($title === 'My Article Title') {
return false;
}
return true;
}
}
/**
@ -307,6 +313,7 @@ class Article extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class BeforeDeleteComment extends CakeTestModel {
public $name = 'BeforeDeleteComment';
public $useTable = 'comments';
@ -316,6 +323,7 @@ class BeforeDeleteComment extends CakeTestModel {
$db->delete($this, array($this->alias . '.' . $this->primaryKey => array(1, 3)));
return true;
}
}
/**
@ -338,6 +346,7 @@ class NumericArticle extends CakeTestModel {
* @var string 'numeric_articles'
*/
public $useTable = 'numeric_articles';
}
/**
@ -367,6 +376,7 @@ class Article10 extends CakeTestModel {
* @var array
*/
public $hasMany = array('Comment' => array('dependent' => true, 'exclusive' => true));
}
/**
@ -417,6 +427,7 @@ class ArticleFeatured extends CakeTestModel {
* @var array
*/
public $validate = array('user_id' => 'numeric', 'title' => 'notEmpty', 'body' => 'notEmpty');
}
/**
@ -554,6 +565,7 @@ class ModifiedComment extends CakeTestModel {
}
return $results;
}
}
/**
@ -595,6 +607,7 @@ class AgainModifiedComment extends CakeTestModel {
}
return $results;
}
}
/**
@ -885,6 +898,7 @@ class Post extends CakeTestModel {
$this->useDbConfig = 'test';
return $results;
}
}
/**
@ -918,6 +932,7 @@ class Author extends CakeTestModel {
$results[0]['Author']['test'] = 'working';
return $results;
}
}
/**
@ -946,6 +961,7 @@ class ModifiedAuthor extends Author {
}
return $results;
}
}
/**
@ -1064,7 +1080,6 @@ class BiddingMessage extends CakeTestModel {
*/
public $primaryKey = 'bidding';
/**
* belongsTo property
*
@ -1164,6 +1179,7 @@ class NodeAfterFind extends CakeTestModel {
public function afterFind($results, $primary = false) {
return $results;
}
}
/**
@ -1943,25 +1959,30 @@ class Callback extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class CallbackPostTestModel extends CakeTestModel {
public $useTable = 'posts';
/**
* variable to control return of beforeValidate
*
* @var string
*/
public $beforeValidateReturn = true;
/**
* variable to control return of beforeSave
*
* @var string
*/
public $beforeSaveReturn = true;
/**
* variable to control return of beforeDelete
*
* @var string
*/
public $beforeDeleteReturn = true;
/**
* beforeSave callback
*
@ -1970,6 +1991,7 @@ class CallbackPostTestModel extends CakeTestModel {
public function beforeSave($options = array()) {
return $this->beforeSaveReturn;
}
/**
* beforeValidate callback
*
@ -1978,6 +2000,7 @@ class CallbackPostTestModel extends CakeTestModel {
public function beforeValidate($options = array()) {
return $this->beforeValidateReturn;
}
/**
* beforeDelete callback
*
@ -1986,6 +2009,7 @@ class CallbackPostTestModel extends CakeTestModel {
public function beforeDelete($cascade = true) {
return $this->beforeDeleteReturn;
}
}
/**
@ -2098,7 +2122,7 @@ class ValidationTest1 extends CakeTestModel {
*
* @return array
*/
public function customValidatorWithParams($data, $validator, $or = true, $ignore_on_same = 'id') {
public function customValidatorWithParams($data, $validator, $or = true, $ignoreOnSame = 'id') {
$this->validatorParams = get_defined_vars();
unset($this->validatorParams['this']);
return true;
@ -2112,6 +2136,7 @@ class ValidationTest1 extends CakeTestModel {
public function customValidatorWithMessage($data) {
return 'This field will *never* validate! Muhahaha!';
}
/**
* Test validation with many parameters
*
@ -2122,6 +2147,7 @@ class ValidationTest1 extends CakeTestModel {
unset($this->validatorParams['this']);
return true;
}
}
/**
@ -2178,6 +2204,7 @@ class ValidationTest2 extends CakeTestModel {
public function schema($field = false) {
return array();
}
}
/**
@ -2200,12 +2227,15 @@ class Person extends CakeTestModel {
* @var array
*/
public $belongsTo = array(
'Mother' => array(
'className' => 'Person',
'foreignKey' => 'mother_id'),
'Father' => array(
'className' => 'Person',
'foreignKey' => 'father_id'));
'Mother' => array(
'className' => 'Person',
'foreignKey' => 'mother_id'
),
'Father' => array(
'className' => 'Person',
'foreignKey' => 'father_id'
)
);
}
/**
@ -2293,7 +2323,14 @@ class Cd extends CakeTestModel {
*
* @var array
*/
public $hasOne = array('OverallFavorite' => array('foreignKey' => 'model_id', 'dependent' => true, 'conditions' => array('model_type' => 'Cd')));
public $hasOne = array(
'OverallFavorite' => array(
'foreignKey' => 'model_id',
'dependent' => true,
'conditions' => array('model_type' => 'Cd')
)
);
}
/**
@ -2315,7 +2352,14 @@ class Book extends CakeTestModel {
*
* @var array
*/
public $hasOne = array('OverallFavorite' => array('foreignKey' => 'model_id', 'dependent' => true, 'conditions' => 'OverallFavorite.model_type = \'Book\''));
public $hasOne = array(
'OverallFavorite' => array(
'foreignKey' => 'model_id',
'dependent' => true,
'conditions' => 'OverallFavorite.model_type = \'Book\''
)
);
}
/**
@ -2462,8 +2506,8 @@ class NumberTree extends CakeTestModel {
* @param bool $hierachial
* @return void
*/
public function initialize($levelLimit = 3, $childLimit = 3, $currentLevel = null, $parent_id = null, $prefix = '1', $hierachial = true) {
if (!$parent_id) {
public function initialize($levelLimit = 3, $childLimit = 3, $currentLevel = null, $parentId = null, $prefix = '1', $hierachial = true) {
if (!$parentId) {
$db = ConnectionManager::getDataSource($this->useDbConfig);
$db->truncate($this->table);
$this->save(array($this->name => array('name' => '1. Root')));
@ -2482,15 +2526,16 @@ class NumberTree extends CakeTestModel {
if ($hierachial) {
if ($this->name == 'UnconventionalTree') {
$data[$this->name]['join'] = $parent_id;
$data[$this->name]['join'] = $parentId;
} else {
$data[$this->name]['parent_id'] = $parent_id;
$data[$this->name]['parent_id'] = $parentId;
}
}
$this->save($data);
$this->initialize($levelLimit, $childLimit, $currentLevel + 1, $this->id, $name, $hierachial);
}
}
}
/**
@ -2543,6 +2588,7 @@ class UnconventionalTree extends NumberTree {
* @var string 'FlagTree'
*/
public $name = 'UnconventionalTree';
public $actsAs = array(
'Tree' => array(
'parent' => 'join',
@ -2550,6 +2596,7 @@ class UnconventionalTree extends NumberTree {
'right' => 'right'
)
);
}
/**
@ -2644,6 +2691,7 @@ class AfterTree extends NumberTree {
$this->data['AfterTree']['name'] = 'Six and One Half Changed in AfterTree::afterSave() but not in database';
}
}
}
/**
@ -2746,7 +2794,9 @@ class ContentAccount extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class FilmFile extends CakeTestModel {
public $name = 'FilmFile';
}
/**
@ -2755,6 +2805,7 @@ class FilmFile extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class Basket extends CakeTestModel {
public $name = 'Basket';
public $belongsTo = array(
@ -2766,6 +2817,7 @@ class Basket extends CakeTestModel {
'order' => ''
)
);
}
/**
@ -2941,25 +2993,30 @@ class TranslateTestModel extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class TranslateWithPrefix extends CakeTestModel {
/**
* name property
*
* @var string 'TranslateTestModel'
*/
public $name = 'TranslateWithPrefix';
/**
* tablePrefix property
*
* @var string 'i18n'
*/
public $tablePrefix = 'i18n_';
/**
* displayField property
*
* @var string 'field'
*/
public $displayField = 'field';
}
/**
* TranslatedItem class.
*
@ -2994,6 +3051,7 @@ class TranslatedItem extends CakeTestModel {
* @var string 'TranslateTestModel'
*/
public $translateModel = 'TranslateTestModel';
}
/**
@ -3002,31 +3060,37 @@ class TranslatedItem extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class TranslatedItem2 extends CakeTestModel {
/**
* name property
*
* @var string 'TranslatedItem'
*/
public $name = 'TranslatedItem';
/**
* cacheQueries property
*
* @var bool false
*/
public $cacheQueries = false;
/**
* actsAs property
*
* @var array
*/
public $actsAs = array('Translate' => array('content', 'title'));
/**
* translateModel property
*
* @var string 'TranslateTestModel'
*/
public $translateModel = 'TranslateWithPrefix';
}
/**
* TranslatedItemWithTable class.
*
@ -3075,6 +3139,7 @@ class TranslatedItemWithTable extends CakeTestModel {
* @var string 'another_i18n'
*/
public $translateTable = 'another_i18n';
}
/**
@ -3104,6 +3169,7 @@ class TranslateArticleModel extends CakeTestModel {
* @var string 'field'
*/
public $displayField = 'field';
}
/**
@ -3147,55 +3213,79 @@ class TranslatedArticle extends CakeTestModel {
* @var array
*/
public $belongsTo = array('User');
}
class CounterCacheUser extends CakeTestModel {
public $name = 'CounterCacheUser';
public $alias = 'User';
public $hasMany = array('Post' => array(
'className' => 'CounterCachePost',
'foreignKey' => 'user_id'
));
public $hasMany = array(
'Post' => array(
'className' => 'CounterCachePost',
'foreignKey' => 'user_id'
)
);
}
class CounterCachePost extends CakeTestModel {
public $name = 'CounterCachePost';
public $alias = 'Post';
public $belongsTo = array('User' => array(
'className' => 'CounterCacheUser',
'foreignKey' => 'user_id',
'counterCache' => true
));
public $belongsTo = array(
'User' => array(
'className' => 'CounterCacheUser',
'foreignKey' => 'user_id',
'counterCache' => true
)
);
}
class CounterCacheUserNonstandardPrimaryKey extends CakeTestModel {
public $name = 'CounterCacheUserNonstandardPrimaryKey';
public $alias = 'User';
public $primaryKey = 'uid';
public $hasMany = array('Post' => array(
'className' => 'CounterCachePostNonstandardPrimaryKey',
'foreignKey' => 'uid'
));
public $hasMany = array(
'Post' => array(
'className' => 'CounterCachePostNonstandardPrimaryKey',
'foreignKey' => 'uid'
)
);
}
class CounterCachePostNonstandardPrimaryKey extends CakeTestModel {
public $name = 'CounterCachePostNonstandardPrimaryKey';
public $alias = 'Post';
public $primaryKey = 'pid';
public $belongsTo = array('User' => array(
'className' => 'CounterCacheUserNonstandardPrimaryKey',
'foreignKey' => 'uid',
'counterCache' => true
));
public $belongsTo = array(
'User' => array(
'className' => 'CounterCacheUserNonstandardPrimaryKey',
'foreignKey' => 'uid',
'counterCache' => true
)
);
}
class ArticleB extends CakeTestModel {
public $name = 'ArticleB';
public $useTable = 'articles';
public $hasAndBelongsToMany = array(
'TagB' => array(
'className' => 'TagB',
@ -3204,11 +3294,15 @@ class ArticleB extends CakeTestModel {
'associationForeignKey' => 'tag_id'
)
);
}
class TagB extends CakeTestModel {
public $name = 'TagB';
public $useTable = 'tags';
public $hasAndBelongsToMany = array(
'ArticleB' => array(
'className' => 'ArticleB',
@ -3217,10 +3311,13 @@ class TagB extends CakeTestModel {
'associationForeignKey' => 'article_id'
)
);
}
class Fruit extends CakeTestModel {
public $name = 'Fruit';
public $hasAndBelongsToMany = array(
'UuidTag' => array(
'className' => 'UuidTag',
@ -3230,11 +3327,15 @@ class Fruit extends CakeTestModel {
'with' => 'FruitsUuidTag'
)
);
}
class FruitsUuidTag extends CakeTestModel {
public $name = 'FruitsUuidTag';
public $primaryKey = false;
public $belongsTo = array(
'UuidTag' => array(
'className' => 'UuidTag',
@ -3245,10 +3346,13 @@ class FruitsUuidTag extends CakeTestModel {
'foreignKey' => 'fruit_id',
)
);
}
class UuidTag extends CakeTestModel {
public $name = 'UuidTag';
public $hasAndBelongsToMany = array(
'Fruit' => array(
'className' => 'Fruit',
@ -3258,11 +3362,15 @@ class UuidTag extends CakeTestModel {
'with' => 'FruitsUuidTag'
)
);
}
class FruitNoWith extends CakeTestModel {
public $name = 'Fruit';
public $useTable = 'fruits';
public $hasAndBelongsToMany = array(
'UuidTag' => array(
'className' => 'UuidTagNoWith',
@ -3271,11 +3379,15 @@ class FruitNoWith extends CakeTestModel {
'associationForeignKey' => 'uuid_tag_id',
)
);
}
class UuidTagNoWith extends CakeTestModel {
public $name = 'UuidTag';
public $useTable = 'uuid_tags';
public $hasAndBelongsToMany = array(
'Fruit' => array(
'className' => 'FruitNoWith',
@ -3284,21 +3396,29 @@ class UuidTagNoWith extends CakeTestModel {
'associationForeignKey' => 'fruit_id',
)
);
}
class ProductUpdateAll extends CakeTestModel {
public $name = 'ProductUpdateAll';
public $useTable = 'product_update_all';
}
class GroupUpdateAll extends CakeTestModel {
public $name = 'GroupUpdateAll';
public $useTable = 'group_update_all';
}
class TransactionTestModel extends CakeTestModel {
public $name = 'TransactionTestModel';
public $useTable = 'samples';
public function afterSave($created) {
@ -3307,10 +3427,13 @@ class TransactionTestModel extends CakeTestModel {
);
$this->saveAll($data, array('atomic' => true, 'callbacks' => false));
}
}
class TransactionManyTestModel extends CakeTestModel {
public $name = 'TransactionManyTestModel';
public $useTable = 'samples';
public function afterSave($created) {
@ -3319,24 +3442,29 @@ class TransactionManyTestModel extends CakeTestModel {
);
$this->saveMany($data, array('atomic' => true, 'callbacks' => false));
}
}
class Site extends CakeTestModel {
public $name = 'Site';
public $useTable = 'sites';
public $hasAndBelongsToMany = array(
'Domain' => array('unique' => 'keepExisting'),
);
);
}
class Domain extends CakeTestModel {
public $name = 'Domain';
public $useTable = 'domains';
public $hasAndBelongsToMany = array(
'Site' => array('unique' => 'keepExisting'),
);
);
}
/**
@ -3411,6 +3539,7 @@ class TestModel extends CakeTestModel {
public function findAll($conditions = null, $fields = null, $order = null, $recursive = null) {
return $conditions;
}
}
/**
@ -3538,6 +3667,7 @@ class TestModel4 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -3582,6 +3712,7 @@ class TestModel4TestModel7 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -3649,6 +3780,7 @@ class TestModel5 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -3684,10 +3816,12 @@ class TestModel6 extends CakeTestModel {
*
* @var array
*/
public $belongsTo = array('TestModel5' => array(
'className' => 'TestModel5',
'foreignKey' => 'test_model5_id'
));
public $belongsTo = array(
'TestModel5' => array(
'className' => 'TestModel5',
'foreignKey' => 'test_model5_id'
)
);
/**
* schema method
@ -3706,6 +3840,7 @@ class TestModel6 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -3752,6 +3887,7 @@ class TestModel7 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -3812,6 +3948,7 @@ class TestModel8 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -3847,11 +3984,13 @@ class TestModel9 extends CakeTestModel {
*
* @var array
*/
public $belongsTo = array('TestModel8' => array(
'className' => 'TestModel8',
'foreignKey' => 'test_model8_id',
'conditions' => 'TestModel8.name != \'larry\''
));
public $belongsTo = array(
'TestModel8' => array(
'className' => 'TestModel8',
'foreignKey' => 'test_model8_id',
'conditions' => 'TestModel8.name != \'larry\''
)
);
/**
* schema method
@ -3870,6 +4009,7 @@ class TestModel9 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -3928,6 +4068,7 @@ class Level extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -4059,6 +4200,7 @@ class User2 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -4141,6 +4283,7 @@ class Category2 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -4212,6 +4355,7 @@ class Article2 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -4259,6 +4403,7 @@ class CategoryFeatured2 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -4316,6 +4461,7 @@ class Featured2 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -4369,6 +4515,7 @@ class Comment2 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -4448,6 +4595,7 @@ class ArticleFeatured2 extends CakeTestModel {
}
return $this->_schema;
}
}
/**
@ -4504,26 +4652,27 @@ class MysqlTestModel extends Model {
*/
public function schema($field = false) {
return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
}
}
/**
@ -4532,9 +4681,13 @@ class MysqlTestModel extends Model {
*/
class PrefixTestModel extends CakeTestModel {
}
class PrefixTestUseTableModel extends CakeTestModel {
public $name = 'PrefixTest';
public $useTable = 'prefix_tests';
}
/**
@ -4574,6 +4727,7 @@ class ScaffoldMock extends CakeTestModel {
'foreignKey' => 'article_id',
)
);
/**
* hasAndBelongsToMany property
*
@ -4587,6 +4741,7 @@ class ScaffoldMock extends CakeTestModel {
'joinTable' => 'join_things'
)
);
}
/**
@ -4649,12 +4804,14 @@ class ScaffoldComment extends CakeTestModel {
* @package Cake.Test.Case.Controller
*/
class ScaffoldTag extends CakeTestModel {
/**
* useTable property
*
* @var string 'posts'
*/
public $useTable = 'tags';
}
/**
@ -4663,12 +4820,14 @@ class ScaffoldTag extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class Player extends CakeTestModel {
public $hasAndBelongsToMany = array(
'Guild' => array(
'with' => 'GuildsPlayer',
'unique' => true,
),
);
),
);
}
/**
@ -4677,12 +4836,14 @@ class Player extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class Guild extends CakeTestModel {
public $hasAndBelongsToMany = array(
'Player' => array(
'with' => 'GuildsPlayer',
'unique' => true,
),
);
),
);
}
/**
@ -4731,6 +4892,7 @@ class ArmorsPlayer extends CakeTestModel {
* @package Cake.Test.Case.Model
*/
class CustomArticle extends AppModel {
/**
* useTable property
*
@ -4750,12 +4912,12 @@ class CustomArticle extends AppModel {
*
* @return array
*/
public function _findUnPublished($state, $query, $results = array()) {
if ($state === 'before') {
$query['conditions']['published'] = 'N';
return $query;
}
return $results;
protected function _findUnPublished($state, $query, $results = array()) {
if ($state === 'before') {
$query['conditions']['published'] = 'N';
return $query;
}
return $results;
}
}
}

View file

@ -22,6 +22,7 @@ App::uses('Xml', 'Utility');
App::uses('CakeRequest', 'Network');
class CakeRequestTest extends CakeTestCase {
/**
* setup callback
*
@ -106,7 +107,6 @@ class CakeRequestTest extends CakeTestCase {
$expected = array('one' => 'something', 'two' => 'else');
$this->assertEquals($expected, $request->query);
$this->assertEquals('some/path?one=something&two=else', $request->url);
}
/**
@ -161,7 +161,6 @@ class CakeRequestTest extends CakeTestCase {
$this->assertFalse(isset($request->random));
}
/**
* test parsing POST data into the object.
*
@ -437,7 +436,6 @@ class CakeRequestTest extends CakeTestCase {
);
$this->assertEquals($request->data, $expected);
$_FILES = array(
'data' => array(
'name' => array('birth_cert' => 'born on.txt'),
@ -471,7 +469,6 @@ class CakeRequestTest extends CakeTestCase {
);
$request = new CakeRequest('some/path');
$this->assertEquals($request->params['form'], $_FILES);
}
/**
@ -682,7 +679,7 @@ class CakeRequestTest extends CakeTestCase {
* @expectedException CakeException
* @return void
*/
public function test__callExceptionOnUnknownMethod() {
public function testMagicCallExceptionOnUnknownMethod() {
$request = new CakeRequest('some/path');
$request->IamABanana();
}
@ -725,7 +722,7 @@ class CakeRequestTest extends CakeTestCase {
*
* @return void
*/
public function test__get() {
public function testMagicget() {
$request = new CakeRequest('some/path');
$request->params = array('controller' => 'posts', 'action' => 'view', 'plugin' => 'blogs');
@ -740,7 +737,7 @@ class CakeRequestTest extends CakeTestCase {
*
* @return void
*/
public function test__isset() {
public function testMagicisset() {
$request = new CakeRequest('some/path');
$request->params = array(
'controller' => 'posts',
@ -800,7 +797,7 @@ class CakeRequestTest extends CakeTestCase {
$_SERVER['TEST_VAR'] = 'wrong';
$this->assertFalse($request->is('compare'), 'Value mis-match failed.');
$request->addDetector('compareCamelCase', array('env' => 'TEST_VAR', 'value' => 'foo'));
$_SERVER['TEST_VAR'] = 'foo';
@ -945,7 +942,6 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals($request->webroot, '/1.2.x.x/');
$this->assertEquals($request->url, 'posts/view/1');
$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot';
$_SERVER['PHP_SELF'] = '/index.php';
$_SERVER['PATH_INFO'] = '/posts/add';
@ -962,7 +958,6 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals('', $request->base);
$this->assertEquals('/', $request->webroot);
$_SERVER['DOCUMENT_ROOT'] = '/some/apps/where';
$_SERVER['PHP_SELF'] = '/app/webroot/index.php';
$request = new CakeRequest();
@ -1704,7 +1699,6 @@ XML;
);
}
/**
* Test is('requested') and isRequested()
*

View file

@ -40,9 +40,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the request object constructor
*
*/
* Tests the request object constructor
*
*/
public function testConstruct() {
$response = new CakeResponse();
$this->assertNull($response->body());
@ -64,9 +64,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the body method
*
*/
* Tests the body method
*
*/
public function testBody() {
$response = new CakeResponse();
$this->assertNull($response->body());
@ -76,9 +76,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the charset method
*
*/
* Tests the charset method
*
*/
public function testCharset() {
$response = new CakeResponse();
$this->assertEquals($response->charset(), 'UTF-8');
@ -88,10 +88,10 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the statusCode method
*
* @expectedException CakeException
*/
* Tests the statusCode method
*
* @expectedException CakeException
*/
public function testStatusCode() {
$response = new CakeResponse();
$this->assertEquals($response->statusCode(), 200);
@ -104,9 +104,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the type method
*
*/
* Tests the type method
*
*/
public function testType() {
$response = new CakeResponse();
$this->assertEquals($response->type(), 'text/html');
@ -125,9 +125,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the header method
*
*/
* Tests the header method
*
*/
public function testHeader() {
$response = new CakeResponse();
$headers = array();
@ -169,9 +169,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the send method
*
*/
* Tests the send method
*
*/
public function testSend() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies'));
$response->header(array(
@ -195,9 +195,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the send method and changing the content type
*
*/
* Tests the send method and changing the content type
*
*/
public function testSendChangingContentYype() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies'));
$response->type('mp3');
@ -214,9 +214,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the send method and changing the content type
*
*/
* Tests the send method and changing the content type
*
*/
public function testSendChangingContentType() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies'));
$response->type('mp3');
@ -233,9 +233,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the send method and changing the content type
*
*/
* Tests the send method and changing the content type
*
*/
public function testSendWithLocation() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies'));
$response->header('Location', 'http://www.example.com');
@ -245,14 +245,14 @@ class CakeResponseTest extends CakeTestCase {
$response->expects($this->at(2))
->method('_sendHeader')->with('Location', 'http://www.example.com');
$response->expects($this->at(3))
->method('_sendHeader')->with('Content-Type', 'text/html; charset=UTF-8');
->method('_sendHeader')->with('Content-Type', 'text/html; charset=UTF-8');
$response->send();
}
/**
* Tests the disableCache method
*
*/
* Tests the disableCache method
*
*/
public function testDisableCache() {
$response = new CakeResponse();
$expected = array(
@ -265,9 +265,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the cache method
*
*/
* Tests the cache method
*
*/
public function testCache() {
$response = new CakeResponse();
$since = time();
@ -336,15 +336,15 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the httpCodes method
*
*/
* Tests the httpCodes method
*
*/
public function testHttpCodes() {
$response = new CakeResponse();
$result = $response->httpCodes();
$this->assertEquals(count($result), 39);
$result = $response->httpCodes(100);
$result = $response->httpCodes(100);
$expected = array(100 => 'Continue');
$this->assertEquals($expected, $result);
@ -353,7 +353,7 @@ class CakeResponseTest extends CakeTestCase {
1729 => 'Hardy-Ramanujan Located'
);
$result = $response->httpCodes($codes);
$result = $response->httpCodes($codes);
$this->assertTrue($result);
$this->assertEquals(count($response->httpCodes()), 41);
@ -372,9 +372,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the download method
*
*/
* Tests the download method
*
*/
public function testDownload() {
$response = new CakeResponse();
$expected = array(
@ -385,9 +385,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the mapType method
*
*/
* Tests the mapType method
*
*/
public function testMapType() {
$response = new CakeResponse();
$this->assertEquals('wav', $response->mapType('audio/x-wav'));
@ -401,9 +401,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the outputCompressed method
*
*/
* Tests the outputCompressed method
*
*/
public function testOutputCompressed() {
$response = new CakeResponse();
@ -438,9 +438,9 @@ class CakeResponseTest extends CakeTestCase {
}
/**
* Tests the send and setting of Content-Length
*
*/
* Tests the send and setting of Content-Length
*
*/
public function testSendContentLength() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent'));
$response->body('the response body');
@ -479,7 +479,7 @@ class CakeResponseTest extends CakeTestCase {
$response->header('Content-Length', 1);
$response->expects($this->never())->method('outputCompressed');
$response->expects($this->once())->method('_sendContent')->with($body);
$response->expects($this->at(1))
$response->expects($this->at(1))
->method('_sendHeader')->with('Content-Length', 1);
$response->send();
@ -652,7 +652,6 @@ class CakeResponseTest extends CakeTestCase {
->method('_sendHeader')->with('Cache-Control', 'public');
$response->send();
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent'));
$response->sharable(false);
$headers = $response->header();
@ -765,7 +764,6 @@ class CakeResponseTest extends CakeTestCase {
$response->expects($this->at(1))
->method('_sendHeader')->with('Cache-Control', 's-maxage=3600, must-revalidate');
$response->send();
}
/**
@ -835,7 +833,7 @@ class CakeResponseTest extends CakeTestCase {
**/
public function testCheckNotModifiedByEtagStar() {
$_SERVER['HTTP_IF_NONE_MATCH'] = '*';
$response = $this->getMock('CakeResponse', array('notModified'));
$response = $this->getMock('CakeResponse', array('notModified'));
$response->etag('something');
$response->expects($this->once())->method('notModified');
$response->checkNotModified(new CakeRequest);
@ -848,7 +846,7 @@ class CakeResponseTest extends CakeTestCase {
**/
public function testCheckNotModifiedByEtagExact() {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
$response = $this->getMock('CakeResponse', array('notModified'));
$response = $this->getMock('CakeResponse', array('notModified'));
$response->etag('something', true);
$response->expects($this->once())->method('notModified');
$this->assertTrue($response->checkNotModified(new CakeRequest));
@ -862,7 +860,7 @@ class CakeResponseTest extends CakeTestCase {
public function testCheckNotModifiedByEtagAndTime() {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
$response = $this->getMock('CakeResponse', array('notModified'));
$response = $this->getMock('CakeResponse', array('notModified'));
$response->etag('something', true);
$response->modified('2012-01-01 00:00:00');
$response->expects($this->once())->method('notModified');
@ -877,7 +875,7 @@ class CakeResponseTest extends CakeTestCase {
public function testCheckNotModifiedByEtagAndTimeMismatch() {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
$response = $this->getMock('CakeResponse', array('notModified'));
$response = $this->getMock('CakeResponse', array('notModified'));
$response->etag('something', true);
$response->modified('2012-01-01 00:00:01');
$response->expects($this->never())->method('notModified');
@ -892,14 +890,13 @@ class CakeResponseTest extends CakeTestCase {
public function testCheckNotModifiedByEtagMismatch() {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something-else", "other"';
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
$response = $this->getMock('CakeResponse', array('notModified'));
$response = $this->getMock('CakeResponse', array('notModified'));
$response->etag('something', true);
$response->modified('2012-01-01 00:00:00');
$response->expects($this->never())->method('notModified');
$this->assertFalse($response->checkNotModified(new CakeRequest));
}
/**
* Test checkNotModified method
*
@ -907,7 +904,7 @@ class CakeResponseTest extends CakeTestCase {
**/
public function testCheckNotModifiedByTime() {
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
$response = $this->getMock('CakeResponse', array('notModified'));
$response = $this->getMock('CakeResponse', array('notModified'));
$response->modified('2012-01-01 00:00:00');
$response->expects($this->once())->method('notModified');
$this->assertTrue($response->checkNotModified(new CakeRequest));
@ -921,7 +918,7 @@ class CakeResponseTest extends CakeTestCase {
public function testCheckNotModifiedNoHints() {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
$response = $this->getMock('CakeResponse', array('notModified'));
$response = $this->getMock('CakeResponse', array('notModified'));
$response->expects($this->never())->method('notModified');
$this->assertFalse($response->checkNotModified(new CakeRequest));
}

View file

@ -62,6 +62,7 @@ class TestCakeEmail extends CakeEmail {
public function encode($text) {
return $this->_encode($text);
}
}
/*
@ -110,7 +111,7 @@ class CakeEmailTest extends CakeTestCase {
$this->CakeEmail = new TestCakeEmail();
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
}
@ -308,12 +309,12 @@ class CakeEmailTest extends CakeTestCase {
$this->assertSame($expected, $result);
$result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => '寿限無寿限無五劫の擦り切れ海砂利水魚の水行末雲来末風来末食う寝る処に住む処やぶら小路の藪柑子パイポパイポパイポのシューリンガンシューリンガンのグーリンダイグーリンダイのポンポコピーのポンポコナーの長久命の長助'));
$expected = array("=?ISO-2022-JP?B?GyRCPHc4Qkw1PHc4Qkw1OF45ZSROOyQkakBaJGwzJDo9TXg/ZTV7GyhC?=\r\n"
." =?ISO-2022-JP?B?GyRCJE4/ZTlUS3YxQE1oS3ZJd01oS3Y/KSQmPzIkaz1oJEs9OyRgGyhC?=\r\n"
." =?ISO-2022-JP?B?GyRCPWgkZCRWJGk+Lk8pJE5pLjQ7O1IlUSUkJV0lUSUkJV0lUSUkGyhC?=\r\n"
." =?ISO-2022-JP?B?GyRCJV0kTiU3JWUhPCVqJXMlLCVzJTclZSE8JWolcyUsJXMkTiUwGyhC?=\r\n"
." =?ISO-2022-JP?B?GyRCITwlaiVzJUAlJCUwITwlaiVzJUAlJCROJV0lcyVdJTMlVCE8GyhC?=\r\n"
." =?ISO-2022-JP?B?GyRCJE4lXSVzJV0lMyVKITwkTkQ5NVdMPyRORDk9dRsoQg==?= <cake@cakephp.org>");
$expected = array("=?ISO-2022-JP?B?GyRCPHc4Qkw1PHc4Qkw1OF45ZSROOyQkakBaJGwzJDo9TXg/ZTV7GyhC?=\r\n" .
" =?ISO-2022-JP?B?GyRCJE4/ZTlUS3YxQE1oS3ZJd01oS3Y/KSQmPzIkaz1oJEs9OyRgGyhC?=\r\n" .
" =?ISO-2022-JP?B?GyRCPWgkZCRWJGk+Lk8pJE5pLjQ7O1IlUSUkJV0lUSUkJV0lUSUkGyhC?=\r\n" .
" =?ISO-2022-JP?B?GyRCJV0kTiU3JWUhPCVqJXMlLCVzJTclZSE8JWolcyUsJXMkTiUwGyhC?=\r\n" .
" =?ISO-2022-JP?B?GyRCITwlaiVzJUAlJCUwITwlaiVzJUAlJCROJV0lcyVdJTMlVCE8GyhC?=\r\n" .
" =?ISO-2022-JP?B?GyRCJE4lXSVzJV0lMyVKITwkTkQ5NVdMPyRORDk9dRsoQg==?= <cake@cakephp.org>");
$this->assertSame($expected, $result);
}
@ -420,13 +421,12 @@ class CakeEmailTest extends CakeTestCase {
$this->assertSame($this->CakeEmail->subject(), $expected);
$this->CakeEmail->subject('長い長い長いSubjectの場合はfoldingするのが正しいんだけどいったいどうなるんだろう');
$expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n"
." =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n"
." =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?=";
$expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n" .
" =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n" .
" =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?=";
$this->assertSame($this->CakeEmail->subject(), $expected);
}
/**
* testHeaders method
*
@ -659,7 +659,6 @@ class CakeEmailTest extends CakeTestCase {
$this->CakeEmail->config(array());
$this->assertSame($transportClass->config(), array());
}
/**
@ -883,7 +882,7 @@ class CakeEmailTest extends CakeTestCase {
$this->assertContains($expected, $result['message']);
$this->assertContains('--rel-' . $boundary . '--', $result['message']);
$this->assertContains('--' . $boundary . '--', $result['message']);
}
}
/**
* testSendWithLog method
@ -1209,7 +1208,6 @@ class CakeEmailTest extends CakeTestCase {
$this->assertTrue($this->checkContentTransferEncoding($message, '7bit'));
}
/**
* testReset method
*
@ -1493,9 +1491,9 @@ class CakeEmailTest extends CakeTestCase {
$this->CakeEmail->headerCharset = 'ISO-2022-JP';
$result = $this->CakeEmail->encode('長い長い長いSubjectの場合はfoldingするのが正しいんだけどいったいどうなるんだろう');
$expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n"
. " =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n"
. " =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?=";
$expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n" .
" =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n" .
" =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?=";
$this->assertSame($expected, $result);
}

View file

@ -52,7 +52,6 @@ class SmtpTestTransport extends SmtpTransport {
* @return void
*/
protected function _generateSocket() {
return;
}
/**

View file

@ -160,8 +160,8 @@ class DigestAuthenticationTest extends CakeTestCase {
$this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000003') > 0);
$this->assertEquals($auth['nc'], 4);
$responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response=');
$response2 = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32);
$this->assertNotEquals($response, $response2);
$responseB = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32);
$this->assertNotEquals($response, $responseB);
}
/**

View file

@ -85,6 +85,7 @@ class TestHttpResponse extends HttpResponse {
* @package Cake.Test.Case.Network.Http
*/
class HttpResponseTest extends CakeTestCase {
/**
* This function sets up a HttpResponse
*
@ -491,7 +492,7 @@ class HttpResponseTest extends CakeTestCase {
$unescapedToken = $this->HttpResponse->unescapeToken($token);
$expectedToken = 'My-special-' . $char . '-Token';
$this->assertEquals($unescapedToken, $expectedToken, 'Test token unescaping for ASCII '.ord($char));
$this->assertEquals($unescapedToken, $expectedToken, 'Test token unescaping for ASCII ' . ord($char));
}
$token = 'Extreme-":"Token-" "-""""@"-test';
@ -519,14 +520,13 @@ class HttpResponseTest extends CakeTestCase {
);
$this->HttpResponse->body = 'This is a test!';
$this->HttpResponse->raw = "HTTP/1.1 200 OK\r\nServer: CakePHP\r\nContEnt-Type: text/plain\r\n\r\nThis is a test!";
$expected1 = "HTTP/1.1 200 OK\r\n";
$this->assertEquals($this->HttpResponse['raw']['status-line'], $expected1);
$expected2 = "Server: CakePHP\r\nContEnt-Type: text/plain\r\n";
$this->assertEquals($this->HttpResponse['raw']['header'], $expected2);
$expected3 = 'This is a test!';
$this->assertEquals($this->HttpResponse['raw']['body'], $expected3);
$expected = $expected1 . $expected2 . "\r\n" . $expected3;
$expectedOne = "HTTP/1.1 200 OK\r\n";
$this->assertEquals($this->HttpResponse['raw']['status-line'], $expectedOne);
$expectedTwo = "Server: CakePHP\r\nContEnt-Type: text/plain\r\n";
$this->assertEquals($this->HttpResponse['raw']['header'], $expectedTwo);
$expectedThree = 'This is a test!';
$this->assertEquals($this->HttpResponse['raw']['body'], $expectedThree);
$expected = $expectedOne . $expectedTwo . "\r\n" . $expectedThree;
$this->assertEquals($this->HttpResponse['raw']['response'], $expected);
$expected = 'HTTP/1.1';
@ -555,4 +555,4 @@ class HttpResponseTest extends CakeTestCase {
$this->assertSame($this->HttpResponse['raw']['header'], null);
}
}
}

View file

@ -160,7 +160,7 @@ class TestHttpSocket extends HttpSocket {
* @param string $token Token to escape
* @return string Escaped token
*/
public function EscapeToken($token, $chars = null) {
public function escapeToken($token, $chars = null) {
return parent::_escapeToken($token, $chars);
}
@ -761,7 +761,6 @@ class HttpSocketTest extends CakeTestCase {
$this->assertInstanceOf('CustomResponse', $response);
$this->assertEquals($response->first10, 'HTTP/1.x 2');
}
/**
* testRequestWithRedirect method
@ -777,11 +776,11 @@ class HttpSocketTest extends CakeTestCase {
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
$response = $this->Socket->request($request);
$this->assertEquals('<h1>You have been redirected</h1>', $response->body());
}
public function testRequestWithRedirectAsInt() {
$request = array(
'uri' => 'http://localhost/oneuri',
@ -791,11 +790,11 @@ class HttpSocketTest extends CakeTestCase {
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
$response = $this->Socket->request($request);
$this->assertEquals(1, $this->Socket->request['redirect']);
}
public function testRequestWithRedirectAsIntReachingZero() {
$request = array(
'uri' => 'http://localhost/oneuri',
@ -805,13 +804,12 @@ class HttpSocketTest extends CakeTestCase {
$serverResponse2 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
$response = $this->Socket->request($request);
$this->assertEquals(0, $this->Socket->request['redirect']);
$this->assertEquals(302, $response->code);
$this->assertEquals('http://localhost/anotheruri', $response->getHeader('Location'));
}
/**
* testProxy method
@ -1496,7 +1494,6 @@ class HttpSocketTest extends CakeTestCase {
$r = $this->Socket->buildHeader(array('Test@Field' => "My value"));
$this->assertEquals($r, "Test\"@\"Field: My value\r\n");
}
/**
@ -1561,7 +1558,7 @@ class HttpSocketTest extends CakeTestCase {
$escapedToken = $this->Socket->escapeToken($token);
$expectedToken = 'My-special-"' . $char . '"-Token';
$this->assertEquals($escapedToken, $expectedToken, 'Test token escaping for ASCII '.ord($char));
$this->assertEquals($escapedToken, $expectedToken, 'Test token escaping for ASCII ' . ord($char));
}
$token = 'Extreme-:Token- -"@-test';

View file

@ -256,7 +256,7 @@ class CakeTestCaseTest extends CakeTestCase {
$two = "\nOne\nTwo";
$this->assertTextEquals($one, $two);
}
/**
* test assertTextStartsWith()
*
@ -265,7 +265,7 @@ class CakeTestCaseTest extends CakeTestCase {
public function testAssertTextStartsWith() {
$stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!";
$stringClean = "some\nstring\nwith\ndifferent\nline endings!";
$this->assertStringStartsWith("some\nstring", $stringDirty);
$this->assertStringStartsNotWith("some\r\nstring\r\nwith", $stringDirty);
$this->assertStringStartsNotWith("some\nstring\nwith", $stringDirty);
@ -282,19 +282,19 @@ class CakeTestCaseTest extends CakeTestCase {
public function testAssertTextStartsNotWith() {
$stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!";
$stringClean = "some\nstring\nwith\ndifferent\nline endings!";
$this->assertTextStartsNotWith("some\nstring\nwithout", $stringDirty);
}
/**
* test assertTextEndsWith()
*
* @return void
*/
*/
public function testAssertTextEndsWith() {
$stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!";
$stringClean = "some\nstring\nwith\ndifferent\nline endings!";
$this->assertTextEndsWith("string\nwith\r\ndifferent\rline endings!", $stringDirty);
$this->assertTextEndsWith("string\r\nwith\ndifferent\nline endings!", $stringDirty);
}
@ -303,39 +303,40 @@ class CakeTestCaseTest extends CakeTestCase {
* test assertTextEndsNotWith()
*
* @return void
*/
*/
public function testAssertTextEndsNotWith() {
$stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!";
$stringClean = "some\nstring\nwith\ndifferent\nline endings!";
$this->assertStringEndsNotWith("different\nline endings", $stringDirty);
$this->assertTextEndsNotWith("different\rline endings", $stringDirty);
}
/**
* test assertTextContains()
*
* @return void
*/
*/
public function testAssertTextContains() {
$stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!";
$stringClean = "some\nstring\nwith\ndifferent\nline endings!";
$this->assertContains("different", $stringDirty);
$this->assertNotContains("different\rline", $stringDirty);
$this->assertTextContains("different\rline", $stringDirty);
$this->assertTextContains("different\rline", $stringDirty);
}
/**
* test assertTextNotContains()
*
* @return void
*/
*/
public function testAssertTextNotContains() {
$stringDirty = "some\nstring\r\nwith\rdifferent\nline endings!";
$stringClean = "some\nstring\nwith\ndifferent\nline endings!";
$this->assertTextNotContains("different\rlines", $stringDirty);
$this->assertTextNotContains("different\rlines", $stringDirty);
}
}

View file

@ -155,15 +155,23 @@ class CakeTestFixtureDefaultImportFixture extends CakeTestFixture {
* @package Cake.Test.Case.TestSuite
*/
class FixtureImportTestModel extends Model {
public $name = 'FixtureImport';
public $useTable = 'fixture_tests';
public $useDbConfig = 'test';
}
class FixturePrefixTest extends Model {
public $name = 'FixturePrefix';
public $useTable = '_tests';
public $tablePrefix = 'fixture';
public $useDbConfig = 'test';
}
@ -218,9 +226,9 @@ class CakeTestFixtureTest extends CakeTestCase {
$this->assertEquals($Fixture->primaryKey, 'my_random_key');
}
/**
* test that init() correctly sets the fixture table when the connection or model have prefixes defined.
* test that init() correctly sets the fixture table when the connection
* or model have prefixes defined.
*
* @return void
*/
@ -359,7 +367,6 @@ class CakeTestFixtureTest extends CakeTestCase {
$Source->create($newTestSuiteDb);
$Source->insert($newTestSuiteDb);
$Fixture = new CakeTestFixtureDefaultImportFixture();
$Fixture->fields = $Fixture->records = null;
$Fixture->import = array(

View file

@ -20,24 +20,6 @@
*/
class CakeTestSuiteTest extends CakeTestCase {
/**
* setUp
*
* @return void
*/
public function setUp() {
parent::setUp();
}
/**
* tearDown
*
* @return void
*/
public function tearDown() {
parent::tearDown();
}
/**
* testAddTestDirectory
*

View file

@ -26,7 +26,6 @@ App::uses('CakeHtmlReporter', 'TestSuite/Reporter');
require_once dirname(dirname(__FILE__)) . DS . 'Model' . DS . 'models.php';
/**
* AppController class
*
@ -36,9 +35,10 @@ if (!class_exists('AppController', false)) {
/**
* AppController class
*
* @package Cake.Test.Case.TestSuite
* @package Cake.Test.Case.TestSuite
*/
class AppController extends Controller {
/**
* helpers property
*
@ -46,6 +46,7 @@ if (!class_exists('AppController', false)) {
* @access public
*/
public $helpers = array('Html');
/**
* uses property
*
@ -53,6 +54,7 @@ if (!class_exists('AppController', false)) {
* @access public
*/
public $uses = array('ControllerPost');
/**
* components property
*
@ -60,6 +62,7 @@ if (!class_exists('AppController', false)) {
* @access public
*/
public $components = array('Cookie');
}
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
define('APP_CONTROLLER_EXISTS', true);
@ -238,7 +241,6 @@ class ControllerTestCaseTest extends CakeTestCase {
->will($this->returnValue(false));
$this->assertTrue($Tests->TestPluginComment->save(array()));
$this->assertFalse($Tests->TestPluginComment->save(array()));
}
/**
@ -496,7 +498,7 @@ class ControllerTestCaseTest extends CakeTestCase {
$this->assertContains('This is the TestsAppsController index view', $result);
$this->assertContains('first call', $result);
$this->assertContains('</html>', $result);
$result = $this->Case->testAction('/tests_apps/index', array(
'data' => array('var' => 'second call'),
'method' => 'get',

View file

@ -21,6 +21,7 @@ App::uses('HtmlCoverageReport', 'TestSuite/Coverage');
App::uses('CakeBaseReporter', 'TestSuite/Reporter');
class HtmlCoverageReportTest extends CakeTestCase {
/**
* setUp
*
@ -127,7 +128,6 @@ class HtmlCoverageReportTest extends CakeTestCase {
}
}
/**
* Test that coverage works with phpunit 3.6 as the data formats from coverage are totally different.
*
@ -198,7 +198,6 @@ class HtmlCoverageReportTest extends CakeTestCase {
5 => -1
);
$result = $this->Coverage->generateDiff('myfile.php', $file, $coverage);
$this->assertTrue(

View file

@ -49,6 +49,7 @@ class CacheTestController extends Controller {
$this->set('batman', 'bruce wayne');
$this->set('spiderman', 'peter parker');
}
}
/**
@ -84,7 +85,7 @@ class CacheHelperTest extends CakeTestCase {
Configure::write('Cache.check', true);
Configure::write('Cache.disable', false);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
), App::RESET);
}
@ -380,7 +381,6 @@ class CacheHelperTest extends CakeTestCase {
$this->assertTrue(file_exists($filename));
@unlink($filename);
$this->Controller->cache_parsing();
$this->Controller->cacheAction = array(
'cache_parsing' => 21600
@ -398,7 +398,6 @@ class CacheHelperTest extends CakeTestCase {
$this->assertTrue(file_exists($filename));
@unlink($filename);
$this->Controller->cache_parsing();
$this->Controller->request->addParams(array(
'controller' => 'cache_test',

View file

@ -182,6 +182,7 @@ class ContactTagsContact extends CakeTestModel {
public function setSchema($schema) {
$this->_schema = $schema;
}
}
/**
@ -217,6 +218,7 @@ class ContactNonStandardPk extends Contact {
unset($this->_schema['id']);
return $this->_schema;
}
}
/**
@ -369,6 +371,7 @@ class OpenidUrl extends CakeTestModel {
$this->invalidate('openid_not_registered');
return true;
}
}
/**
@ -432,6 +435,7 @@ class ValidateUser extends CakeTestModel {
$this->invalidate('email');
return false;
}
}
/**
@ -505,6 +509,7 @@ class ValidateProfile extends CakeTestModel {
$this->invalidate('city');
return false;
}
}
/**
@ -568,6 +573,7 @@ class ValidateItem extends CakeTestModel {
$this->invalidate('description');
return false;
}
}
/**
@ -675,8 +681,6 @@ class FormHelperTest extends CakeTestCase {
Configure::write('Security.salt', $this->oldSalt);
}
/**
* testFormCreateWithSecurity method
*
@ -975,7 +979,6 @@ class FormHelperTest extends CakeTestCase {
$this->assertEquals(array('Address.button'), $result);
}
/**
* Test that submit inputs created with foo[bar] name attributes are unlocked correctly.
*
@ -1093,6 +1096,9 @@ class FormHelperTest extends CakeTestCase {
$this->Form->create('Address');
$this->Form->input('Address.primary.1');
$this->assertEquals('Address.primary', $this->Form->fields[0]);
$this->Form->input('Address.secondary.1.0');
$this->assertEquals('Address.secondary', $this->Form->fields[1]);
}
/**
@ -1469,7 +1475,7 @@ class FormHelperTest extends CakeTestCase {
*/
public function testTagIsInvalid() {
$Contact = ClassRegistry::getObject('Contact');
$Contact->validationErrors[0]['email'] = array('Please provide an email');
$Contact->validationErrors[0]['email'] = array('Please provide an email');
$this->Form->setEntity('Contact.0.email');
$result = $this->Form->tagIsInvalid();
@ -1496,7 +1502,7 @@ class FormHelperTest extends CakeTestCase {
*/
public function testPasswordValidation() {
$Contact = ClassRegistry::getObject('Contact');
$Contact->validationErrors['password'] = array('Please provide a password');
$Contact->validationErrors['password'] = array('Please provide a password');
$result = $this->Form->input('Contact.password');
$expected = array(
@ -2389,7 +2395,6 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->View->viewVars['users'] = array('value' => 'good', 'other' => 'bad');
$this->Form->request->data = array('Model' => array('user_id' => 'value'));
@ -5271,7 +5276,6 @@ class FormHelperTest extends CakeTestCase {
$this->assertContains('label for="ModelDateYear"', $result);
}
/**
* testMonth method
*
@ -5613,7 +5617,7 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->hour('Model.field', true, array('value' => 'now'));
$thisHour = date('H');
$optValue = date('G');
$this->assertRegExp('/<option value="' . $thisHour . '" selected="selected">'. $optValue .'<\/option>/', $result);
$this->assertRegExp('/<option value="' . $thisHour . '" selected="selected">' . $optValue . '<\/option>/', $result);
}
/**
@ -5943,7 +5947,7 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->button('No type', array('type' => false));
$this->assertTags($result, array('button' => array(), 'No type', '/button'));
$result = $this->Form->button('Upload Text', array('onClick' => "$('#postAddForm').ajaxSubmit({target: '#postTextUpload', url: '/posts/text'});return false;'", 'escape' => false));
$this->assertNotRegExp('/\&039/', $result);
}
@ -6459,7 +6463,6 @@ class FormHelperTest extends CakeTestCase {
'/div'
);
$this->assertTags($result, $expected);
}
/**
@ -6572,8 +6575,12 @@ class FormHelperTest extends CakeTestCase {
*/
public function testCreateWithInputDefaults() {
$this->Form->create('User', array(
'inputDefaults' => array('div' => false, 'label' => false, 'error' => array('attributes'=>array('wrap' => 'small', 'class' => 'error')))
));
'inputDefaults' => array(
'div' => false,
'label' => false,
'error' => array('attributes' => array('wrap' => 'small', 'class' => 'error'))
)
));
$result = $this->Form->input('username');
$expected = array(
'input' => array('type' => 'text', 'name' => 'data[User][username]', 'id' => 'UserUsername')
@ -6588,7 +6595,7 @@ class FormHelperTest extends CakeTestCase {
'/div'
);
$this->assertTags($result, $expected);
$User = ClassRegistry::getObject('User');
$User->validationErrors['username'] = array('empty');
$result = $this->Form->input('username', array('div' => true, 'label' => 'username', 'error' => array('empty' => __('Required'))));
@ -7058,7 +7065,6 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
extract($this->dateRegex);
$now = strtotime('now');

View file

@ -52,6 +52,7 @@ class TheHtmlTestController extends Controller {
}
class TestHtmlHelper extends HtmlHelper {
/**
* expose a method as public
*
@ -150,7 +151,7 @@ class HtmlHelperTest extends CakeTestCase {
$this->Html->request->webroot = '';
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'. DS)
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));
Configure::write('Asset.timestamp', false);
@ -404,7 +405,7 @@ class HtmlHelperTest extends CakeTestCase {
$File = new File($testfile, true);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
Configure::write('Asset.timestamp', true);
Configure::write('debug', 1);
@ -442,7 +443,7 @@ class HtmlHelperTest extends CakeTestCase {
*/
public function testThemeAssetsInMainWebrootPath() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$webRoot = Configure::read('App.www_root');
Configure::write('App.www_root', CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS);
@ -800,10 +801,9 @@ class HtmlHelperTest extends CakeTestCase {
'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
);
$this->assertTags($result, $expected);
}
/**
/**
* test that plugin scripts added with uses() are only ever included once.
* test script tag generation with plugin syntax
*
@ -933,7 +933,7 @@ class HtmlHelperTest extends CakeTestCase {
$File = new File($testfile, true);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$this->Html->webroot = '/';
@ -987,7 +987,6 @@ class HtmlHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->View->expects($this->at(0))
->method('append')
->with('script', $this->matchesRegularExpression('/window\.foo\s\=\s2;/'));
@ -1031,7 +1030,6 @@ class HtmlHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$result = $this->Html->scriptStart(array('safe' => false));
$this->assertNull($result);
echo 'this is some javascript';
@ -1116,7 +1114,6 @@ class HtmlHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->Html->addCrumb('Fourth', null);
$result = $this->Html->getCrumbs();
@ -1164,6 +1161,18 @@ class HtmlHelperTest extends CakeTestCase {
* Test the array form of $startText
*/
public function testGetCrumbFirstLink() {
$result = $this->Html->getCrumbList(null, 'Home');
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/')), 'Home', '/a',
'/li',
'/ul'
)
);
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');
@ -1502,14 +1511,11 @@ class HtmlHelperTest extends CakeTestCase {
$this->assertTags($result, array('meta' => array('name' => 'keywords', 'content' => 'these, are, some, meta, keywords')));
$this->assertRegExp('/\s+\/>$/', $result);
$result = $this->Html->meta('description', 'this is the meta description');
$this->assertTags($result, array('meta' => array('name' => 'description', 'content' => 'this is the meta description')));
$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'));
$this->assertTags($result, array('meta' => array('name' => 'ROBOTS', 'content' => 'ALL')));
}
/**
@ -1788,46 +1794,46 @@ class HtmlHelperTest extends CakeTestCase {
/**
* Test getCrumbList startText
*/
public function testCrumbListFirstLink() {
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');
public function testCrumbListFirstLink() {
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');
$result = $this->Html->getCrumbList(null, 'Home');
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/')), 'Home', '/a',
'/li',
'<li',
array('a' => array('href' => '#first')), 'First', '/a',
'/li',
array('li' => array('class' => 'last')),
array('a' => array('href' => '#second')), 'Second', '/a',
'/li',
'/ul'
)
);
$result = $this->Html->getCrumbList(null, 'Home');
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/')), 'Home', '/a',
'/li',
'<li',
array('a' => array('href' => '#first')), 'First', '/a',
'/li',
array('li' => array('class' => 'last')),
array('a' => array('href' => '#second')), 'Second', '/a',
'/li',
'/ul'
)
);
$result = $this->Html->getCrumbList(null, array('url' => '/home', 'text' => '<img src="/home.png" />', 'escape' => false));
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/home')), 'img' => array('src' => '/home.png'), '/a',
'/li',
'<li',
array('a' => array('href' => '#first')), 'First', '/a',
'/li',
array('li' => array('class' => 'last')),
array('a' => array('href' => '#second')), 'Second', '/a',
'/li',
'/ul'
)
);
}
$result = $this->Html->getCrumbList(null, array('url' => '/home', 'text' => '<img src="/home.png" />', 'escape' => false));
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/home')), 'img' => array('src' => '/home.png'), '/a',
'/li',
'<li',
array('a' => array('href' => '#first')), 'First', '/a',
'/li',
array('li' => array('class' => 'last')),
array('a' => array('href' => '#second')), 'Second', '/a',
'/li',
'/ul'
)
);
}
/**
* testLoadConfig method
@ -1836,7 +1842,7 @@ class HtmlHelperTest extends CakeTestCase {
*/
public function testLoadConfig() {
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS;
$result = $this->Html->loadConfig('htmlhelper_tags', $path);
$expected = array(
@ -1876,7 +1882,7 @@ class HtmlHelperTest extends CakeTestCase {
* @expectedException ConfigureException
*/
public function testLoadConfigWrongReader() {
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS;
$result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path);
}

View file

@ -22,6 +22,7 @@ App::uses('JqueryEngineHelper', 'View/Helper');
App::uses('View', 'View');
class JqueryEngineHelperTest extends CakeTestCase {
/**
* setUp
*

View file

@ -26,12 +26,15 @@ App::uses('View', 'View');
App::uses('ClassRegistry', 'Utility');
class JsEncodingObject {
protected $_title = 'Old thing';
private $__noshow = 'Never ever';
}
class OptionEngineHelper extends JsBaseEngineHelper {
protected $_optionMap = array(
'request' => array(
'complete' => 'success',
@ -58,17 +61,39 @@ class OptionEngineHelper extends JsBaseEngineHelper {
return $this->_parseOptions($options, $safe);
}
public function get($selector) {}
public function event($type, $callback, $options = array()) {}
public function domReady($functionBody) {}
public function each($callback) {}
public function effect($name, $options = array()) {}
public function request($url, $options = array()) {}
public function drag($options = array()) {}
public function drop($options = array()) {}
public function sortable($options = array()) {}
public function slider($options = array()) {}
public function serializeForm($options = array()) {}
public function get($selector) {
}
public function event($type, $callback, $options = array()) {
}
public function domReady($functionBody) {
}
public function each($callback) {
}
public function effect($name, $options = array()) {
}
public function request($url, $options = array()) {
}
public function drag($options = array()) {
}
public function drop($options = array()) {
}
public function sortable($options = array()) {
}
public function slider($options = array()) {
}
public function serializeForm($options = array()) {
}
}
/**
@ -77,6 +102,7 @@ class OptionEngineHelper extends JsBaseEngineHelper {
* @package Cake.Test.Case.View.Helper
*/
class JsHelperTest extends CakeTestCase {
/**
* Regexp for CDATA start block
*
@ -91,7 +117,6 @@ class JsHelperTest extends CakeTestCase {
*/
public $cDataEnd = 'preg:/[^\]]*\]\]\>[\s\r\n]*/';
/**
* setUp method
*
@ -689,6 +714,7 @@ class JsHelperTest extends CakeTestCase {
$this->assertEquals($result[1], 'alert("hey you!");');
$this->assertEquals($result[2], 'confirm("Are you sure?");');
}
}
/**
@ -697,6 +723,7 @@ class JsHelperTest extends CakeTestCase {
* @package Cake.Test.Case.View.Helper
*/
class JsBaseEngineTest extends CakeTestCase {
/**
* setUp method
*
@ -812,7 +839,6 @@ class JsBaseEngineTest extends CakeTestCase {
* @return void
*/
public function testObject() {
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8));
$result = $this->JsEngine->object($object);
$expected = '{"title":"New thing","indexes":[5,6,7,8]}';

View file

@ -22,6 +22,7 @@ App::uses('JsHelper', 'View/Helper');
App::uses('MootoolsEngineHelper', 'View/Helper');
class MootoolsEngineHelperTest extends CakeTestCase {
/**
* setUp
*

View file

@ -68,7 +68,6 @@ class NumberHelperTest extends CakeTestCase {
unset($this->View);
}
/**
* test CakeNumber class methods are called correctly
*/

View file

@ -212,13 +212,11 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc'));
@ -330,7 +328,6 @@ class PaginatorHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$result = $this->Paginator->sort('Article.title', 'Title');
$expected = array(
@ -1344,7 +1341,6 @@ class PaginatorHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->Paginator->request->params['paging'] = array(
'Client' => array(
'page' => 14,
@ -1417,7 +1413,7 @@ class PaginatorHelperTest extends CakeTestCase {
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
);
$this->assertTags($result, $expected);
$result = $this->Paginator->numbers(array('first' => 1, 'currentClass' => 'active'));
$expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
@ -1439,7 +1435,7 @@ class PaginatorHelperTest extends CakeTestCase {
array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
);
$this->assertTags($result, $expected);
$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active'));
$expected = array(
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
@ -1699,7 +1695,6 @@ class PaginatorHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->Paginator->request->params['paging'] = array(
'Client' => array(
'page' => 4895,

View file

@ -22,6 +22,7 @@ App::uses('JsHelper', 'View/Helper');
App::uses('PrototypeEngineHelper', 'View/Helper');
class PrototypeEngineHelperTest extends CakeTestCase {
/**
* setUp
*

View file

@ -377,7 +377,7 @@ class RssHelperTest extends CakeTestCase {
'url' => 'http://example.com/foo?a=1&b=2',
'convertEntities' => false
),
'description' => array(
'description' => array(
'value' => 'descriptive words',
'cdata' => true,
),

View file

@ -128,7 +128,7 @@ class SessionHelperTest extends CakeTestCase {
$this->assertEquals($expected, $result);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$result = $this->Session->flash('notification');
$result = str_replace("\r\n", "\n", $result);
@ -161,7 +161,7 @@ class SessionHelperTest extends CakeTestCase {
*/
public function testFlashElementInAttrs() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$result = $this->Session->flash('flash', array(
'element' => 'session_helper',
@ -178,7 +178,7 @@ class SessionHelperTest extends CakeTestCase {
*/
public function testFlashWithPluginElement() {
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'. DS)
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));
CakePlugin::load('TestPlugin');

View file

@ -28,6 +28,7 @@ class HtmlAliasHelper extends HtmlHelper {
}
class HelperCollectionTest extends CakeTestCase {
/**
* setUp
*

View file

@ -93,6 +93,7 @@ class HelperTestComment extends Model {
);
return $this->_schema;
}
}
/**
@ -123,6 +124,7 @@ class HelperTestTag extends Model {
);
return $this->_schema;
}
}
/**
@ -151,9 +153,11 @@ class HelperTestPostsTag extends Model {
);
return $this->_schema;
}
}
class TestHelper extends Helper {
/**
* Helpers for this helper.
*
@ -173,6 +177,7 @@ class TestHelper extends Helper {
public function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
}
}
/**
@ -644,12 +649,12 @@ class HelperTest extends CakeTestCase {
* @return void
*/
public function testAssetTimestampPluginsAndThemes() {
$_timestamp = Configure::read('Asset.timestamp');
$timestamp = Configure::read('Asset.timestamp');
Configure::write('Asset.timestamp', 'force');
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS),
));
CakePlugin::load(array('TestPlugin'));;
CakePlugin::load(array('TestPlugin'));
$result = $this->Helper->assetTimestamp('/test_plugin/css/test_plugin_asset.css');
$this->assertRegExp('#/test_plugin/css/test_plugin_asset.css\?[0-9]+$#', $result, 'Missing timestamp plugin');
@ -664,7 +669,7 @@ class HelperTest extends CakeTestCase {
$this->assertRegExp('#/theme/test_theme/js/non_existant.js\?$#', $result, 'No error on missing file');
App::build();
Configure::write('Asset.timestamp', $_timestamp);
Configure::write('Asset.timestamp', $timestamp);
}
/**
@ -834,7 +839,7 @@ class HelperTest extends CakeTestCase {
$this->Helper->request->data['My']['title'] = 'My Title';
$result = $this->Helper->value('My.title');
$this->assertEquals($result,'My Title');
$this->assertEquals($result, 'My Title');
}
public function testWebrootPaths() {
@ -846,7 +851,7 @@ class HelperTest extends CakeTestCase {
$this->Helper->theme = 'test_theme';
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$result = $this->Helper->webroot('/img/cake.power.gif');
@ -916,10 +921,11 @@ class HelperTest extends CakeTestCase {
*/
public function testLazyLoadingUsesReferences() {
$Helper = new TestHelper($this->View);
$result1 = $Helper->Html;
$result2 = $Helper->Html;
$resultA = $Helper->Html;
$resultB = $Helper->Html;
$result1->testprop = 1;
$this->assertEquals($result1->testprop, $result2->testprop);
$resultA->testprop = 1;
$this->assertEquals($resultA->testprop, $resultB->testprop);
}
}

View file

@ -62,7 +62,7 @@ class JsonViewTest extends CakeTestCase {
$View = new JsonView($Controller);
$output = $View->render(false);
$this->assertIdentical(json_encode(array('no' =>$data['no'], 'user' => $data['user'])), $output);
$this->assertIdentical(json_encode(array('no' => $data['no'], 'user' => $data['user'])), $output);
$this->assertIdentical('application/json', $Response->type());
}

View file

@ -70,7 +70,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testRender() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'css' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
);
@ -117,7 +117,7 @@ class MediaViewTest extends CakeTestCase {
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
$_SERVER['HTTP_USER_AGENT'] = 'Some generic browser';
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'id' => 'no_section.ini',
'extension' => 'ini',
);
@ -176,7 +176,7 @@ class MediaViewTest extends CakeTestCase {
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
$_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10';
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'id' => 'no_section.ini',
'extension' => 'ini',
);
@ -240,7 +240,7 @@ class MediaViewTest extends CakeTestCase {
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)';
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'id' => 'no_section.ini',
'extension' => 'ini',
'name' => 'config'
@ -303,7 +303,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testConnectionAborted() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'css' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
);
@ -326,7 +326,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testConnectionAbortedOnBuffering() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'css' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
);
@ -359,7 +359,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testRenderUpperExtension() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'img' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS,
'id' => 'test_2.JPG',
'extension' => 'JPG',
);
@ -383,7 +383,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testRenderExtensionNotSet() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'img' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS,
'id' => 'test_2.JPG',
);

View file

@ -39,6 +39,7 @@ class TestScaffoldView extends ScaffoldView {
public function testGetFilename($action) {
return $this->_getViewFileName($action);
}
}
/**
@ -141,7 +142,7 @@ class ScaffoldViewTest extends CakeTestCase {
$this->assertEquals($expected, $result);
$result = $ScaffoldView->testGetFilename('admin_edit');
$expected =CAKE . 'View' . DS . 'Scaffolds' . DS . 'form.ctp';
$expected = CAKE . 'View' . DS . 'Scaffolds' . DS . 'form.ctp';
$this->assertEquals($expected, $result);
$result = $ScaffoldView->testGetFilename('admin_add');
@ -159,11 +160,11 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($Controller);
$result = $ScaffoldView->testGetFilename('admin_edit');
$expected = CAKE . 'Test' . DS . 'test_app' .DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp';
$this->assertEquals($expected, $result);
$result = $ScaffoldView->testGetFilename('edit');
$expected = CAKE . 'Test' . DS . 'test_app' .DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp';
$this->assertEquals($expected, $result);
$Controller = new ScaffoldViewMockController($this->request);
@ -178,13 +179,13 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($Controller);
$result = $ScaffoldView->testGetFilename('admin_add');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'
. DS .'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' .
DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp';
$this->assertEquals($expected, $result);
$result = $ScaffoldView->testGetFilename('add');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'
. DS .'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' .
DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp';
$this->assertEquals($expected, $result);
Configure::write('Routing.prefixes', $_admin);
@ -202,8 +203,8 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($this->Controller);
$result = $ScaffoldView->testGetFilename('index');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS
. 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'scaffold.index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .
'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'scaffold.index.ctp';
$this->assertEquals($expected, $result);
}

View file

@ -48,6 +48,7 @@ class ThemePosts2Controller extends Controller {
$test3 = 'even more data';
$this->set(compact('test2', 'test3'));
}
}
/**
@ -112,7 +113,7 @@ class ThemeViewTest extends CakeTestCase {
$this->ThemeView = new ThemeView($this->PostsController);
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
App::objects('plugins', null, false);
CakePlugin::load(array('TestPlugin'));
@ -144,15 +145,15 @@ class ThemeViewTest extends CakeTestCase {
$this->Controller->theme = 'TestTheme';
$ThemeView = new TestTheme2View($this->Controller);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp';
$result = $ThemeView->getViewFileName('index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS .'plugin_default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS . 'plugin_default.ctp';
$result = $ThemeView->getLayoutFileName('plugin_default');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName('default');
$this->assertEquals($expected, $result);
}
@ -171,15 +172,15 @@ class ThemeViewTest extends CakeTestCase {
$ThemeView = new TestTheme2View($this->Controller);
$ThemeView->theme = 'TestTheme';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp';
$result = $ThemeView->getViewFileName('home');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp';
$result = $ThemeView->getViewFileName('/Posts/index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertEquals($expected, $result);

View file

@ -66,6 +66,7 @@ class ViewPostsController extends Controller {
$this->set('foo', 'this is foo var');
$this->set('bar', 'this is bar var');
}
}
/**
@ -95,6 +96,7 @@ class ThemePostsController extends Controller {
$test3 = 'even more data';
$this->set(compact('test2', 'test3'));
}
}
/**
@ -196,6 +198,7 @@ class TestView extends View {
public function scripts() {
return $this->_scripts;
}
}
/**
@ -229,6 +232,7 @@ class TestAfterHelper extends Helper {
public function afterLayout($layoutFile) {
$this->_View->output .= 'modified in the afterlife';
}
}
@ -270,7 +274,7 @@ class ViewTest extends CakeTestCase {
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
), App::RESET);
App::objects('plugins', null, false);
@ -292,8 +296,8 @@ class ViewTest extends CakeTestCase {
unset($this->ThemeView);
unset($this->ThemePostsController);
unset($this->ThemeController);
}
/**
* testGetTemplate method
*
@ -308,15 +312,15 @@ class ViewTest extends CakeTestCase {
$ThemeView = new TestThemeView($this->Controller);
$ThemeView->theme = 'TestTheme';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp';
$result = $ThemeView->getViewFileName('home');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp';
$result = $ThemeView->getViewFileName('/Posts/index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertEquals($expected, $result);
@ -344,11 +348,11 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
$expected = CakePlugin::path('TestPlugin') . 'View' . DS .'Tests' . DS .'index.ctp';
$expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'Tests' . DS . 'index.ctp';
$result = $View->getViewFileName('index');
$this->assertEquals($expected, $result);
$expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName();
$this->assertEquals($expected, $result);
}
@ -366,15 +370,15 @@ class ViewTest extends CakeTestCase {
$this->Controller->theme = 'TestTheme';
$ThemeView = new TestThemeView($this->Controller);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp';
$result = $ThemeView->getViewFileName('index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS .'plugin_default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS . 'plugin_default.ctp';
$result = $ThemeView->getLayoutFileName('plugin_default');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName('default');
$this->assertEquals($expected, $result);
}
@ -421,15 +425,15 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$pluginPath = CakePlugin::path('TestPlugin');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS .'TestPlugin' . DS . 'View' . DS .'Tests' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'index.ctp';
$result = $View->getViewFileName('index');
$this->assertEquals($expected, $result);
$expected = $pluginPath. 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = $pluginPath . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName();
$this->assertEquals($expected, $result);
}
@ -448,29 +452,29 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp';
$result = $View->getViewFileName('home');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp';
$result = $View->getViewFileName('/Posts/index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp';
$result = $View->getViewFileName('../Posts/index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'page.home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'page.home.ctp';
$result = $View->getViewFileName('page.home');
$this->assertEquals($expected, $result, 'Should not ruin files with dots.');
CakePlugin::load('TestPlugin');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp';
$result = $View->getViewFileName('TestPlugin.home');
$this->assertEquals($expected, $result, 'Plugin is missing the view, cascade to app.');
$View->viewPath = 'Tests';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS .'Tests' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'index.ctp';
$result = $View->getViewFileName('TestPlugin.index');
$this->assertEquals($expected, $result);
}
@ -488,7 +492,7 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName();
$this->assertEquals($expected, $result);
@ -517,12 +521,12 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
CakePlugin::load('TestPlugin');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName('TestPlugin.default');
$this->assertEquals($expected, $result);
$View->plugin = 'TestPlugin';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName('default');
$this->assertEquals($expected, $result);
}
@ -1042,10 +1046,9 @@ class ViewTest extends CakeTestCase {
$result = $View->getViewFileName('../Themed/TestTheme/Posts/index');
$this->assertRegExp('/Themed(\/|\\\)TestTheme(\/|\\\)Posts(\/|\\\)index.ctp/', $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp';
$result = $View->getViewFileName('../Posts/index');
$this->assertEquals($expected, $result);
}
/**
@ -1114,44 +1117,6 @@ class ViewTest extends CakeTestCase {
$this->assertNotRegExp('/cake:nocache/', $result);
}
/**
* testRenderNocache method
*
* @return void
*/
/* This is a new test case for a pending enhancement
public function testRenderNocache() {
$this->PostsController->helpers = array('Cache', 'Html');
$this->PostsController->constructClasses();
$this->PostsController->cacheAction = 21600;
$this->PostsController->here = '/posts/nocache_multiple_element';
$this->PostsController->action = 'nocache_multiple_element';
$this->PostsController->nocache_multiple_element();
Configure::write('Cache.check', true);
Configure::write('Cache.disable', false);
$filename = CACHE . 'views' . DS . 'posts_nocache_multiple_element.php';
$View = new TestView($this->PostsController);
$View->render();
ob_start();
$View->renderCache($filename, getMicroTime());
$result = ob_get_clean();
@unlink($filename);
$this->assertRegExp('/php echo \$foo;/', $result);
$this->assertRegExp('/php echo \$bar;/', $result);
$this->assertRegExp('/php \$barfoo = \'in sub2\';/', $result);
$this->assertRegExp('/php echo \$barfoo;/', $result);
$this->assertRegExp('/printing: "in sub2"/', $result);
$this->assertRegExp('/php \$foobar = \'in sub1\';/', $result);
$this->assertRegExp('/php echo \$foobar;/', $result);
$this->assertRegExp('/printing: "in sub1"/', $result);
}
*/
/**
* testSet method
*

View file

@ -64,7 +64,7 @@ class XmlViewTest extends CakeTestCase {
$output = $View->render(false);
$expected = array(
'response' => array('no' =>$data['no'], 'user' => $data['user'])
'response' => array('no' => $data['no'], 'user' => $data['user'])
);
$this->assertIdentical(Xml::build($expected)->asXML(), $output);
$this->assertIdentical('application/xml', $Response->type());

View file

@ -30,6 +30,7 @@ class AccountFixture extends CakeTestFixture {
* @var string 'Aco'
*/
public $name = 'Account';
public $table = 'Accounts';
/**

View file

@ -86,7 +86,7 @@ class AssertTagsTestCase extends CakeTestCase {
$this->assertTags($input, $pattern);
}
/**
/**
* testBadAssertTags
*
* @return void

View file

@ -39,7 +39,7 @@ class BookFixture extends CakeTestFixture {
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'isbn' => array('type' => 'string', 'length' => 13),
'title' => array('type' => 'string', 'length' => 255),
'title' => array('type' => 'string', 'length' => 255),
'author' => array('type' => 'string', 'length' => 255),
'year' => array('type' => 'integer', 'null' => true),
'pages' => array('type' => 'integer', 'null' => true)

View file

@ -38,7 +38,7 @@ class CdFixture extends CakeTestFixture {
*/
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'title' => array('type' => 'string', 'length' => 255),
'title' => array('type' => 'string', 'length' => 255),
'artist' => array('type' => 'string', 'length' => 255, 'null' => true),
'genre' => array('type' => 'string', 'length' => 255, 'null' => true)
);

View file

@ -30,6 +30,7 @@ class ContentAccountFixture extends CakeTestFixture {
* @var string 'Aco'
*/
public $name = 'ContentAccount';
public $table = 'ContentAccounts';
/**
@ -39,8 +40,8 @@ class ContentAccountFixture extends CakeTestFixture {
*/
public $fields = array(
'iContentAccountsId' => array('type' => 'integer', 'key' => 'primary'),
'iContentId' => array('type' => 'integer'),
'iAccountId' => array('type' => 'integer')
'iContentId' => array('type' => 'integer'),
'iAccountId' => array('type' => 'integer')
);
/**

View file

@ -30,6 +30,7 @@ class ContentFixture extends CakeTestFixture {
* @var string 'Aco'
*/
public $name = 'Content';
public $table = 'Content';
/**
@ -38,8 +39,8 @@ class ContentFixture extends CakeTestFixture {
* @var array
*/
public $fields = array(
'iContentId' => array('type' => 'integer', 'key' => 'primary'),
'cDescription' => array('type' => 'string', 'length' => 50, 'null' => true)
'iContentId' => array('type' => 'integer', 'key' => 'primary'),
'cDescription' => array('type' => 'string', 'length' => 50, 'null' => true)
);
/**

View file

@ -40,7 +40,6 @@ class DataTestFixture extends CakeTestFixture {
'id' => array('type' => 'integer', 'key' => 'primary'),
'count' => array('type' => 'integer', 'default' => 0),
'float' => array('type' => 'float', 'default' => 0),
//'timestamp' => array('type' => 'timestamp', 'default' => null, 'null' => true),
'created' => array('type' => 'datetime', 'default' => null),
'updated' => array('type' => 'datetime', 'default' => null)
);

View file

@ -52,6 +52,7 @@ class FixturizedTestCase extends CakeTestCase {
* test that a fixtures are unoaded even if the test throws exceptions
*
* @return void
* @throws Exception
*/
public function testThrowException() {
throw new Exception();

View file

@ -40,7 +40,7 @@ class FruitFixture extends CakeTestFixture {
'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'),
'name' => array('type' => 'string', 'length' => 255),
'color' => array('type' => 'string', 'length' => 13),
'shape' => array('type' => 'string', 'length' => 255),
'shape' => array('type' => 'string', 'length' => 255),
'taste' => array('type' => 'string', 'length' => 255)
);

View file

@ -23,15 +23,18 @@
* @package Cake.Test.Fixture
*/
class GroupUpdateAllFixture extends CakeTestFixture {
public $name = 'GroupUpdateAll';
public $table = 'group_update_all';
public $fields = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => false, 'length' => 29),
'code' => array('type' => 'integer', 'null' => false, 'length' => 4),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
public $records = array(
array(
'id' => 1,

View file

@ -27,9 +27,11 @@
class PrefixTestFixture extends CakeTestFixture {
public $name = 'PrefixTest';
public $table = 'prefix_prefix_tests';
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
);
}

View file

@ -23,16 +23,19 @@
* @package Cake.Test.Fixture
*/
class ProductUpdateAllFixture extends CakeTestFixture {
public $name = 'ProductUpdateAll';
public $table = 'product_update_all';
public $fields = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => false, 'length' => 29),
'groupcode' => array('type' => 'integer', 'null' => false, 'length' => 4),
'group_id' => array('type' => 'integer', 'null' => false, 'length' => 8),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
public $records = array(
array(
'id' => 1,

View file

@ -31,13 +31,6 @@ class SessionFixture extends CakeTestFixture {
*/
public $name = 'Session';
/**
* table property.
*
* @var string
*/
// public $table = 'sessions';
/**
* fields property
*

View file

@ -1,5 +1,4 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
@ -28,6 +27,7 @@
* @package Cake.Test.Fixture
*/
class TranslateWithPrefixFixture extends CakeTestFixture {
/**
* name property
*

View file

@ -30,7 +30,8 @@ class UnderscoreFieldFixture extends CakeTestFixture {
* @var string 'UnderscoreField'
*/
public $name = 'UnderscoreField';
/**
/**
* fields property
*
* @var array
@ -43,7 +44,8 @@ class UnderscoreFieldFixture extends CakeTestFixture {
'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'),
'another_field' => array('type' => 'integer', 'length' => 3),
);
/**
/**
* records property
*
* @var array

View file

@ -40,7 +40,7 @@ class UuidTagFixture extends CakeTestFixture {
'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'),
'name' => array('type' => 'string', 'length' => 255),
'created' => array('type' => 'datetime')
);
);
/**
* records property

View file

@ -53,16 +53,16 @@ $config['roles'] = array(
// Rules
//-------------------------------------
$config['rules']['allow'] = array(
'/*' => 'Role/admin',
'/controllers/*/manager_*' => 'Role/manager',
'/controllers/reports/*' => 'Role/sales',
'/controllers/invoices/*' => 'Role/accounting',
'/controllers/invoices/edit'=> 'User/db_manager_2',
'/controllers/db/*' => 'Role/database_manager',
'/controllers/*/(add|edit|publish)' => 'User/stan',
'/*' => 'Role/admin',
'/controllers/*/manager_*' => 'Role/manager',
'/controllers/reports/*' => 'Role/sales',
'/controllers/invoices/*' => 'Role/accounting',
'/controllers/invoices/edit' => 'User/db_manager_2',
'/controllers/db/*' => 'Role/database_manager',
'/controllers/*/(add|edit|publish)' => 'User/stan',
'/controllers/users/dashboard' => 'Role/default',
// test for case insensitivity
'controllers/Forms/NEW' => 'Role/data_acquirer',
'controllers/Forms/NEW' => 'Role/data_acquirer',
);
$config['rules']['deny'] = array(
// accountants and sales should not delete anything

View file

@ -17,7 +17,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class TestsAppsController extends AppController {
public $name = 'TestsApps';
public $uses = array();
public function index() {
@ -40,4 +42,5 @@ class TestsAppsController extends AppController {
public function redirect_to() {
$this->redirect('http://cakephp.org');
}
}

View file

@ -17,8 +17,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class TestsAppsPostsController extends AppController {
public $name = 'TestsAppsPosts';
public $uses = array('Post');
public $viewPath = 'TestsApps';
public function add() {

View file

@ -24,13 +24,18 @@ class TestAppCacheEngine extends CacheEngine {
}
}
public function read($key) { }
public function read($key) {
}
public function increment($key, $offset = 1) { }
public function increment($key, $offset = 1) {
}
public function decrement($key, $offset = 1) { }
public function decrement($key, $offset = 1) {
}
public function delete($key) { }
public function delete($key) {
}
public function clear($check) { }
public function clear($check) {
}
}

View file

@ -16,4 +16,5 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class Library {}
class Library {
}

View file

@ -22,6 +22,5 @@ App::uses('CakeLogInterface', 'Log');
class TestAppLog implements CakeLogInterface {
public function write($type, $message) {
}
}

View file

@ -16,4 +16,5 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class TestUtilityClass {}
class TestUtilityClass {
}

View file

@ -19,6 +19,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class Comment extends AppModel {
public $useTable = 'comments';
public $name = 'Comment';
}

View file

@ -13,22 +13,18 @@ class TestAppLibSession implements CakeSessionHandlerInterface {
}
public function close() {
}
public function read($id) {
}
public function write($id, $data) {
}
public function destroy($id) {
}
public function gc($expires = null) {
}
}
}

View file

@ -19,12 +19,15 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class PersisterOne extends AppModel {
public $useTable = 'posts';
public $name = 'PersisterOne';
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
public $hasMany = array('Comment', 'TestPlugin.TestPluginComment');
public $validate = array(
'title' => array(
'custom' => array(
@ -53,4 +56,5 @@ class PersisterOne extends AppModel {
)
),
);
}

View file

@ -19,10 +19,13 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class PersisterTwo extends AppModel {
public $useTable = 'posts';
public $name = 'PersisterTwo';
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
public $hasMany = array('Comment', 'TestPlugin.TestPluginComment');
}

Some files were not shown because too many files have changed in this diff Show more