Commit 2da7ec5f authored by Tino Goratsch's avatar Tino Goratsch

added unit tests for the DateValidationRule class

parent e52b2865
......@@ -40,8 +40,8 @@ class DateValidationRule extends AbstractValidationRule
{
if ($this->matchIsDate($start)) {
// Check date range
if ($end !== null && $this->matchIsDate($end) && strtotime($start) <= strtotime($end)) {
return true;
if ($end !== null && $this->matchIsDate($end)) {
return strtotime($start) <= strtotime($end);
}
return true;
......
<?php
class DateValidationRuleTest extends AbstractValidationRuleTest
{
protected function setUp()
{
$this->validationRule = new \ACP3\Core\Validation\ValidationRules\DateValidationRule();
}
/**
* @return array
*/
public function validationRuleProvider()
{
return [
'valid-data-string' => ['1980-03-20', '', [], true],
'valid-data-string-with-time' => ['1980-03-20 20:05', '', [], true],
'valid-data-array' => [['foo' => '1980-03-20'], 'foo', [], true],
'valid-data-array-with-time' => [['foo' => '1980-03-20 20:05'], 'foo', [], true],
'valid-data-array-range' => [['start' => '1980-03-20', 'end' => '1980-03-21'], ['start', 'end'], [], true],
'valid-data-array-range-with-time' => [['start' => '1980-03-20 20:05', 'end' => '1980-03-21 20:05'], ['start', 'end'], [], true],
'invalid-data-string-random-string' => ['abc/1234/test', '', [], false],
'invalid-data-array-range' => [['start' => '1980-03-20', 'end' => '1980-03-19'], ['start', 'end'], [], false],
];
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment