Permalink
Browse files

Merge branch 1.2 into 1.3

  • Loading branch information...
gwoo
gwoo committed Apr 15, 2009
2 parents 643651f + 8db4fe6 commit ec18aac4ab38a49d00c1e6b600a868f42ac029c4
Showing with 1,216 additions and 275 deletions.
  1. +2 −2 cake/console/libs/tasks/controller.php
  2. +6 −1 cake/libs/controller/components/request_handler.php
  3. +8 −5 cake/libs/controller/controller.php
  4. +2 −1 cake/libs/debugger.php
  5. +1 −1 cake/libs/model/model.php
  6. +1 −1 cake/libs/session.php
  7. +2 −0 cake/libs/string.php
  8. +2 −1 cake/libs/validation.php
  9. +2 −1 cake/libs/view/helpers/ajax.php
  10. +7 −4 cake/libs/view/helpers/form.php
  11. +1 −1 cake/libs/view/helpers/javascript.php
  12. +9 −1 cake/libs/view/helpers/paginator.php
  13. +13 −1 cake/tests/cases/basics.test.php
  14. +5 −6 cake/tests/cases/console/cake.test.php
  15. +4 −1 cake/tests/cases/console/libs/shell.test.php
  16. +38 −6 cake/tests/cases/dispatcher.test.php
  17. +70 −13 cake/tests/cases/libs/cache.test.php
  18. +14 −2 cake/tests/cases/libs/cache/apc.test.php
  19. +10 −7 cake/tests/cases/libs/cache/file.test.php
  20. +8 −4 cake/tests/cases/libs/cache/memcache.test.php
  21. +14 −2 cake/tests/cases/libs/cache/xcache.test.php
  22. +6 −1 cake/tests/cases/libs/cake_test_case.test.php
  23. +1 −1 cake/tests/cases/libs/code_coverage_manager.test.php
  24. +5 −3 cake/tests/cases/libs/configure.test.php
  25. +20 −5 cake/tests/cases/libs/controller/component.test.php
  26. +1 −1 cake/tests/cases/libs/controller/components/acl.test.php
  27. +21 −6 cake/tests/cases/libs/controller/components/auth.test.php
  28. +21 −4 cake/tests/cases/libs/controller/components/email.test.php
  29. +1 −0 cake/tests/cases/libs/controller/components/request_handler.test.php
  30. +2 −2 cake/tests/cases/libs/controller/components/security.test.php
  31. +20 −0 cake/tests/cases/libs/controller/components/session.test.php
  32. +24 −2 cake/tests/cases/libs/controller/controller.test.php
  33. +28 −1 cake/tests/cases/libs/controller/pages_controller.test.php
  34. +2 −3 cake/tests/cases/libs/debugger.test.php
  35. +46 −42 cake/tests/cases/libs/error.test.php
  36. +1 −1 cake/tests/cases/libs/file.test.php
  37. +138 −2 cake/tests/cases/libs/folder.test.php
  38. +10 −0 cake/tests/cases/libs/i18n.test.php
  39. +10 −7 cake/tests/cases/libs/inflector.test.php
  40. +18 −1 cake/tests/cases/libs/model/behaviors/containable.test.php
  41. +1 −2 cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php
  42. +1 −2 cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
  43. +1 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
  44. +1 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
  45. +1 −3 cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php
  46. +1 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
  47. +1 −1 cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
  48. +43 −15 cake/tests/cases/libs/model/model.test.php
  49. +26 −5 cake/tests/cases/libs/model/models.php
  50. +1 −1 cake/tests/cases/libs/overloadable.test.php
  51. +5 −0 cake/tests/cases/libs/security.test.php
  52. +21 −0 cake/tests/cases/libs/session.test.php
  53. +5 −0 cake/tests/cases/libs/string.test.php
  54. +10 −0 cake/tests/cases/libs/validation.test.php
  55. +6 −0 cake/tests/cases/libs/view/helper.test.php
  56. +5 −0 cake/tests/cases/libs/view/helpers/ajax.test.php
  57. +79 −0 cake/tests/cases/libs/view/helpers/form.test.php
  58. +11 −0 cake/tests/cases/libs/view/helpers/html.test.php
  59. +14 −0 cake/tests/cases/libs/view/helpers/javascript.test.php
  60. +1 −1 cake/tests/cases/libs/view/helpers/js.test.php
  61. +69 −2 cake/tests/cases/libs/view/helpers/paginator.test.php
  62. +50 −0 cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php
  63. +49 −0 cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php
  64. +5 −5 cake/tests/groups/cache.group.php
  65. +5 −5 cake/tests/groups/components.group.php
  66. +4 −4 cake/tests/groups/console.group.php
  67. +4 −4 cake/tests/groups/{lib_controller.group.php → controller.group.php}
  68. +5 −5 cake/tests/groups/helpers.group.php
  69. +5 −5 cake/tests/groups/lib.group.php
  70. +71 −0 cake/tests/groups/no_cross_contamination.group.php
  71. +5 −5 cake/tests/groups/no_database.group.php
  72. +5 −5 cake/tests/groups/view.group.php
  73. +1 −1 cake/tests/groups/xml.group.php
  74. +110 −58 cake/tests/lib/cake_test_case.php
@@ -465,11 +465,11 @@ function bakeTest($className) {
$out .= "\tvar \$autoRender = false;\n}\n\n";
$out .= "class {$className}ControllerTest extends CakeTestCase {\n";
$out .= "\tvar \${$className} = null;\n\n";
- $out .= "\tfunction setUp() {\n\t\t\$this->{$className} = new Test{$className}();";
+ $out .= "\tfunction startTest() {\n\t\t\$this->{$className} = new Test{$className}();";
$out .= "\n\t\t\$this->{$className}->constructClasses();\n\t}\n\n";
$out .= "\tfunction test{$className}ControllerInstance() {\n";
$out .= "\t\t\$this->assertTrue(is_a(\$this->{$className}, '{$className}Controller'));\n\t}\n\n";
- $out .= "\tfunction tearDown() {\n\t\tunset(\$this->{$className});\n\t}\n}\n";
+ $out .= "\tfunction endTest() {\n\t\tunset(\$this->{$className});\n\t}\n}\n";
$path = CONTROLLER_TESTS;
if (isset($this->plugin)) {
@@ -524,6 +524,7 @@ function prefers($type = null) {
return $this->ext;
}
+ $types = $type;
if (is_string($type)) {
$types = array($type);
}
@@ -550,7 +551,11 @@ function prefers($type = null) {
return $accepts[0];
}
- $accepts = array_intersect($this->__acceptTypes, $accepts);
+ $acceptedTypes = array();
+ foreach ($this->__acceptTypes as $type) {
+ $acceptedTypes[] = $this->mapType($type);
+ }
+ $accepts = array_intersect($acceptedTypes, $accepts);
return $accepts[0];
}
/**
@@ -1026,6 +1026,14 @@ function paginate($object = null, $scope = array(), $whitelist = array()) {
if (!isset($defaults['conditions'])) {
$defaults['conditions'] = array();
}
+
+ $type = 'all';
+
+ if (isset($defaults[0])) {
+ $type = $defaults[0];
+ unset($defaults[0]);
+ }
+
extract($options = array_merge(array('page' => 1, 'limit' => 20), $defaults, $options));
if (is_array($scope) && !empty($scope)) {
@@ -1036,12 +1044,7 @@ function paginate($object = null, $scope = array(), $whitelist = array()) {
if ($recursive === null) {
$recursive = $object->recursive;
}
- $type = 'all';
- if (isset($defaults[0])) {
- $type = $defaults[0];
- unset($defaults[0]);
- }
$extra = array_diff_key($defaults, compact(
'conditions', 'fields', 'order', 'limit', 'page', 'recursive'
));
View
@@ -144,7 +144,8 @@ function log($var, $level = LOG_DEBUG) {
if (is_object($trace[0]['object']) && isset($trace[0]['object']->_reporter->_test_stack)) {
$stack = $trace[0]['object']->_reporter->_test_stack;
- $source = "[". $stack[0].", ". $stack[2] ."::" . $stack[3] ."()]\n";
+ $source = sprintf('[%1$s, %3$s::%2$s()]' . "\n",
+ array_shift($stack), array_pop($stack), array_pop($stack));
}
CakeLog::write($level, $source . $_this->exportVar($var));
@@ -1420,7 +1420,7 @@ function _prepareUpdateFields($data) {
return array();
}
$old = $this->find('first', array(
- 'conditions' => array('id' => $this->id),
+ 'conditions' => array($this->primaryKey => $this->id),
'fields' => array_values($included),
'recursive' => -1
));
View
@@ -510,7 +510,7 @@ function __initSession() {
array('Cache', 'read'),
array('Cache', 'write'),
array('Cache', 'delete'),
- array('CakeSession', '__gc'));
+ array('Cache', 'gc'));
break;
default:
if (empty($_SESSION)) {
View
@@ -237,6 +237,8 @@ function insert($str, $data, $options = array()) {
$str = substr_replace($str, $val, $pos, 1);
}
} else {
+ asort($data);
+
$hashKeys = array_map('md5', array_keys($data));
$tempData = array_combine(array_keys($data), array_values($hashKeys));
foreach ($tempData as $key => $hashVal) {
View
@@ -798,6 +798,7 @@ function ssn($check, $regex = null, $country = null) {
* an optional fragment (anchor tag)
*
* @param string $check Value to check
+ * @param boolean $strict Require URL to be prefixed by a valid scheme (one of http(s)/ftp(s)/file/news/gopher)
* @return boolean Success
* @access public
*/
@@ -925,4 +926,4 @@ function __reset() {
$this->errors = array();
}
}
-?>
+?>
@@ -81,7 +81,8 @@ class AjaxHelper extends AppHelper {
*/
var $dragOptions = array(
'handle', 'revert', 'snap', 'zindex', 'constraint', 'change', 'ghosting',
- 'starteffect', 'reverteffect', 'endeffect'
+ 'starteffect', 'reverteffect', 'endeffect', 'scroll', 'scrollSensitivity',
+ 'onStart', 'onDrag', 'onEnd'
);
/**
* Options for droppable.
@@ -852,11 +852,14 @@ function checkbox($fieldName, $options = array()) {
} elseif (!empty($value) && $value === $options['value']) {
$options['checked'] = 'checked';
}
-
- $output = $this->hidden($fieldName, array(
+ $hiddenOptions = array(
'id' => $options['id'] . '_', 'name' => $options['name'],
'value' => '0', 'secure' => false
- ));
+ );
+ if (isset($options['disabled'])) {
+ $hiddenOptions['disabled'] = 'disabled';
+ }
+ $output = $this->hidden($fieldName, $hiddenOptions);
return $this->output($output . sprintf(
$this->Html->tags['checkbox'],
@@ -935,7 +938,7 @@ function radio($fieldName, $options = array(), $attributes = array()) {
if (!isset($value) || $value === '') {
$hidden = $this->hidden($fieldName, array(
- 'id' => $attributes['id'] . '_', 'value' => ''
+ 'id' => $attributes['id'] . '_', 'value' => '', 'name' => $attributes['name']
));
}
$out = $hidden . join($inbetween, $out);
@@ -319,7 +319,7 @@ function escapeScript($script) {
* @return string Escaped string.
*/
function escapeString($string) {
- $escape = array("\r\n" => '\n', "\r" => '\n', "\n" => '\n', '"' => '\"', "'" => "\\'");
+ $escape = array('\n' => '\\\n', "\r\n" => '\n', "\r" => '\n', "\n" => '\n', '"' => '\"', "'" => "\\'");
return str_replace(array_keys($escape), array_values($escape), $string);
}
/**
@@ -222,8 +222,16 @@ function sort($title, $key = null, $options = array()) {
$title = __(Inflector::humanize(preg_replace('/_id$/', '', $title)), true);
}
$dir = 'asc';
+ $sortKey = $this->sortKey($options['model']);
+ $defaultModel = $this->defaultModel();
- if ($this->sortKey($options['model']) == $key && $this->sortDir($options['model']) == 'asc') {
+ if (strpos($sortKey, $defaultModel) !== false && strpos($key, $defaultModel) === false) {
+ $isSorted = ($sortKey === $defaultModel . '.' . $key);
+ } else {
+ $isSorted = ($sortKey === $key);
+ }
+
+ if ($isSorted && $this->sortDir($options['model']) === 'asc') {
$dir = 'desc';
}
if (is_array($title) && array_key_exists($dir, $title)) {
@@ -40,7 +40,19 @@ class BasicsTest extends CakeTestCase {
* @return void
*/
function setUp() {
+ $this->_localePaths = Configure::read('localePaths');
Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
+ $this->_language = Configure::read('Config.language');
+ }
+/**
+ * tearDown method
+ *
+ * @access public
+ * @return void
+ */
+ function tearDown() {
+ Configure::write('localePaths', $this->_localePaths);
+ Configure::write('Config.language', $this->_language);
}
/**
* testHttpBase method
@@ -119,7 +131,7 @@ function testEnv() {
* @return void
*/
function testUses() {
- $this->skipIf(class_exists('Security') || class_exists('Sanitize'), 'Security and/or Sanitize class already loaded');
+ $this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded');
$this->assertFalse(class_exists('Security'));
$this->assertFalse(class_exists('Sanitize'));
@@ -123,10 +123,9 @@ class ShellDispatcherTest extends UnitTestCase {
* @return void
*/
function setUp() {
- if (!isset($this->pluginPaths)) {
- $this->pluginPaths = Configure::read('pluginPaths');
- $this->shellPaths = Configure::read('shellPaths');
- }
+ $this->_pluginPaths = Configure::read('pluginPaths');
+ $this->_shellPaths = Configure::read('shellPaths');
+
Configure::write('pluginPaths', array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
));
@@ -142,8 +141,8 @@ function setUp() {
* @return void
*/
function tearDown() {
- Configure::write('pluginPaths', $this->pluginPaths);
- Configure::write('shellPaths', $this->shellPaths);
+ Configure::write('pluginPaths', $this->_pluginPaths);
+ Configure::write('shellPaths', $this->_shellPaths);
}
/**
* testParseParams method
@@ -78,7 +78,10 @@ class ShellTest extends CakeTestCase {
* @var array
* @access public
*/
- var $fixtures = array('core.post', 'core.comment');
+ var $fixtures = array(
+ 'core.post', 'core.comment', 'core.article', 'core.user',
+ 'core.tag', 'core.articles_tag', 'core.attachment'
+ );
/**
* setUp method
*
@@ -24,8 +24,13 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
-require_once CAKE.'dispatcher.php';
-App::import('Core', 'AppController');
+require_once CAKE . 'dispatcher.php';
+
+if (!class_exists('AppController')) {
+ require_once LIBS . 'controller' . DS . 'app_controller.php';
+} elseif (!defined('APP_CONTROLLER_EXISTS')){
+ define('APP_CONTROLLER_EXISTS', true);
+}
/**
* TestDispatcher class
*
@@ -491,11 +496,41 @@ class DispatcherTest extends CakeTestCase {
function setUp() {
$this->_get = $_GET;
$_GET = array();
+ $this->_post = $_POST;
+ $this->_files = $_FILES;
+ $this->_server = $_SERVER;
+
+ $this->_app = Configure::read('App');
Configure::write('App.base', false);
Configure::write('App.baseUrl', false);
Configure::write('App.dir', 'app');
Configure::write('App.webroot', 'webroot');
+
+ $this->_cache = Configure::read('Cache');
Configure::write('Cache.disable', true);
+
+ $this->_vendorPaths = Configure::read('vendorPaths');
+ $this->_pluginPaths = Configure::read('pluginPaths');
+ $this->_viewPaths = Configure::read('viewPaths');
+ $this->_debug = Configure::read('debug');
+ }
+/**
+ * tearDown method
+ *
+ * @access public
+ * @return void
+ */
+ function tearDown() {
+ $_GET = $this->_get;
+ $_POST = $this->_post;
+ $_FILES = $this->_files;
+ $_SERVER = $this->_server;
+ Configure::write('App', $this->_app);
+ Configure::write('Cache', $this->_cache);
+ Configure::write('vendorPaths', $this->_vendorPaths);
+ Configure::write('pluginPaths', $this->_pluginPaths);
+ Configure::write('viewPaths', $this->_viewPaths);
+ Configure::write('debug', $this->_debug);
}
/**
* tearDown method
@@ -626,8 +661,6 @@ function testQueryStringOnRoot() {
$this->assertTrue(isset($result['url']['sleep']));
$this->assertTrue(isset($result['url']['coffee']));
$this->assertEqual($result['url']['coffee'], 'life');
-
- $_GET = $this->_get;
}
/**
* testFileUploadArrayStructure method
@@ -854,8 +887,6 @@ function testFileUploadArrayStructure() {
)
);
$this->assertEqual($result['data'], $expected);
-
- $_FILES = array();
}
/**
* testGetUrl method
@@ -1614,6 +1645,7 @@ function testTestPluginDispatch() {
* @return void
*/
function testChangingParamsFromBeforeFilter() {
+ $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
$Dispatcher =& new TestDispatcher();
$url = 'some_posts/index/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
Oops, something went wrong.

0 comments on commit ec18aac

Please sign in to comment.