Fix : date before 2000 throws an exception
This commit is contained in:
parent
6f8265689a
commit
b0f58ab592
2 changed files with 52 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
2<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
|
@ -204,4 +204,54 @@ class Ac_CommonTest extends TestCase
|
|||
$this->assertEquals($text,$text);
|
||||
|
||||
}
|
||||
/**
|
||||
* provides data to testIsDate
|
||||
*/
|
||||
function dataIsDate()
|
||||
{
|
||||
return array(
|
||||
['01.01.1992',1],
|
||||
['30.02.2001',0],
|
||||
['15.07.01',0],
|
||||
['21.08.2001',1]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @covers IsDate
|
||||
* @testdox isDate
|
||||
* @dataProvider dataIsDate
|
||||
*/
|
||||
function testIsDate($p_date,$expected)
|
||||
{
|
||||
$return=($expected==1)?$p_date:null;
|
||||
$this->assertEquals(isDate($p_date),$return,"Test $p_date");
|
||||
}
|
||||
function dataCompareDate ()
|
||||
{
|
||||
return array(
|
||||
['01.01.1992','05.02.2001',-1],
|
||||
['01.01.2012','05.02.2001',1],
|
||||
['05.02.2001','05.02.2001',0]);
|
||||
}
|
||||
/**
|
||||
* @covers cmpDate
|
||||
* @testDox test cmpDate
|
||||
* @dataProvider dataCompareDate
|
||||
*/
|
||||
function testCompareDate($p_date,$p_date_2,$p_result)
|
||||
{
|
||||
$cmp=cmpDate($p_date,$p_date_2);
|
||||
switch ( $p_result ) {
|
||||
case 0:
|
||||
$this->assertEquals($cmp,0);
|
||||
break;
|
||||
case 1:
|
||||
$this->assertGreaterThan(0,$cmp);
|
||||
break;
|
||||
case -1:
|
||||
$this->assertLessThan(0,$cmp);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue