Dropped date utility class
Only had one function and it was referencing the time class. Moved date tests to the time tests because it seemed like a more comprehensive set of tests.
This commit is contained in:
parent
442e505cbf
commit
8e60e9d553
3 changed files with 22 additions and 68 deletions
39
src/Date.php
39
src/Date.php
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Date Utility Collection
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistribution of these files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2007-2014, Josh Sherman
|
||||
* @license http://www.opensource.org/licenses/mit-license.html
|
||||
* @link http://picklesphp.com
|
||||
* @package Pickles
|
||||
*/
|
||||
|
||||
namespace Pickles;
|
||||
|
||||
/**
|
||||
* Date Class
|
||||
*
|
||||
* Just a simple collection of static functions to accomplish some of the more
|
||||
* redundant date related manipulation.
|
||||
*/
|
||||
class Date
|
||||
{
|
||||
/**
|
||||
* Age
|
||||
*
|
||||
* Calculates age based on the passed date.
|
||||
*
|
||||
* @static
|
||||
* @param string $date birth / inception date
|
||||
* @return integer $age number of years old
|
||||
*/
|
||||
public static function age($date)
|
||||
{
|
||||
return Time::age($date);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
class DateTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerAge
|
||||
*/
|
||||
public function testAge($a, $b)
|
||||
{
|
||||
$this->assertEquals(Pickles\Date::age($a), $b);
|
||||
}
|
||||
|
||||
public function providerAge()
|
||||
{
|
||||
ini_set('date.timezone', 'America/New_York');
|
||||
|
||||
$time = strtotime('-25 years');
|
||||
|
||||
return [
|
||||
[date('Y-m-d', $time), '25'],
|
||||
[date('m/d/Y', $time), '25'],
|
||||
[date('r', $time), '25'],
|
||||
['today', '0'],
|
||||
['400 days ago', '1'],
|
||||
[true, Pickles\Date::age('1969-12-31')],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,28 @@ class TimeTest extends PHPUnit_Framework_TestCase
|
|||
date_default_timezone_set('GMT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAge
|
||||
*/
|
||||
public function testAge($a, $b)
|
||||
{
|
||||
$this->assertEquals(Pickles\Time::age($a), $b);
|
||||
}
|
||||
|
||||
public function providerAge()
|
||||
{
|
||||
$time = strtotime('-25 years');
|
||||
|
||||
return [
|
||||
[date('Y-m-d', $time), '25'],
|
||||
[date('m/d/Y', $time), '25'],
|
||||
[date('r', $time), '25'],
|
||||
['today', '0'],
|
||||
['400 days ago', '1'],
|
||||
[true, Pickles\Date::age('1969-12-31')],
|
||||
];
|
||||
}
|
||||
|
||||
public function testAgePastTime()
|
||||
{
|
||||
$this->assertEquals(18, Pickles\Time::age(date('Y-m-d', strtotime('-18 years'))));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue