Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '2.1' into 2.2

Conflicts:
	lib/Cake/Test/Case/Model/ModelWriteTest.php
  • Loading branch information...
commit c58b61c17b23382cf99a7f6a5383a4fa1dcbfc83 2 parents e8993b5 + dbb2dd4
@markstory markstory authored
Showing with 1,344 additions and 1,074 deletions.
  1. +1 −1  app/Console/cake
  2. +1 −1  app/webroot/.htaccess
  3. +6 −0 build.xml
  4. +2 −2 lib/Cake/Console/Templates/skel/Console/cake
  5. +1 −1  lib/Cake/Console/Templates/skel/webroot/.htaccess
  6. +1 −1  lib/Cake/Console/cake
  7. +30 −23 lib/Cake/Controller/Component/CookieComponent.php
  8. +5 −3 lib/Cake/Controller/Component/RequestHandlerComponent.php
  9. +37 −11 lib/Cake/Core/Configure.php
  10. +2 −2 lib/Cake/Model/Behavior/TreeBehavior.php
  11. +10 −2 lib/Cake/Model/Model.php
  12. +1 −1  lib/Cake/Test/Case/AllTestsTest.php
  13. +20 −20 lib/Cake/Test/Case/BasicsTest.php
  14. +20 −1 lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php
  15. +1 −1  lib/Cake/Test/Case/Core/ConfigureTest.php
  16. +4 −4 lib/Cake/Test/Case/I18n/I18nTest.php
  17. +3 −4 lib/Cake/Test/Case/I18n/L10nTest.php
  18. +0 −76 lib/Cake/Test/Case/I18n/MultibyteTest.php
  19. +2 −1  lib/Cake/Test/Case/Model/AclNodeTest.php
  20. +20 −18 lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php
  21. +5 −3 lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
  22. +1 −2  lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
  23. +1 −1  lib/Cake/Test/Case/Model/Behavior/TreeBehaviorAfterTest.php
  24. +32 −34 lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php
  25. +1 −1  lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php
  26. +8 −8 lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php
  27. +13 −66 lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
  28. +45 −38 lib/Cake/Test/Case/Model/CakeSchemaTest.php
  29. +2 −2 lib/Cake/Test/Case/Model/ConnectionManagerTest.php
  30. +54 −60 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
  31. +36 −32 lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php
  32. +1 −0  lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
  33. +29 −23 lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php
  34. +2 −9 lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
  35. +4 −1 lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php
  36. +6 −4 lib/Cake/Test/Case/Model/ModelCrossSchemaHabtmTest.php
  37. +5 −6 lib/Cake/Test/Case/Model/ModelDeleteTest.php
  38. +110 −17 lib/Cake/Test/Case/Model/ModelIntegrationTest.php
  39. +13 −14 lib/Cake/Test/Case/Model/ModelReadTest.php
  40. +1 −1  lib/Cake/Test/Case/Model/ModelValidationTest.php
  41. +62 −18 lib/Cake/Test/Case/Model/ModelWriteTest.php
  42. +242 −80 lib/Cake/Test/Case/Model/models.php
  43. +5 −11 lib/Cake/Test/Case/Network/CakeRequestTest.php
  44. +63 −66 lib/Cake/Test/Case/Network/CakeResponseTest.php
  45. +15 −17 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
  46. +0 −1  lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php
  47. +2 −2 lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php
  48. +10 −10 lib/Cake/Test/Case/Network/Http/HttpResponseTest.php
  49. +7 −10 lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
  50. +18 −17 lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php
  51. +10 −3 lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php
  52. +0 −18 lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php
  53. +6 −4 lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php
  54. +1 −2  lib/Cake/Test/Case/TestSuite/HtmlCoverageReportTest.php
  55. +2 −3 lib/Cake/Test/Case/View/Helper/CacheHelperTest.php
  56. +20 −14 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  57. +60 −54 lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
  58. +1 −0  lib/Cake/Test/Case/View/Helper/JqueryEngineHelperTest.php
  59. +39 −13 lib/Cake/Test/Case/View/Helper/JsHelperTest.php
  60. +1 −0  lib/Cake/Test/Case/View/Helper/MootoolsEngineHelperTest.php
  61. +0 −1  lib/Cake/Test/Case/View/Helper/NumberHelperTest.php
  62. +2 −7 lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
  63. +1 −0  lib/Cake/Test/Case/View/Helper/PrototypeEngineHelperTest.php
  64. +1 −1  lib/Cake/Test/Case/View/Helper/RssHelperTest.php
  65. +3 −3 lib/Cake/Test/Case/View/Helper/SessionHelperTest.php
  66. +1 −0  lib/Cake/Test/Case/View/HelperCollectionTest.php
  67. +15 −9 lib/Cake/Test/Case/View/HelperTest.php
  68. +1 −1  lib/Cake/Test/Case/View/JsonViewTest.php
  69. +8 −8 lib/Cake/Test/Case/View/MediaViewTest.php
  70. +10 −9 lib/Cake/Test/Case/View/ScaffoldViewTest.php
  71. +8 −7 lib/Cake/Test/Case/View/ThemeViewTest.php
  72. +27 −62 lib/Cake/Test/Case/View/ViewTest.php
  73. +1 −1  lib/Cake/Test/Case/View/XmlViewTest.php
  74. +1 −0  lib/Cake/Test/Fixture/AccountFixture.php
  75. +1 −1  lib/Cake/Test/Fixture/AssertTagsTestCase.php
  76. +1 −1  lib/Cake/Test/Fixture/BookFixture.php
  77. +1 −1  lib/Cake/Test/Fixture/CdFixture.php
  78. +3 −2 lib/Cake/Test/Fixture/ContentAccountFixture.php
  79. +3 −2 lib/Cake/Test/Fixture/ContentFixture.php
  80. +0 −1  lib/Cake/Test/Fixture/DataTestFixture.php
  81. +1 −0  lib/Cake/Test/Fixture/FixturizedTestCase.php
  82. +1 −1  lib/Cake/Test/Fixture/FruitFixture.php
  83. +4 −1 lib/Cake/Test/Fixture/GroupUpdateAllFixture.php
  84. +2 −0  lib/Cake/Test/Fixture/PrefixTestFixture.php
  85. +4 −1 lib/Cake/Test/Fixture/ProductUpdateAllFixture.php
  86. +0 −7 lib/Cake/Test/Fixture/SessionFixture.php
  87. +1 −1  lib/Cake/Test/Fixture/TranslateWithPrefixFixture.php
  88. +4 −2 lib/Cake/Test/Fixture/UnderscoreFieldFixture.php
  89. +1 −1  lib/Cake/Test/Fixture/UuidTagFixture.php
  90. +8 −8 lib/Cake/Test/test_app/Config/acl.php
  91. +3 −0  lib/Cake/Test/test_app/Controller/TestsAppsController.php
  92. +3 −0  lib/Cake/Test/test_app/Controller/TestsAppsPostsController.php
  93. +10 −5 lib/Cake/Test/test_app/Lib/Cache/Engine/TestAppCacheEngine.php
  94. +2 −1  lib/Cake/Test/test_app/Lib/Library.php
  95. +0 −1  lib/Cake/Test/test_app/Lib/Log/Engine/TestAppLog.php
  96. +2 −1  lib/Cake/Test/test_app/Lib/Utility/TestUtilityClass.php
  97. +3 −0  lib/Cake/Test/test_app/Model/Comment.php
  98. +2 −6 lib/Cake/Test/test_app/Model/Datasource/Session/TestAppLibSession.php
  99. +4 −0 lib/Cake/Test/test_app/Model/PersisterOne.php
  100. +3 −0  lib/Cake/Test/test_app/Model/PersisterTwo.php
  101. +3 −0  lib/Cake/Test/test_app/Model/Post.php
  102. +5 −5 lib/Cake/Test/test_app/Plugin/TestPlugin/Config/Schema/schema.php
  103. +18 −18 lib/Cake/Test/test_app/Plugin/TestPlugin/Config/load.php
  104. +18 −18 lib/Cake/Test/test_app/Plugin/TestPlugin/Config/more.load.php
  105. +2 −0  lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/PluginsComponent.php
  106. +2 −0  lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/Component/TestPluginComponent.php
  107. +2 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/TestPluginAppController.php
  108. +2 −0  lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/TestPluginController.php
  109. +5 −0 lib/Cake/Test/test_app/Plugin/TestPlugin/Controller/TestsController.php
  110. +12 −6 lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/Cache/Engine/TestPluginCacheEngine.php
  111. +2 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/Custom/Package/CustomLibClass.php
  112. +0 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/Log/Engine/TestPluginLog.php
  113. +2 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/TestPluginLibrary.php
  114. +2 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/Lib/TestPluginOtherLibrary.php
  115. +0 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterOneBehavior.php
  116. +0 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Behavior/TestPluginPersisterTwoBehavior.php
  117. +3 −0  lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/Database/DboDummy.php
  118. +2 −6 lib/Cake/Test/test_app/Plugin/TestPlugin/Model/Datasource/Session/TestPluginSession.php
  119. +2 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAppModel.php
  120. +0 −3  lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthUser.php
  121. +3 −3 lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginAuthors.php
  122. +3 −3 lib/Cake/Test/test_app/Plugin/TestPlugin/Model/TestPluginComment.php
  123. +2 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/View/Helper/OtherHelperHelper.php
  124. +1 −0  lib/Cake/Test/test_app/Plugin/TestPlugin/View/Helper/PluggedHelperHelper.php
  125. +1 −2  lib/Cake/Test/test_app/Plugin/TestPlugin/View/Helper/TestPluginAppHelper.php
  126. +1 −1  lib/Cake/Test/test_app/Plugin/TestPlugin/webroot/css/test_plugin_asset.css
  127. +1 −5 lib/Cake/View/Helper/FormHelper.php
  128. +4 −4 lib/Cake/View/Helper/HtmlHelper.php
View
2  app/Console/cake
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
################################################################################
#
# Bake is a shell script for running CakePHP bake script
View
2  app/webroot/.htaccess
@@ -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
6 build.xml
@@ -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
4 lib/Cake/Console/Templates/skel/Console/cake
@@ -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
2  lib/Cake/Console/Templates/skel/webroot/.htaccess
@@ -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
2  lib/Cake/Console/cake
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
################################################################################
#
# Bake is a shell script for running CakePHP bake script
View
53 lib/Cake/Controller/Component/CookieComponent.php
@@ -190,8 +190,9 @@ public function __construct(ComponentCollection $collection, $settings = array()
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 @@ public function startup(Controller $controller) {
* @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 @@ public function write($key, $value = null, $encrypt = true, $expires = null) {
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 @@ public function write($key, $value = null, $encrypt = true, $expires = null) {
* @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 @@ public function read($key = null) {
* @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 @@ public function delete($key) {
*/
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 @@ protected function _explode($string) {
}
return $array;
}
-
}
+
View
8 lib/Cake/Controller/Component/RequestHandlerComponent.php
@@ -581,9 +581,11 @@ public function renderAs(Controller $controller, $type, $options = array()) {
$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
48 lib/Cake/Core/Configure.php
@@ -75,20 +75,26 @@ public static function bootstrap($boot = true) {
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 @@ public static function restore($name, $cacheConfig = 'default') {
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
4 lib/Cake/Model/Behavior/TreeBehavior.php
@@ -607,7 +607,7 @@ public function recover(Model $Model, $mode = 'parent', $missingParentAction = n
$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 @@ public function removeFromTree(Model $Model, $id = null, $delete = false) {
$Model->id = $id;
return $Model->save(
array($left => $edge + 1, $right => $edge + 2, $parent => null),
- array('callbacks' => false)
+ array('callbacks' => false, 'validate' => false)
);
}
}
View
12 lib/Cake/Model/Model.php
@@ -1792,8 +1792,14 @@ protected function _saveMulti($joined, $id, $db) {
$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 @@ protected function _saveMulti($joined, $id, $db) {
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
2  lib/Cake/Test/Case/AllTestsTest.php
@@ -51,7 +51,7 @@ public static function suite() {
$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
40 lib/Cake/Test/Case/BasicsTest.php
@@ -685,7 +685,7 @@ public function testDebug() {
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 @@ public function testDebug() {
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 @@ public function testDebug() {
$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 @@ public function testDebug() {
$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 @@ public function testDebug() {
$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 @@ public function testDebug() {
</pre>
</div>
EXPECTED;
-$expectedText = <<<EXPECTED
+ $expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
'<div>this-is-a-test</div>'
@@ -761,9 +761,9 @@ public function testDebug() {
$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 @@ public function testDebug() {
</pre>
</div>
EXPECTED;
-$expectedText = <<<EXPECTED
+ $expectedText = <<<EXPECTED
########## DEBUG ##########
'<div>this-is-a-test</div>'
@@ -785,9 +785,9 @@ public function testDebug() {
$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 @@ public function testDebug() {
$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 @@ public function testDebug() {
$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 @@ public function testDebug() {
*/
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
21 lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php
@@ -160,7 +160,6 @@ public function testReadEncryptedCookieData() {
*/
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);
@@ -171,6 +170,26 @@ public function testReadPlainCookieData() {
}
/**
+ * 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()
*
* @return void
View
2  lib/Cake/Test/Case/Core/ConfigureTest.php
@@ -353,5 +353,5 @@ public function testReaderExceptionOnIncorrectClass() {
$reader = new StdClass();
Configure::config('test', $reader);
}
-}
+}
View
8 lib/Cake/Test/Case/I18n/I18nTest.php
@@ -2668,7 +2668,7 @@ private function __domainCategorySingular($domain = 'test_plugin', $category = 3
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 @@ private function __domainSingular($domain = 'test_plugin') {
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 @@ private function __singular() {
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 @@ private function __singularFromCore() {
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
7 lib/Cake/Test/Case/I18n/L10nTest.php
@@ -67,7 +67,6 @@ public function testGet() {
$l10n->get('');
$this->assertEquals($l10n->lang, 'en-us');
-
// Using $this->default
$l10n = new L10n();
@@ -83,7 +82,7 @@ public function testGet() {
* @return void
*/
public function testGetAutoLanguage() {
- $__SERVER = $_SERVER;
+ $serverBackup = $_SERVER;
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'inexistent,en-ca';
$l10n = new L10n();
@@ -107,7 +106,7 @@ public function testGetAutoLanguage() {
$this->assertEquals($l10n->languagePath, array('eng', 'eng', 'eng'));
$this->assertEquals($l10n->locale, 'eng');
- $_SERVER = $__SERVER;
+ $_SERVER = $serverBackup;
}
/**
@@ -895,7 +894,7 @@ public function testCatalog() {
$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
76 lib/Cake/Test/Case/I18n/MultibyteTest.php
@@ -159,14 +159,12 @@ public function testUtf8() {
65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276);
$this->assertEquals($expected, $result);
-
$string = 'abcdefghijklmnopqrstuvwxyz';
$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 @@ public function testUtf8() {
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 @@ public function testUsingMbStrtolower() {
$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 @@ public function testUsingMbStrtoupper() {
$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
3  lib/Cake/Test/Case/Model/AclNodeTest.php
@@ -198,6 +198,7 @@ public function bindNode($ref = null) {
return array('DbAroTest' => array('DbAroTest.model' => 'AuthUser', 'DbAroTest.foreign_key' => 2));
}
}
+
}
/**
@@ -218,6 +219,7 @@ public function __construct() {
$this->Aco = new DbAcoTest();
$this->Aro->Permission = new DbPermissionTest();
}
+
}
/**
@@ -332,7 +334,6 @@ public function testNodeObjectFind() {
$result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id');
$expected = array(4, 2, 1);
$this->assertEquals($expected, $result);
-
}
/**
View
38 lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php
@@ -27,10 +27,10 @@
/**
-* 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 @@ public function parentNode() {
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 @@ public function testAfterSave() {
$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 @@ public function testAfterSaveUpdateParentIdNotNull() {
);
$this->Aro->save($aroData);
-
$acoData = array(
'Aco' => array(
'model' => 'AclPerson',
View
8 lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
@@ -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 @@ public function testAutoFieldsWithMultipleDatabases() {
$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
3  lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
@@ -22,7 +22,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';
/**
* TranslateBehaviorTest class
@@ -351,7 +351,6 @@ public function testLocaleMultiple() {
$TestModel = new TranslatedItem();
$TestModel->locale = array('deu', 'eng', 'cze');
-
$result = $TestModel->read(null, 1);
$expected = array(
'TranslatedItem' => array(
View
2  lib/Cake/Test/Case/Model/Behavior/TreeBehaviorAfterTest.php
@@ -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
66 lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php
@@ -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 @@ public function testAddNotIndexedByModel() {
$validTree = $this->Tree->verify();
$this->assertSame($validTree, true);
-}
+ }
/**
* testMovePromote method
@@ -424,12 +424,12 @@ public function testMovePromote() {
$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 @@ public function testMoveWithWhitelist() {
$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 @@ public function testMoveBefore() {
$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 @@ public function testMoveAfter() {
$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 @@ public function testMoveDemoteInvalid() {
$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 @@ public function testMoveInvalid() {
$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 @@ public function testMoveSelfInvalid() {
$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 @@ public function testDelete() {
$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 @@ public function testRemoveAndDelete() {
$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 @@ public function testChildren() {
$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 @@ public function testGetParentNode() {
$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 @@ public function testGetPath() {
$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 @@ public function testNoAmbiguousColumn() {
$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
2  lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php
@@ -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
16 lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php
@@ -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 @@ public function testMovePromote() {
$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 @@ public function testMoveWithWhitelist() {
$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
79 lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
@@ -320,6 +320,7 @@ public function speakEnglish(Model $model, $method, $query) {
$query = preg_replace('/^in\s+/', 'Location.name = \'', $query);
return $method . '\' AND ' . $query . '\'';
}
+
}
/**
@@ -328,15 +329,15 @@ public function speakEnglish(Model $model, $method, $query) {
* @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 @@ public function setup(Model $model, $config = null) {
* @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 @@ public function setup(Model $model, $config = null) {
* @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 @@ public function setup(Model $model, $config = null) {
* @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 @@ public function testBehaviorHasManyFindCallbacks() {
$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 @@ public function testBehaviorHasManyFindCallbacks() {
$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 @@ public function testBehaviorHasOneFindCallbacks() {
$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 @@ public function testBehaviorHasOneFindCallbacks() {
$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 @@ public function testBehaviorBelongsToFindCallbacks() {
$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 @@ public function testBehaviorDeleteCallbacks() {
$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 @@ public function testHasMethodAsCallback() {
$this->assertEquals($expected, $result);
}
-
}
View
83 lib/Cake/Test/Case/Model/CakeSchemaTest.php
@@ -113,6 +113,7 @@ public function getVar($var) {
}
return $this->$var;
}
+
}
/**
@@ -219,6 +220,7 @@ public function setup($version) {
*/
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 @@ public function setUp() {
*/
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 @@ public function testSchemaRead() {
}
/**
-* 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 @@ public function testSchemaReadWithTablePrefix() {
));
unset($read['tables']['missing']);
$this->assertTrue(isset($read['tables']['auth_users']), 'auth_users key missing %s');
-
}
/**
@@ -699,14 +701,15 @@ public function testSchemaReadWithCrossDatabase() {
$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 @@ public function testSchemaReadWithCrossDatabase() {
$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 @@ public function testGenerateTable() {
* @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 @@ public function testSchemaComparison() {
$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),