From c15259f49c0a268141eec84f779d8b7c611177f5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 17 Apr 2012 21:50:47 -0400 Subject: [PATCH 1/8] Remove useless backups. PHPUnit does this for us. Fix formatting and whitespace. --- .../Test/Case/Network/CakeRequestTest.php | 192 +++++++++--------- 1 file changed, 98 insertions(+), 94 deletions(-) diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 922342c40..4ca06914c 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -30,10 +30,6 @@ class CakeRequestTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $this->_server = $_SERVER; - $this->_get = $_GET; - $this->_post = $_POST; - $this->_files = $_FILES; $this->_app = Configure::read('App'); $this->_case = null; if (isset($_GET['case'])) { @@ -51,10 +47,6 @@ class CakeRequestTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - $_SERVER = $this->_server; - $_GET = $this->_get; - $_POST = $this->_post; - $_FILES = $this->_files; if (!empty($this->_case)) { $_GET['case'] = $this->_case; } @@ -217,94 +209,106 @@ class CakeRequestTest extends CakeTestCase { * * @return void */ - public function testFILESParsing() { - $_FILES = array('data' => array('name' => array( - 'File' => array( - array('data' => 'cake_sqlserver_patch.patch'), - array('data' => 'controller.diff'), - array('data' => ''), - array('data' => ''), + public function testFilesParsing() { + $_FILES = array( + 'data' => array( + 'name' => array( + 'File' => array( + array('data' => 'cake_sqlserver_patch.patch'), + array('data' => 'controller.diff'), + array('data' => ''), + array('data' => ''), + ), + 'Post' => array('attachment' => 'jquery-1.2.1.js'), + ), + 'type' => array( + 'File' => array( + array('data' => ''), + array('data' => ''), + array('data' => ''), + array('data' => ''), + ), + 'Post' => array('attachment' => 'application/x-javascript'), ), - 'Post' => array('attachment' => 'jquery-1.2.1.js'), - ), - 'type' => array( - 'File' => array( - array('data' => ''), - array('data' => ''), - array('data' => ''), - array('data' => ''), + 'tmp_name' => array( + 'File' => array( + array('data' => '/private/var/tmp/phpy05Ywj'), + array('data' => '/private/var/tmp/php7MBztY'), + array('data' => ''), + array('data' => ''), + ), + 'Post' => array('attachment' => '/private/var/tmp/phpEwlrIo'), ), - 'Post' => array('attachment' => 'application/x-javascript'), - ), - 'tmp_name' => array( - 'File' => array( - array('data' => '/private/var/tmp/phpy05Ywj'), - array('data' => '/private/var/tmp/php7MBztY'), - array('data' => ''), - array('data' => ''), + 'error' => array( + 'File' => array( + array('data' => 0), + array('data' => 0), + array('data' => 4), + array('data' => 4) + ), + 'Post' => array('attachment' => 0) ), - 'Post' => array('attachment' => '/private/var/tmp/phpEwlrIo'), - ), - 'error' => array( - 'File' => array( - array('data' => 0), - array('data' => 0), - array('data' => 4), - array('data' => 4) + 'size' => array( + 'File' => array( + array('data' => 6271), + array('data' => 350), + array('data' => 0), + array('data' => 0), + ), + 'Post' => array('attachment' => 80469) ), - 'Post' => array('attachment' => 0) - ), - 'size' => array( - 'File' => array( - array('data' => 6271), - array('data' => 350), - array('data' => 0), - array('data' => 0), - ), - 'Post' => array('attachment' => 80469) - ), - )); + ) + ); $request = new CakeRequest('some/path'); $expected = array( 'File' => array( - array('data' => array( - 'name' => 'cake_sqlserver_patch.patch', - 'type' => '', - 'tmp_name' => '/private/var/tmp/phpy05Ywj', - 'error' => 0, - 'size' => 6271, - )), array( 'data' => array( - 'name' => 'controller.diff', - 'type' => '', - 'tmp_name' => '/private/var/tmp/php7MBztY', - 'error' => 0, - 'size' => 350, - )), - array('data' => array( - 'name' => '', - 'type' => '', - 'tmp_name' => '', - 'error' => 4, - 'size' => 0, - )), - array('data' => array( - 'name' => '', - 'type' => '', - 'tmp_name' => '', - 'error' => 4, - 'size' => 0, - )), + 'name' => 'cake_sqlserver_patch.patch', + 'type' => '', + 'tmp_name' => '/private/var/tmp/phpy05Ywj', + 'error' => 0, + 'size' => 6271, + ) + ), + array( + 'data' => array( + 'name' => 'controller.diff', + 'type' => '', + 'tmp_name' => '/private/var/tmp/php7MBztY', + 'error' => 0, + 'size' => 350, + ) + ), + array( + 'data' => array( + 'name' => '', + 'type' => '', + 'tmp_name' => '', + 'error' => 4, + 'size' => 0, + ) + ), + array( + 'data' => array( + 'name' => '', + 'type' => '', + 'tmp_name' => '', + 'error' => 4, + 'size' => 0, + ) + ), ), - 'Post' => array('attachment' => array( - 'name' => 'jquery-1.2.1.js', - 'type' => 'application/x-javascript', - 'tmp_name' => '/private/var/tmp/phpEwlrIo', - 'error' => 0, - 'size' => 80469, - )) + 'Post' => array( + 'attachment' => array( + 'name' => 'jquery-1.2.1.js', + 'type' => 'application/x-javascript', + 'tmp_name' => '/private/var/tmp/phpEwlrIo', + 'error' => 0, + 'size' => 80469, + ) + ) ); $this->assertEquals($expected, $request->data); @@ -343,12 +347,12 @@ class CakeRequestTest extends CakeTestCase { 1 => array( 'birth_cert' => '/private/var/tmp/phpbsUWfH', 'passport' => '/private/var/tmp/php7f5zLt', - 'drivers_license' => '/private/var/tmp/phpMXpZgT', + 'drivers_license' => '/private/var/tmp/phpMXpZgT', ), 2 => array( 'birth_cert' => '/private/var/tmp/php5kHZt0', - 'passport' => '/private/var/tmp/phpnYkOuM', - 'drivers_license' => '/private/var/tmp/php9Rq0P3', + 'passport' => '/private/var/tmp/phpnYkOuM', + 'drivers_license' => '/private/var/tmp/php9Rq0P3', ) ) ), @@ -357,12 +361,12 @@ class CakeRequestTest extends CakeTestCase { 1 => array( 'birth_cert' => 0, 'passport' => 0, - 'drivers_license' => 0, + 'drivers_license' => 0, ), 2 => array( 'birth_cert' => 0, - 'passport' => 0, - 'drivers_license' => 0, + 'passport' => 0, + 'drivers_license' => 0, ) ) ), @@ -371,12 +375,12 @@ class CakeRequestTest extends CakeTestCase { 1 => array( 'birth_cert' => 123, 'passport' => 458, - 'drivers_license' => 875, + 'drivers_license' => 875, ), 2 => array( 'birth_cert' => 876, - 'passport' => 976, - 'drivers_license' => 9783, + 'passport' => 976, + 'drivers_license' => 9783, ) ) ) From b54c3b030878e95fd706bcc0b19ddde0f238ff88 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 17 Apr 2012 22:28:08 -0400 Subject: [PATCH 2/8] Convert FILES processing to use recursion. Fixes issues with deeply nested file data issues. Fixes #2796 --- lib/Cake/Network/CakeRequest.php | 40 ++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 977261ef9..e665db301 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -320,21 +320,31 @@ class CakeRequest implements ArrayAccess { if (isset($_FILES['data'])) { foreach ($_FILES['data'] as $key => $data) { - foreach ($data as $model => $fields) { - if (is_array($fields)) { - foreach ($fields as $field => $value) { - if (is_array($value)) { - foreach ($value as $k => $v) { - $this->data[$model][$field][$k][$key] = $v; - } - } else { - $this->data[$model][$field][$key] = $value; - } - } - } else { - $this->data[$model][$key] = $fields; - } - } + $this->_processFileData('', $data, $key); + } + } + } + +/** + * Recursively walks the FILES array restructuring the data + * into something sane and useable. + * + * @param string $path The dot separated path to insert $data into. + * @param array $data The data to traverse/insert. + * @param string $field The terminal field name, which is the top level key in $_FILES. + * @return void + */ + protected function _processFileData($path, $data, $field) { + foreach ($data as $key => $fields) { + $newPath = $key; + if (!empty($path)) { + $newPath = $path . '.' . $key; + } + if (is_array($fields)) { + $this->_processFileData($newPath, $fields, $field); + } else { + $newPath .= '.' . $field; + $this->data = Set::insert($this->data, $newPath, $fields); } } } From c49da62c233f0f20334b11cd60086811e67abda3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 18 Apr 2012 22:23:18 -0400 Subject: [PATCH 3/8] Update content_for_layout to use fetch() Fixes #2803 --- app/View/Layouts/ajax.ctp | 2 +- app/View/Layouts/js/default.ctp | 2 +- app/View/Layouts/rss/default.ctp | 4 ++-- app/View/Layouts/xml/default.ctp | 2 +- .../Templates/skel/View/Layouts/Emails/html/default.ctp | 4 ++-- .../Templates/skel/View/Layouts/Emails/text/default.ctp | 2 +- lib/Cake/Console/Templates/skel/View/Layouts/ajax.ctp | 2 +- lib/Cake/Console/Templates/skel/View/Layouts/js/default.ctp | 2 +- lib/Cake/Console/Templates/skel/View/Layouts/rss/default.ctp | 4 ++-- lib/Cake/Console/Templates/skel/View/Layouts/xml/default.ctp | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/View/Layouts/ajax.ctp b/app/View/Layouts/ajax.ctp index c0ca27058..c0da8502a 100644 --- a/app/View/Layouts/ajax.ctp +++ b/app/View/Layouts/ajax.ctp @@ -16,4 +16,4 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - \ No newline at end of file +fetch('content'); ?> diff --git a/app/View/Layouts/js/default.ctp b/app/View/Layouts/js/default.ctp index d94dc903a..7239b5dae 100644 --- a/app/View/Layouts/js/default.ctp +++ b/app/View/Layouts/js/default.ctp @@ -1,2 +1,2 @@ - \ No newline at end of file + diff --git a/app/View/Layouts/rss/default.ctp b/app/View/Layouts/rss/default.ctp index 2b8e9d434..077de6125 100644 --- a/app/View/Layouts/rss/default.ctp +++ b/app/View/Layouts/rss/default.ctp @@ -8,7 +8,7 @@ if (!isset($channel['title'])) { echo $this->Rss->document( $this->Rss->channel( - array(), $channel, $content_for_layout + array(), $channel, $this->fetch('content') ) ); -?> \ No newline at end of file +?> diff --git a/app/View/Layouts/xml/default.ctp b/app/View/Layouts/xml/default.ctp index 27f20316b..fbd5ee0c3 100644 --- a/app/View/Layouts/xml/default.ctp +++ b/app/View/Layouts/xml/default.ctp @@ -1 +1 @@ - +fetch('content'); ?> diff --git a/lib/Cake/Console/Templates/skel/View/Layouts/Emails/html/default.ctp b/lib/Cake/Console/Templates/skel/View/Layouts/Emails/html/default.ctp index 0df9def85..a1cc8369c 100644 --- a/lib/Cake/Console/Templates/skel/View/Layouts/Emails/html/default.ctp +++ b/lib/Cake/Console/Templates/skel/View/Layouts/Emails/html/default.ctp @@ -24,8 +24,8 @@ - + fetch('content');?>

This email was sent using the CakePHP Framework

- \ No newline at end of file + diff --git a/lib/Cake/Console/Templates/skel/View/Layouts/Emails/text/default.ctp b/lib/Cake/Console/Templates/skel/View/Layouts/Emails/text/default.ctp index ba3086ad9..0a25fb93d 100644 --- a/lib/Cake/Console/Templates/skel/View/Layouts/Emails/text/default.ctp +++ b/lib/Cake/Console/Templates/skel/View/Layouts/Emails/text/default.ctp @@ -17,6 +17,6 @@ */ ?> - +fetch('content');?> This email was sent using the CakePHP Framework, http://cakephp.org. diff --git a/lib/Cake/Console/Templates/skel/View/Layouts/ajax.ctp b/lib/Cake/Console/Templates/skel/View/Layouts/ajax.ctp index 9475d5f7d..9dc5ee58e 100644 --- a/lib/Cake/Console/Templates/skel/View/Layouts/ajax.ctp +++ b/lib/Cake/Console/Templates/skel/View/Layouts/ajax.ctp @@ -16,4 +16,4 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - \ No newline at end of file +fetch('content'); ?> diff --git a/lib/Cake/Console/Templates/skel/View/Layouts/js/default.ctp b/lib/Cake/Console/Templates/skel/View/Layouts/js/default.ctp index d94dc903a..7239b5dae 100644 --- a/lib/Cake/Console/Templates/skel/View/Layouts/js/default.ctp +++ b/lib/Cake/Console/Templates/skel/View/Layouts/js/default.ctp @@ -1,2 +1,2 @@ - \ No newline at end of file + diff --git a/lib/Cake/Console/Templates/skel/View/Layouts/rss/default.ctp b/lib/Cake/Console/Templates/skel/View/Layouts/rss/default.ctp index 2b8e9d434..077de6125 100644 --- a/lib/Cake/Console/Templates/skel/View/Layouts/rss/default.ctp +++ b/lib/Cake/Console/Templates/skel/View/Layouts/rss/default.ctp @@ -8,7 +8,7 @@ if (!isset($channel['title'])) { echo $this->Rss->document( $this->Rss->channel( - array(), $channel, $content_for_layout + array(), $channel, $this->fetch('content') ) ); -?> \ No newline at end of file +?> diff --git a/lib/Cake/Console/Templates/skel/View/Layouts/xml/default.ctp b/lib/Cake/Console/Templates/skel/View/Layouts/xml/default.ctp index 27f20316b..fbd5ee0c3 100644 --- a/lib/Cake/Console/Templates/skel/View/Layouts/xml/default.ctp +++ b/lib/Cake/Console/Templates/skel/View/Layouts/xml/default.ctp @@ -1 +1 @@ - +fetch('content'); ?> From dec67ef2599e9985cc923b7f5cd81f55685db751 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 18 Apr 2012 22:45:55 -0400 Subject: [PATCH 4/8] Add proper charset to web test runner. Fixes #2804 --- lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php index 98ff96146..9c59d03cc 100644 --- a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php @@ -33,12 +33,24 @@ class CakeHtmlReporter extends CakeBaseReporter { */ public function paintHeader() { $this->_headerSent = true; + $this->sendContentType(); $this->sendNoCacheHeaders(); $this->paintDocumentStart(); $this->paintTestMenu(); echo "
    \n"; } +/** + * Set the content-type header so it is in the correct encoding. + * + * @return void + */ + public function sendContentType() { + if (!headers_sent()) { + header('Content-Type: text/html; charset=' . Configure::read('App.encoding')); + } + } + /** * Paints the document start content contained in header.php * From f0bd7386e22e8d0d08b0e146b76f03aa997f3c68 Mon Sep 17 00:00:00 2001 From: Ceeram Date: Wed, 28 Mar 2012 17:49:41 +0200 Subject: [PATCH 5/8] created, modified and updated fields now use static timestamp in testcases --- lib/Cake/Model/Model.php | 2 +- .../Component/Auth/FormAuthenticateTest.php | 3 +- .../Test/Case/Model/ModelIntegrationTest.php | 3 +- lib/Cake/Test/Case/Model/ModelWriteTest.php | 161 ++++++++---------- lib/Cake/TestSuite/CakeTestCase.php | 10 ++ .../TestSuite/CakeTestSuiteDispatcher.php | 26 +++ lib/Cake/TestSuite/Fixture/CakeTestModel.php | 15 +- 7 files changed, 124 insertions(+), 96 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 422b86976..aeebf3ea0 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1629,7 +1629,7 @@ class Model extends Object implements CakeEventListener { if (!array_key_exists('format', $colType)) { $time = strtotime('now'); } else { - $time = $colType['formatter']($colType['format']); + $time = call_user_func($colType['formatter'], $colType['format']); } if (!empty($this->whitelist)) { $this->whitelist[] = $updateCol; diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php index 09097d4b7..a65e04f28 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php @@ -163,7 +163,6 @@ class FormAuthenticateTest extends CakeTestCase { ), App::RESET); CakePlugin::load('TestPlugin'); - $ts = date('Y-m-d H:i:s'); $PluginModel = ClassRegistry::init('TestPlugin.TestPluginAuthUser'); $user['id'] = 1; $user['username'] = 'gwoo'; @@ -185,7 +184,7 @@ class FormAuthenticateTest extends CakeTestCase { 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23' ); - $this->assertTrue($result['updated'] >= $ts); + $this->assertEquals(self::date(), $result['updated']); unset($result['updated']); $this->assertEquals($expected, $result); CakePlugin::unload(); diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index 05afa857a..180e1aeac 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -1867,7 +1867,6 @@ class ModelIntegrationTest extends BaseModelTest { 'doomed' => true )))); - $ts = date('Y-m-d H:i:s'); $TestModel->save(); $TestModel->hasAndBelongsToMany['SomethingElse']['order'] = 'SomethingElse.id ASC'; @@ -1921,7 +1920,7 @@ class ModelIntegrationTest extends BaseModelTest { ) ) ); - $this->assertTrue($result['Something']['updated'] >= $ts); + $this->assertEquals(self::date(), $result['Something']['updated']); unset($result['Something']['updated']); $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index c06c964d9..ff51b5f6f 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -1613,7 +1613,6 @@ class ModelWriteTest extends BaseModelTest { ); $this->assertEquals($expected, $result); - $ts = date('Y-m-d H:i:s'); $TestModel->id = 2; $data = array('Tag' => array('Tag' => array(2))); $TestModel->save($data); @@ -1627,7 +1626,7 @@ class ModelWriteTest extends BaseModelTest { 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', - 'updated' => $ts + 'updated' => self::date() ), 'Tag' => array( array( @@ -2562,29 +2561,28 @@ class ModelWriteTest extends BaseModelTest { $this->assertEquals($expected, $result); - $ts = date('Y-m-d H:i:s'); $TestModel->id = 1; $data = array( 'JoinA' => array( 'id' => '1', 'name' => 'New name for Join A 1', - 'updated' => $ts + 'updated' => self::date() ), 'JoinB' => array( array( 'id' => 1, 'join_b_id' => 2, 'other' => 'New data for Join A 1 Join B 2', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() )), 'JoinC' => array( array( 'id' => 1, 'join_c_id' => 2, 'other' => 'New data for Join A 1 Join C 2', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() ))); $TestModel->set($data); @@ -2597,7 +2595,7 @@ class ModelWriteTest extends BaseModelTest { 'name' => 'New name for Join A 1', 'body' => 'Join A 1 Body', 'created' => '2008-01-03 10:54:23', - 'updated' => $ts + 'updated' => self::date() ), 'JoinB' => array( 0 => array( @@ -2610,8 +2608,8 @@ class ModelWriteTest extends BaseModelTest { 'join_a_id' => 1, 'join_b_id' => 2, 'other' => 'New data for Join A 1 Join B 2', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() ))), 'JoinC' => array( 0 => array( @@ -2624,8 +2622,8 @@ class ModelWriteTest extends BaseModelTest { 'join_a_id' => 1, 'join_c_id' => 2, 'other' => 'New data for Join A 1 Join C 2', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() )))); $this->assertEquals($expected, $result); @@ -2643,7 +2641,6 @@ class ModelWriteTest extends BaseModelTest { $result = $TestModel->find('all'); $this->assertEquals(3, count($result)); $this->assertFalse(isset($result[3])); - $ts = date('Y-m-d H:i:s'); $TestModel->saveAll(array( 'Post' => array( @@ -2670,10 +2667,10 @@ class ModelWriteTest extends BaseModelTest { 'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'test' => 'working' )); - $this->assertTrue($result[3]['Post']['created'] >= $ts); - $this->assertTrue($result[3]['Post']['updated'] >= $ts); - $this->assertTrue($result[3]['Author']['created'] >= $ts); - $this->assertTrue($result[3]['Author']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[3]['Post']['created']); + $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(self::date(), $result[3]['Author']['created']); + $this->assertEquals(self::date(), $result[3]['Author']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[3]['Author']['created'], $result[3]['Author']['updated']); $this->assertEquals($expected, $result[3]); @@ -2685,7 +2682,6 @@ class ModelWriteTest extends BaseModelTest { // SQLite seems to reset the PK counter when that happens, so we need this to make the tests pass $this->db->truncate($TestModel); - $ts = date('Y-m-d H:i:s'); $TestModel->saveAll(array( array( 'title' => 'Multi-record post 1', @@ -2719,16 +2715,15 @@ class ModelWriteTest extends BaseModelTest { 'body' => 'Second multi-record post', 'published' => 'N' ))); - $this->assertTrue($result[0]['Post']['created'] >= $ts); - $this->assertTrue($result[0]['Post']['updated'] >= $ts); - $this->assertTrue($result[1]['Post']['created'] >= $ts); - $this->assertTrue($result[1]['Post']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[0]['Post']['created']); + $this->assertEquals(self::date(), $result[0]['Post']['updated']); + $this->assertEquals(self::date(), $result[1]['Post']['created']); + $this->assertEquals(self::date(), $result[1]['Post']['updated']); unset($result[0]['Post']['created'], $result[0]['Post']['updated']); unset($result[1]['Post']['created'], $result[1]['Post']['updated']); $this->assertEquals($expected, $result); $TestModel = new Comment(); - $ts = date('Y-m-d H:i:s'); $result = $TestModel->saveAll(array( 'Comment' => array( 'article_id' => 2, @@ -2749,8 +2744,8 @@ class ModelWriteTest extends BaseModelTest { 'comment' => 'New comment with attachment', 'published' => 'Y' ); - $this->assertTrue($result[6]['Comment']['created'] >= $ts); - $this->assertTrue($result[6]['Comment']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[6]['Comment']['created']); + $this->assertEquals(self::date(), $result[6]['Comment']['updated']); unset($result[6]['Comment']['created'], $result[6]['Comment']['updated']); $this->assertEquals($expected, $result[6]['Comment']); @@ -2759,8 +2754,8 @@ class ModelWriteTest extends BaseModelTest { 'comment_id' => '7', 'attachment' => 'some_file.tgz' ); - $this->assertTrue($result[6]['Attachment']['created'] >= $ts); - $this->assertTrue($result[6]['Attachment']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[6]['Attachment']['created']); + $this->assertEquals(self::date(), $result[6]['Attachment']['updated']); unset($result[6]['Attachment']['created'], $result[6]['Attachment']['updated']); $this->assertEquals($expected, $result[6]['Attachment']); } @@ -4057,7 +4052,6 @@ class ModelWriteTest extends BaseModelTest { array('author_id' => 1, 'title' => 'New Fifth Post'), array('author_id' => 1, 'title' => '') ); - $ts = date('Y-m-d H:i:s'); $this->assertFalse($TestModel->saveAll($data)); $result = $TestModel->find('all', array('recursive' => -1)); @@ -4099,8 +4093,8 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'New Fourth Post', 'body' => null, 'published' => 'N', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() )); $expected[] = array( @@ -4110,8 +4104,8 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'New Fifth Post', 'body' => null, 'published' => 'N', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() )); $this->assertEquals($expected, $result); @@ -4126,7 +4120,6 @@ class ModelWriteTest extends BaseModelTest { array('author_id' => 1, 'title' => ''), array('author_id' => 1, 'title' => 'New Sixth Post') ); - $ts = date('Y-m-d H:i:s'); $this->assertFalse($TestModel->saveAll($data)); $result = $TestModel->find('all', array('recursive' => -1)); @@ -4168,8 +4161,8 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'New Fourth Post', 'body' => 'Third Post Body', 'published' => 'N', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() )); $expected[] = array( @@ -4179,8 +4172,8 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'N', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() )); } $this->assertEquals($expected, $result); @@ -4265,7 +4258,6 @@ class ModelWriteTest extends BaseModelTest { 'author_id' => 2 )); - $ts = date('Y-m-d H:i:s'); $this->assertTrue($TestModel->saveAll($data)); $result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC')); @@ -4306,10 +4298,10 @@ class ModelWriteTest extends BaseModelTest { 'body' => 'Fourth post body', 'published' => 'N' ))); - $this->assertTrue($result[0]['Post']['updated'] >= $ts); - $this->assertTrue($result[1]['Post']['updated'] >= $ts); - $this->assertTrue($result[3]['Post']['created'] >= $ts); - $this->assertTrue($result[3]['Post']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[0]['Post']['updated']); + $this->assertEquals(self::date(), $result[1]['Post']['updated']); + $this->assertEquals(self::date(), $result[3]['Post']['created']); + $this->assertEquals(self::date(), $result[3]['Post']['updated']); unset($result[0]['Post']['updated'], $result[1]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); @@ -4400,10 +4392,10 @@ class ModelWriteTest extends BaseModelTest { ) ); - $this->assertTrue($result[0]['Post']['updated'] >= $ts); - $this->assertTrue($result[1]['Post']['updated'] >= $ts); - $this->assertTrue($result[3]['Post']['updated'] >= $ts); - $this->assertTrue($result[3]['Post']['created'] >= $ts); + $this->assertEquals(self::date(), $result[0]['Post']['updated']); + $this->assertEquals(self::date(), $result[1]['Post']['updated']); + $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(self::date(), $result[3]['Post']['created']); unset( $result[0]['Post']['updated'], $result[1]['Post']['updated'], $result[3]['Post']['updated'], $result[3]['Post']['created'] @@ -4731,7 +4723,6 @@ class ModelWriteTest extends BaseModelTest { $result = $TestModel->find('all'); $this->assertEquals(3, count($result)); $this->assertFalse(isset($result[3])); - $ts = date('Y-m-d H:i:s'); $TestModel->saveAssociated(array( 'Post' => array( @@ -4758,10 +4749,10 @@ class ModelWriteTest extends BaseModelTest { 'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'test' => 'working' )); - $this->assertTrue($result[3]['Post']['updated'] >= $ts); - $this->assertTrue($result[3]['Post']['created'] >= $ts); - $this->assertTrue($result[3]['Author']['created'] >= $ts); - $this->assertTrue($result[3]['Author']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(self::date(), $result[3]['Post']['created']); + $this->assertEquals(self::date(), $result[3]['Author']['created']); + $this->assertEquals(self::date(), $result[3]['Author']['updated']); unset( $result[3]['Post']['updated'], $result[3]['Post']['created'], $result[3]['Author']['updated'], $result[3]['Author']['created'] @@ -4769,10 +4760,7 @@ class ModelWriteTest extends BaseModelTest { $this->assertEquals($expected, $result[3]); $this->assertEquals(4, count($result)); - $ts = date('Y-m-d H:i:s'); - $TestModel = new Comment(); - $ts = date('Y-m-d H:i:s'); $result = $TestModel->saveAssociated(array( 'Comment' => array( 'article_id' => 2, @@ -4793,8 +4781,8 @@ class ModelWriteTest extends BaseModelTest { 'comment' => 'New comment with attachment', 'published' => 'Y' ); - $this->assertTrue($result[6]['Comment']['updated'] >= $ts); - $this->assertTrue($result[6]['Comment']['created'] >= $ts); + $this->assertEquals(self::date(), $result[6]['Comment']['updated']); + $this->assertEquals(self::date(), $result[6]['Comment']['created']); unset($result[6]['Comment']['updated'], $result[6]['Comment']['created']); $this->assertEquals($expected, $result[6]['Comment']); @@ -4803,8 +4791,8 @@ class ModelWriteTest extends BaseModelTest { 'comment_id' => '7', 'attachment' => 'some_file.tgz' ); - $this->assertTrue($result[6]['Attachment']['updated'] >= $ts); - $this->assertTrue($result[6]['Attachment']['created'] >= $ts); + $this->assertEquals(self::date(), $result[6]['Attachment']['updated']); + $this->assertEquals(self::date(), $result[6]['Attachment']['created']); unset($result[6]['Attachment']['updated'], $result[6]['Attachment']['created']); $this->assertEquals($expected, $result[6]['Attachment']); } @@ -4823,7 +4811,6 @@ class ModelWriteTest extends BaseModelTest { // SQLite seems to reset the PK counter when that happens, so we need this to make the tests pass $this->db->truncate($TestModel); - $ts = date('Y-m-d H:i:s'); $TestModel->saveMany(array( array( 'title' => 'Multi-record post 1', @@ -4860,10 +4847,10 @@ class ModelWriteTest extends BaseModelTest { ) ) ); - $this->assertTrue($result[0]['Post']['updated'] >= $ts); - $this->assertTrue($result[0]['Post']['created'] >= $ts); - $this->assertTrue($result[1]['Post']['updated'] >= $ts); - $this->assertTrue($result[1]['Post']['created'] >= $ts); + $this->assertEquals(self::date(), $result[0]['Post']['updated']); + $this->assertEquals(self::date(), $result[0]['Post']['created']); + $this->assertEquals(self::date(), $result[1]['Post']['updated']); + $this->assertEquals(self::date(), $result[1]['Post']['created']); unset($result[0]['Post']['updated'], $result[0]['Post']['created']); unset($result[1]['Post']['updated'], $result[1]['Post']['created']); $this->assertEquals($expected, $result); @@ -5415,7 +5402,6 @@ class ModelWriteTest extends BaseModelTest { array('author_id' => 1, 'title' => 'New Fifth Post'), array('author_id' => 1, 'title' => '') ); - $ts = date('Y-m-d H:i:s'); $this->assertFalse($TestModel->saveMany($data)); $result = $TestModel->find('all', array('recursive' => -1)); @@ -5468,10 +5454,10 @@ class ModelWriteTest extends BaseModelTest { 'published' => 'N', )); - $this->assertTrue($result[3]['Post']['created'] >= $ts); - $this->assertTrue($result[3]['Post']['updated'] >= $ts); - $this->assertTrue($result[4]['Post']['created'] >= $ts); - $this->assertTrue($result[4]['Post']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[3]['Post']['created']); + $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(self::date(), $result[4]['Post']['created']); + $this->assertEquals(self::date(), $result[4]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[4]['Post']['created'], $result[4]['Post']['updated']); $this->assertEquals($expected, $result); @@ -5486,7 +5472,6 @@ class ModelWriteTest extends BaseModelTest { array('author_id' => 1, 'title' => ''), array('author_id' => 1, 'title' => 'New Sixth Post') ); - $ts = date('Y-m-d H:i:s'); $this->assertFalse($TestModel->saveMany($data)); $result = $TestModel->find('all', array('recursive' => -1)); @@ -5538,10 +5523,10 @@ class ModelWriteTest extends BaseModelTest { 'body' => 'Third Post Body', 'published' => 'N' )); - $this->assertTrue($result[3]['Post']['created'] >= $ts); - $this->assertTrue($result[3]['Post']['updated'] >= $ts); - $this->assertTrue($result[4]['Post']['created'] >= $ts); - $this->assertTrue($result[4]['Post']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[3]['Post']['created']); + $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(self::date(), $result[4]['Post']['created']); + $this->assertEquals(self::date(), $result[4]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[4]['Post']['created'], $result[4]['Post']['updated']); } @@ -5610,7 +5595,6 @@ class ModelWriteTest extends BaseModelTest { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment'); $TestModel = new Post(); - $ts = date('Y-m-d H:i:s'); $data = array( array( 'id' => '1', @@ -5673,10 +5657,10 @@ class ModelWriteTest extends BaseModelTest { ) ); - $this->assertTrue($result[0]['Post']['updated'] >= $ts); - $this->assertTrue($result[1]['Post']['updated'] >= $ts); - $this->assertTrue($result[3]['Post']['created'] >= $ts); - $this->assertTrue($result[3]['Post']['updated'] >= $ts); + $this->assertEquals(self::date(), $result[0]['Post']['updated']); + $this->assertEquals(self::date(), $result[1]['Post']['updated']); + $this->assertEquals(self::date(), $result[3]['Post']['created']); + $this->assertEquals(self::date(), $result[3]['Post']['updated']); unset($result[0]['Post']['updated'], $result[1]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); @@ -6373,7 +6357,6 @@ class ModelWriteTest extends BaseModelTest { $result = $TestModel->find('all'); $this->assertCount(3, $result); $this->assertFalse(isset($result[3])); - $ts = date('Y-m-d H:i:s'); // test belongsTo $fieldList = array( @@ -6399,15 +6382,15 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'Post without body', 'body' => null, 'published' => 'N', - 'created' => $ts, - 'updated' => $ts, + 'created' => self::date(), + 'updated' => self::date(), ), 'Author' => array ( 'id' => '5', 'user' => 'bob', 'password' => null, - 'created' => $ts, - 'updated' => $ts, + 'created' => self::date(), + 'updated' => self::date(), 'test' => 'working', ), ); @@ -6419,7 +6402,6 @@ class ModelWriteTest extends BaseModelTest { // test multirecord $this->db->truncate($TestModel); - $ts = date('Y-m-d H:i:s'); $fieldList = array('title', 'author_id'); $TestModel->saveAll(array( array( @@ -6445,8 +6427,8 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'Multi-record post 1', 'body' => '', 'published' => 'N', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() ) ), array( @@ -6456,8 +6438,8 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'Multi-record post 2', 'body' => '', 'published' => 'N', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() ) ) ); @@ -6545,7 +6527,6 @@ class ModelWriteTest extends BaseModelTest { $result = $TestModel->find('all'); $this->assertCount(3, $result); $this->assertFalse(isset($result[3])); - $ts = date('Y-m-d H:i:s'); // test belongsTo $fieldList = array( diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 6ef53e3fc..5b62b6b45 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -152,6 +152,16 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { } } +/** + * See CakeTestSuiteDispatcher::date() + * + * @param string $format format to be used. + * @return string + */ + public static function date($format = 'Y-m-d H:i:s') { + return CakeTestSuiteDispatcher::date($format); + } + // @codingStandardsIgnoreStart PHPUnit overrides don't match CakePHP /** diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 29b65bfbd..31267b573 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -247,6 +247,7 @@ class CakeTestSuiteDispatcher { restore_error_handler(); try { + self::time(); $command = new CakeTestSuiteCommand('CakeTestLoader', $commandArgs); $result = $command->run($options); } catch (MissingConnectionException $exception) { @@ -257,4 +258,29 @@ class CakeTestSuiteDispatcher { } } +/** + * Sets a static timestamp + * + * @param boolean $reset to set new static timestamp. + * @return integer timestamp + */ + public static function time($reset = false) { + static $now; + if ($reset || !$now) { + $now = time(); + } + return $now; + } + +/** + * Returns formatted date string using static time + * This method is being used as formatter for created, modified and updated fields in Model::save() + * + * @param string $format format to be used. + * @return string formatted date + */ + public static function date($format) { + return date($format, self::time()); + } + } diff --git a/lib/Cake/TestSuite/Fixture/CakeTestModel.php b/lib/Cake/TestSuite/Fixture/CakeTestModel.php index dfd8a2bf3..b2a833570 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestModel.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestModel.php @@ -53,5 +53,18 @@ class CakeTestModel extends Model { } return $queryData; } +/** + * Overriding save() to set CakeTestSuiteDispatcher::date() as formatter for created, modified and updated fields + * + * @param array $data + * @param mixed $validate + * @param array $fieldList + */ -} + public function save($data = null, $validate = true, $fieldList = array()) { + $db = $this->getDataSource(); + $db->columns['datetime']['formatter'] = 'CakeTestSuiteDispatcher::date'; + return parent::save($data, $validate, $fieldList); + } + +} \ No newline at end of file From 88465cbb4780d853e1acd67bb242602aefbf99b5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Apr 2012 21:17:12 -0400 Subject: [PATCH 6/8] Remove copy + paste in tests. --- .../Test/Case/View/Helper/HtmlHelperTest.php | 54 ------------------- 1 file changed, 54 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php index 922ab36a0..5ad9a926b 100644 --- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php @@ -1263,33 +1263,6 @@ class HtmlHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $result = $this->Html->nestedList($list, null); - $expected = array( - 'assertTags($result, $expected); $result = $this->Html->nestedList($list, array(), array(), 'ol'); @@ -1323,33 +1296,6 @@ class HtmlHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $result = $this->Html->nestedList($list, 'ol'); - $expected = array( - 'assertTags($result, $expected); $result = $this->Html->nestedList($list, array('class' => 'list')); From 7846254c632e90cba2a4ac2c0a1065326be17848 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Apr 2012 21:31:24 -0400 Subject: [PATCH 7/8] Remove more copy + paste in tests. --- .../Test/Case/View/Helper/FormHelperTest.php | 122 +----------------- 1 file changed, 2 insertions(+), 120 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index e6dc9e344..c34ec4a99 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -4727,84 +4727,12 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); $this->assertNotRegExp('/]+value=""[^<>]+selected="selected"[^>]*>/', $result); - + $result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('value' => false)); - $expected = array( - array('select' => array('name' => 'data[Contact][date][day]', 'id' => 'ContactDateDay')), - $daysRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - '-', - array('select' => array('name' => 'data[Contact][date][month]', 'id' => 'ContactDateMonth')), - $monthsRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - '-', - array('select' => array('name' => 'data[Contact][date][year]', 'id' => 'ContactDateYear')), - $yearsRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - array('select' => array('name' => 'data[Contact][date][hour]', 'id' => 'ContactDateHour')), - $hoursRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - ':', - array('select' => array('name' => 'data[Contact][date][min]', 'id' => 'ContactDateMin')), - $minutesRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - ' ', - array('select' => array('name' => 'data[Contact][date][meridian]', 'id' => 'ContactDateMeridian')), - $meridianRegex, - array('option' => array('value' => '')), - '/option', - '*/select' - ); $this->assertTags($result, $expected); $this->assertNotRegExp('/]+value=""[^<>]+selected="selected"[^>]*>/', $result); $result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('value' => '')); - $expected = array( - array('select' => array('name' => 'data[Contact][date][day]', 'id' => 'ContactDateDay')), - $daysRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - '-', - array('select' => array('name' => 'data[Contact][date][month]', 'id' => 'ContactDateMonth')), - $monthsRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - '-', - array('select' => array('name' => 'data[Contact][date][year]', 'id' => 'ContactDateYear')), - $yearsRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - array('select' => array('name' => 'data[Contact][date][hour]', 'id' => 'ContactDateHour')), - $hoursRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - ':', - array('select' => array('name' => 'data[Contact][date][min]', 'id' => 'ContactDateMin')), - $minutesRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - ' ', - array('select' => array('name' => 'data[Contact][date][meridian]', 'id' => 'ContactDateMeridian')), - $meridianRegex, - array('option' => array('value' => '')), - '/option', - '*/select' - ); $this->assertTags($result, $expected); $this->assertNotRegExp('/]+value=""[^<>]+selected="selected"[^>]*>/', $result); @@ -4858,53 +4786,7 @@ class FormHelperTest extends CakeTestCase { $this->assertNotRegExp('/]+value=""[^<>]+selected="selected"[^>]*>/', $result); $result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('minuteInterval' => 5, 'value' => '')); - $expected = array( - array('select' => array('name' => 'data[Contact][date][day]', 'id' => 'ContactDateDay')), - $daysRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - '-', - array('select' => array('name' => 'data[Contact][date][month]', 'id' => 'ContactDateMonth')), - $monthsRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - '-', - array('select' => array('name' => 'data[Contact][date][year]', 'id' => 'ContactDateYear')), - $yearsRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - array('select' => array('name' => 'data[Contact][date][hour]', 'id' => 'ContactDateHour')), - $hoursRegex, - array('option' => array('value' => '')), - '/option', - '*/select', - ':', - array('select' => array('name' => 'data[Contact][date][min]', 'id' => 'ContactDateMin')), - $minutesRegex, - array('option' => array('value' => '')), - '/option', - array('option' => array('value' => '00')), - '00', - '/option', - array('option' => array('value' => '05')), - '05', - '/option', - array('option' => array('value' => '10')), - '10', - '/option', - '*/select', - ' ', - array('select' => array('name' => 'data[Contact][date][meridian]', 'id' => 'ContactDateMeridian')), - $meridianRegex, - array('option' => array('value' => '')), - '/option', - '*/select' - ); - $this->assertTags($result, $expected); - $this->assertNotRegExp('/]+value=""[^<>]+selected="selected"[^>]*>/', $result); + $result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('minuteInterval' => 5, 'value' => '')); $this->Form->request->data['Contact']['data'] = null; $result = $this->Form->dateTime('Contact.date', 'DMY', '12'); From 49eac06d892402f49a43415c8e41e110b5bf6232 Mon Sep 17 00:00:00 2001 From: Tigran Gabrielyan Date: Sat, 21 Apr 2012 18:33:58 -0700 Subject: [PATCH 8/8] Fixed bug in Router::normalize() --- lib/Cake/Routing/Router.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 86ed4edb5..62cda92e7 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -1014,7 +1014,8 @@ class Router { public static function normalize($url = '/') { if (is_array($url)) { $url = Router::url($url); - } elseif (preg_match('/^[a-z\-]+:\/\//', $url)) { + } + if (preg_match('/^[a-z\-]+:\/\//', $url)) { return $url; } $request = Router::getRequest();