mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Add failing test for FormHelper::input
FormHelper::input does not respect 'value' option when form is of date/time type.
This commit is contained in:
parent
67393f2525
commit
0e0775559c
1 changed files with 92 additions and 0 deletions
|
@ -2517,6 +2517,61 @@ class FormHelperTest extends CakeTestCase {
|
|||
$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 @@ class FormHelperTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue