Tests for the Date class
This commit is contained in:
parent
4cf94f9c28
commit
f11e3157e3
1 changed files with 32 additions and 0 deletions
32
tests/classes/DateTest.php
Normal file
32
tests/classes/DateTest.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
require_once 'classes/Date.php';
|
||||
|
||||
class DateTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerAge
|
||||
*/
|
||||
public function testAge($a, $b)
|
||||
{
|
||||
$this->assertEquals(Date::age($a), $b);
|
||||
}
|
||||
|
||||
public function providerAge()
|
||||
{
|
||||
ini_set('date.timezone', 'America/New_York');
|
||||
|
||||
$time = strtotime('-25 years');
|
||||
|
||||
return array(
|
||||
array(date('Y-m-d', $time), '25'),
|
||||
array(date('m/d/Y', $time), '25'),
|
||||
array(date('r', $time), '25'),
|
||||
array('today', '0'),
|
||||
array('400 days ago', '1'),
|
||||
array(true, Date::age('1969-12-31')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue