From 0e0775559c2d61aaa04ba440a150debf53e7470b Mon Sep 17 00:00:00 2001 From: Yoshiyuki Kinjo Date: Tue, 21 Jul 2015 22:58:50 +0900 Subject: [PATCH] Add failing test for FormHelper::input FormHelper::input does not respect 'value' option when form is of date/time type. --- .../Test/Case/View/Helper/FormHelperTest.php | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 55a917b93..0e7738ee3 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -2517,6 +2517,61 @@ class FormHelperTest extends CakeTestCase { $this->assertContains('', $result); } +/** + * Test interval + value near the hour roll over. + * + * @return void + */ + public function testTimeValueWithInterval() { + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'interval' => 15, + 'value' => array('hour' => '3', 'min' => '57', 'meridian' => 'pm') + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'interval' => 15, + 'value' => '2012-10-23 15:57:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'timeFormat' => 24, + 'type' => 'time', + 'interval' => 15, + 'value' => '15:57' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'timeFormat' => 24, + 'type' => 'time', + 'interval' => 15, + 'value' => '23:57' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.created', array( + 'timeFormat' => 24, + 'type' => 'datetime', + 'interval' => 15, + 'value' => '2012-09-30 23:56' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + } + /** * Test time with selected values around 12:xx:xx * @@ -2554,6 +2609,43 @@ class FormHelperTest extends CakeTestCase { $this->assertContains('', $result); } +/** + * Test time with selected values around 12:xx:xx + * + * @return void + */ + public function testTimeValueWithIntervalTwelve() { + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'value' => '00:00:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'value' => '12:00:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'value' => '12:15:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + } + /** * Test interval & timeFormat = 12 *