Skip to content

Commit

Permalink
Add test to prove #5581
Browse files Browse the repository at this point in the history
Adds a test for the `DateTimeWidget` that proves that an invalid date (e.g. Feb 31) gets converted by the `DateTimeWidget`
  • Loading branch information
Walther Lalk committed Jan 6, 2015
1 parent cde66cb commit 5261b27
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/TestCase/View/Widget/DateTimeWidgetTest.php
Expand Up @@ -115,6 +115,20 @@ public function testRenderSelected($selected)
$this->assertContains('<option value="45" selected="selected">45</option>', $result);
}

public function testRenderInvalidDate() {
$selected = [
'year' => '2014', 'month' => '02', 'day' => '31',
'hour' => '12', 'minute' => '30', 'second' => '45',
];
$result = $this->DateTime->render(['val' => $selected], $this->context);
$this->assertContains('<option value="2014" selected="selected">2014</option>', $result);
$this->assertContains('<option value="02" selected="selected">2</option>', $result);
$this->assertContains('<option value="31" selected="selected">31</option>', $result);
$this->assertContains('<option value="12" selected="selected">12</option>', $result);
$this->assertContains('<option value="30" selected="selected">30</option>', $result);
$this->assertContains('<option value="45" selected="selected">45</option>', $result);
}

/**
* Test that render() works with an array for val that is missing seconds.
*
Expand Down

0 comments on commit 5261b27

Please sign in to comment.