Skip to content
Permalink
Browse files

Updated the test cases for #6518

The new test will now test for unpadded 00 as that might be an
indication of the value converted from string to float or int.

Also added a new test for when 00 minute is selected and the empty
option enabled so that it doesn't select the empty as the 00 minute.

This should complete the adjustment for issue
#6518
  • Loading branch information...
jhawkwind committed May 9, 2015
1 parent b08319e commit bd25341e569f3803c78c57e458c1bf3a12dcbd18
Showing with 72 additions and 9 deletions.
  1. +72 −9 tests/TestCase/View/Widget/DateTimeWidgetTest.php
@@ -805,7 +805,7 @@ public function testRenderMinuteWidget()
$this->assertContains(
'<option value="00">00</option>',
$result,
'contains 1'
'contains 00'
);
$this->assertContains(
'<option value="05">05</option>',
@@ -824,7 +824,65 @@ public function testRenderMinuteWidget()
);
$this->assertNotContains('value="60"', $result, 'No 60 value');
}
/**
* Test rendering the minute widget with empty at zero options.
*
* @return void
*/
public function testRenderMinuteWidgetEmptyZeroDefault()
{
$now = new \DateTime('2010-09-09 13:00:23');
$result = $this->DateTime->render([
'name' => 'date',
'year' => false,
'month' => false,
'day' => false,
'hour' => false,
'minute' => [
'data-foo' => 'test',
],
'empty' => '-',
'default' => '',
'second' => false,
'val' => $now,
], $this->context);
$this->assertContains('<select name="date[minute]" data-foo="test">', $result);
$this->assertContains(
'<option value="">-</option>',
$result,
'contains empty option -'
);
$this->assertContains(
'<option value="00" selected="selected">00</option>',
$result,
'selected value present and correct at 00'
);
$this->assertContains(
'<option value="05">05</option>',
$result,
'contains 05'
);
$this->assertContains(
'<option value="25">25</option>',
$result,
'contains 25'
);
$this->assertContains(
'<option value="59">59</option>',
$result,
'contains 59'
);
$this->assertNotContains(
'<option value="" selected="selected">-</option>',
$result,
'No 0 value as empty value'
);
$this->assertNotContains('value="0"', $result, 'No unpadded 0 value');
$this->assertNotContains('value="60"', $result, 'No 60 value');
}
/**
* Test minutes with interval values.
*
@@ -849,7 +907,7 @@ public function testRenderMinuteWidgetInterval()
$this->assertContains(
'<option value="00">00</option>',
$result,
'contains 0'
'contains 00'
);
$this->assertContains(
'<option value="05">05</option>',
@@ -864,7 +922,7 @@ public function testRenderMinuteWidgetInterval()
$this->assertContains(
'<option value="55">55</option>',
$result,
'contains 59'
'contains 55'
);
$this->assertNotContains('value="2"', $result, 'No 2 value');
$this->assertNotContains('value="23"', $result, 'No 23 value');
@@ -965,10 +1023,15 @@ public function testRenderSecondsWidget()
'val' => $now,
], $this->context);
$this->assertContains('<select name="date[second]" data-foo="test">', $result);
$this->assertContains(
'<option value="00">00</option>',
$result,
'contains 00'
);
$this->assertContains(
'<option value="01">01</option>',
$result,
'contains 1'
'contains 01'
);
$this->assertContains(
'<option value="05">05</option>',
@@ -981,12 +1044,12 @@ public function testRenderSecondsWidget()
'selected value present'
);
$this->assertContains(
'<option value="60">60</option>',
'<option value="59">59</option>',
$result,
'contains 60'
'contains 59'
);
$this->assertNotContains('value="0"', $result, 'No zero value');
$this->assertNotContains('value="61"', $result, 'No 61 value');
$this->assertNotContains('value="0"', $result, 'No unpadded zero value');
$this->assertNotContains('value="60"', $result, 'No 60 value');
}
/**

0 comments on commit bd25341

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