Skip to content
Permalink
Browse files

Add failing test for FormHelper::input

FormHelper::input does not respect 'value' option when form is of date/time type.
  • Loading branch information...
yskkin committed Jul 21, 2015
1 parent 67393f2 commit 0e0775559c2d61aaa04ba440a150debf53e7470b
Showing with 92 additions and 0 deletions.
  1. +92 −0 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -2517,6 +2517,61 @@ public function testTimeSelectedWithInterval() {
$this->assertContains('<option value="00" selected="selected">00</option>', $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('<option value="04" selected="selected">4</option>', $result);
$this->assertContains('<option value="00" selected="selected">00</option>', $result);
$this->assertContains('<option value="pm" selected="selected">pm</option>', $result);
$result = $this->Form->input('Model.start_time', array(
'type' => 'time',
'interval' => 15,
'value' => '2012-10-23 15:57:00'
));
$this->assertContains('<option value="04" selected="selected">4</option>', $result);
$this->assertContains('<option value="00" selected="selected">00</option>', $result);
$this->assertContains('<option value="pm" selected="selected">pm</option>', $result);
$result = $this->Form->input('Model.start_time', array(
'timeFormat' => 24,
'type' => 'time',
'interval' => 15,
'value' => '15:57'
));
$this->assertContains('<option value="16" selected="selected">16</option>', $result);
$this->assertContains('<option value="00" selected="selected">00</option>', $result);
$result = $this->Form->input('Model.start_time', array(
'timeFormat' => 24,
'type' => 'time',
'interval' => 15,
'value' => '23:57'
));
$this->assertContains('<option value="00" selected="selected">0</option>', $result);
$this->assertContains('<option value="00" selected="selected">00</option>', $result);
$result = $this->Form->input('Model.created', array(
'timeFormat' => 24,
'type' => 'datetime',
'interval' => 15,
'value' => '2012-09-30 23:56'
));
$this->assertContains('<option value="2012" selected="selected">2012</option>', $result);
$this->assertContains('<option value="10" selected="selected">October</option>', $result);
$this->assertContains('<option value="01" selected="selected">1</option>', $result);
$this->assertContains('<option value="00" selected="selected">0</option>', $result);
$this->assertContains('<option value="00" selected="selected">00</option>', $result);
}
/**
* Test time with selected values around 12:xx:xx
*
@@ -2554,6 +2609,43 @@ public function testTimeSelectedWithIntervalTwelve() {
$this->assertContains('<option value="pm" selected="selected">pm</option>', $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('<option value="12" selected="selected">12</option>', $result);
$this->assertContains('<option value="00" selected="selected">00</option>', $result);
$this->assertContains('<option value="am" selected="selected">am</option>', $result);
$result = $this->Form->input('Model.start_time', array(
'type' => 'time',
'timeFormat' => 12,
'interval' => 15,
'value' => '12:00:00'
));
$this->assertContains('<option value="12" selected="selected">12</option>', $result);
$this->assertContains('<option value="00" selected="selected">00</option>', $result);
$this->assertContains('<option value="pm" selected="selected">pm</option>', $result);
$result = $this->Form->input('Model.start_time', array(
'type' => 'time',
'timeFormat' => 12,
'interval' => 15,
'value' => '12:15:00'
));
$this->assertContains('<option value="12" selected="selected">12</option>', $result);
$this->assertContains('<option value="15" selected="selected">15</option>', $result);
$this->assertContains('<option value="pm" selected="selected">pm</option>', $result);
}
/**
* Test interval & timeFormat = 12
*

0 comments on commit 0e07755

Please sign in to comment.
You can’t perform that action at this time.