Permalink
Browse files

Move tests around.

Try to fix timing issues in formhelper tests.
  • Loading branch information...
1 parent cec4e8b commit 274a146b24e56037323f7e9ddc5a67f9fc44989b @markstory markstory committed Mar 14, 2013
Showing with 12 additions and 18 deletions.
  1. +12 −18 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
View
30 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -5560,23 +5560,6 @@ public function testDateTime() {
);
$this->assertTags($result, $expected);
- $result = $this->Form->input('published', array('type' => 'time'));
- $now = strtotime('now');
- $expected = array(
- 'div' => array('class' => 'input time'),
- 'label' => array('for' => 'ContactPublishedHour'),
- 'Published',
- '/label',
- array('select' => array('name' => 'data[Contact][published][hour]', 'id' => 'ContactPublishedHour')),
- 'preg:/(?:<option value="([\d])+">[\d]+<\/option>[\r\n]*)*/',
- array('option' => array('value' => date('h', $now), 'selected' => 'selected')),
- date('g', $now),
- '/option',
- '*/select',
- ':',
- );
- $this->assertTags($result, $expected);
-
$result = $this->Form->input('published', array(
'timeFormat' => 24,
'interval' => 5,
@@ -5589,7 +5572,17 @@ public function testDateTime() {
$this->assertRegExp('/<option[^<>]+value="13"[^<>]+selected="selected"[^>]*>13<\/option>/', $result);
$this->assertRegExp('/<option[^<>]+value="35"[^<>]+selected="selected"[^>]*>35<\/option>/', $result);
- $this->assertNoErrors();
+ $result = $this->Form->input('published', array('type' => 'time'));
+ $now = strtotime('now');
+ $this->assertContains('<option value="' . date('h', $now) . '" selected="selected">' . date('g', $now) . '</option>', $result);
+ }
+
+/**
+ * Test that empty values don't trigger errors.
+ *
+ * @return void
+ */
+ public function testDateTimeNoErrorsOnEmptyData() {
$this->Form->request->data['Contact'] = array(
'date' => array(
'day' => '',
@@ -5601,6 +5594,7 @@ public function testDateTime() {
)
);
$result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('empty' => false));
+ $this->assertNotEmpty($result);
}
/**

0 comments on commit 274a146

Please sign in to comment.