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'); ?> diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index dd89cf136..dfcd14508 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/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 289f9e468..82f213986 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); } } } diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 5b866e056..ee081adc2 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(); 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 080b55882..f574821a6 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -1866,7 +1866,6 @@ class ModelIntegrationTest extends BaseModelTest { 'doomed' => true )))); - $ts = date('Y-m-d H:i:s'); $TestModel->save(); $TestModel->hasAndBelongsToMany['SomethingElse']['order'] = 'SomethingElse.id ASC'; @@ -1920,7 +1919,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 72c3309d8..05c34dab5 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( @@ -2561,29 +2560,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); @@ -2596,7 +2594,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( @@ -2609,8 +2607,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( @@ -2623,8 +2621,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); @@ -2642,7 +2640,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( @@ -2669,10 +2666,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]); @@ -2684,7 +2681,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', @@ -2718,16 +2714,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, @@ -2748,8 +2743,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']); @@ -2758,8 +2753,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']); } @@ -4056,7 +4051,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)); @@ -4098,8 +4092,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( @@ -4109,8 +4103,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); @@ -4125,7 +4119,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)); @@ -4167,8 +4160,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( @@ -4178,8 +4171,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); @@ -4264,7 +4257,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')); @@ -4305,10 +4297,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); @@ -4399,10 +4391,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); @@ -5414,7 +5401,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)); @@ -5467,10 +5453,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); @@ -5485,7 +5471,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)); @@ -5537,10 +5522,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']); } @@ -5609,7 +5594,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', @@ -5672,10 +5656,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); @@ -6372,7 +6356,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'); // test belongsTo $fieldList = array( @@ -6398,15 +6381,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', ), ); @@ -6418,7 +6401,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( @@ -6444,8 +6426,8 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'Multi-record post 1', 'body' => '', 'published' => 'N', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() ) ), array( @@ -6455,8 +6437,8 @@ class ModelWriteTest extends BaseModelTest { 'title' => 'Multi-record post 2', 'body' => '', 'published' => 'N', - 'created' => $ts, - 'updated' => $ts + 'created' => self::date(), + 'updated' => self::date() ) ) ); @@ -6544,7 +6526,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'); // test belongsTo $fieldList = array( 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, ) ) ) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 1accaa471..7e6b6ae51 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -4799,84 +4799,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); @@ -4930,53 +4858,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'); 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')); diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 1a28c2d2b..181fd740d 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -155,6 +155,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 diff --git a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php index 025d55a62..31c2a17ef 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 *