diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 16a71847d..1f3e2247f 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -83,61 +83,112 @@ class CakeTimeTest extends CakeTestCase { $result = $this->Time->timeAgoInWords('+1 week'); $this->assertEquals('On ' . date('l d/m, H:i', strtotime('+1 week')), $result); - $result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +3 days'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+4 months +2 weeks +3 days'), + array('end' => '8 years'), + true + ); $this->assertEquals('4 months, 2 weeks, 3 days', $result); - $result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +2 days'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+4 months +2 weeks +2 days'), + array('end' => '8 years'), + true + ); $this->assertEquals('4 months, 2 weeks, 2 days', $result); - $result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +1 day'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+4 months +2 weeks +1 day'), + array('end' => '8 years'), + true + ); $this->assertEquals('4 months, 2 weeks, 1 day', $result); - $result = $this->Time->timeAgoInWords(strtotime('+3 months +2 weeks +1 day'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+3 months +2 weeks +1 day'), + array('end' => '8 years'), + true + ); $this->assertEquals('3 months, 2 weeks, 1 day', $result); - $result = $this->Time->timeAgoInWords(strtotime('+3 months +2 weeks'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+3 months +2 weeks'), + array('end' => '8 years'), + true + ); $this->assertEquals('3 months, 2 weeks', $result); - $result = $this->Time->timeAgoInWords(strtotime('+3 months +1 week +6 days'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+3 months +1 week +6 days'), + array('end' => '8 years'), + true + ); $this->assertEquals('3 months, 1 week, 6 days', $result); - $result = $this->Time->timeAgoInWords(strtotime('+2 months +2 weeks +1 day'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+2 months +2 weeks +1 day'), + array('end' => '8 years'), + true + ); $this->assertEquals('2 months, 2 weeks, 1 day', $result); - $result = $this->Time->timeAgoInWords(strtotime('+2 months +2 weeks'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+2 months +2 weeks'), + array('end' => '8 years'), + true + ); $this->assertEquals('2 months, 2 weeks', $result); - $result = $this->Time->timeAgoInWords(strtotime('+2 months +1 week +6 days'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+2 months +1 week +6 days'), + array('end' => '8 years'), + true + ); $this->assertEquals('2 months, 1 week, 6 days', $result); - $result = $this->Time->timeAgoInWords(strtotime('+1 month +1 week +6 days'), array('end' => '8 years'), true); + $result = $this->Time->timeAgoInWords( + strtotime('+1 month +1 week +6 days'), + array('end' => '8 years'), + true + ); $this->assertEquals('1 month, 1 week, 6 days', $result); - - $result = $this->Time->timeAgoInWords(strtotime('+8 years, +4 months +2 weeks +3 days'), array('end' => '1 years', 'element' => 'span'), true); - $expected = 'on '.date('j/n/y', strtotime('+8 years, +4 months +2 weeks +3 days')).''; - $this->assertEquals($expected, $result); - - $result = $this->Time->timeAgoInWords(strtotime('+2 weeks'), array('end' => '1 years', 'element' => 'div'), true); - $expected = '
2 weeks
'; - $this->assertEquals($expected, $result); - - $result = $this->Time->timeAgoInWords(strtotime('+8 years +4 months +2 weeks +3 days'), array('accuracy' => array('year' => 'year'), 'end' => '+10 years'), true); + + $result = $this->Time->timeAgoInWords( + strtotime('+8 years +4 months +2 weeks +3 days'), + array('accuracy' => array('year' => 'year'), 'end' => '+10 years'), + true + ); $expected = '8 years'; $this->assertEquals($expected, $result); - - $result = $this->Time->timeAgoInWords(strtotime('+8 years +4 months +2 weeks +3 days'), array('accuracy' => array('year' => 'month'), 'end' => '+10 years'), true); + + $result = $this->Time->timeAgoInWords( + strtotime('+8 years +4 months +2 weeks +3 days'), + array('accuracy' => array('year' => 'month'), 'end' => '+10 years'), + true + ); $expected = '8 years, 4 months'; $this->assertEquals($expected, $result); - - $result = $this->Time->timeAgoInWords(strtotime('+8 years +4 months +2 weeks +3 days'), array('accuracy' => array('year' => 'week'), 'end' => '+10 years'), true); + + $result = $this->Time->timeAgoInWords( + strtotime('+8 years +4 months +2 weeks +3 days'), + array('accuracy' => array('year' => 'week'), 'end' => '+10 years'), + true + ); $expected = '8 years, 4 months, 2 weeks'; $this->assertEquals($expected, $result); - - $result = $this->Time->timeAgoInWords(strtotime('+8 years +4 months +2 weeks +3 days'), array('accuracy' => array('year' => 'day'), 'end' => '+10 years'), true); + + $result = $this->Time->timeAgoInWords( + strtotime('+8 years +4 months +2 weeks +3 days'), + array('accuracy' => array('year' => 'day'), 'end' => '+10 years'), + true); $expected = '8 years, 4 months, 2 weeks, 3 days'; $this->assertEquals($expected, $result); - - $result = $this->Time->timeAgoInWords(strtotime('+1 years +5 weeks'), array('accuracy' => array('year' => 'year'), 'end' => '+10 years'), true); + + $result = $this->Time->timeAgoInWords( + strtotime('+1 years +5 weeks'), + array('accuracy' => array('year' => 'year'), 'end' => '+10 years'), + true + ); $expected = '1 year'; $this->assertEquals($expected, $result); @@ -154,8 +205,12 @@ class CakeTimeTest extends CakeTestCase { $this->assertEquals($expected, $result); } } - - $result = $this->Time->timeAgoInWords(strtotime('-2 years -5 months -2 days'), array('end' => '3 years'), true); + + $result = $this->Time->timeAgoInWords( + strtotime('-2 years -5 months -2 days'), + array('end' => '3 years'), + true + ); $this->assertEquals('2 years, 5 months, 2 days ago', $result); $result = $this->Time->timeAgoInWords('2007-9-25'); @@ -167,40 +222,81 @@ class CakeTimeTest extends CakeTestCase { $result = $this->Time->timeAgoInWords('2007-9-25', 'Y-m-d', true); $this->assertEquals('on 2007-09-25', $result); - $result = $this->Time->timeAgoInWords(strtotime('-2 weeks -2 days'), 'Y-m-d', false); + $result = $this->Time->timeAgoInWords( + strtotime('-2 weeks -2 days'), + 'Y-m-d', + false + ); $this->assertEquals('2 weeks, 2 days ago', $result); - $result = $this->Time->timeAgoInWords(strtotime('+2 weeks +2 days'), 'Y-m-d', true); + $result = $this->Time->timeAgoInWords( + strtotime('+2 weeks +2 days'), + 'Y-m-d', + true + ); $this->assertRegExp('/^2 weeks, [1|2] day(s)?$/', $result); - $result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '1 month')); - $this->assertEquals('on ' . date('j/n/y', strtotime('+2 months +2 days')), $result); + $result = $this->Time->timeAgoInWords( + strtotime('+2 months +2 days'), + array('end' => '1 month') + ); + $this->assertEquals( + 'on ' . date('j/n/y', strtotime('+2 months +2 days')), + $result + ); - $result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '3 month')); + $result = $this->Time->timeAgoInWords( + strtotime('+2 months +2 days'), + array('end' => '3 month') + ); $this->assertRegExp('/2 months/', $result); - $result = $this->Time->timeAgoInWords(strtotime('+2 months +12 days'), array('end' => '3 month')); + $result = $this->Time->timeAgoInWords( + strtotime('+2 months +12 days'), + array('end' => '3 month') + ); $this->assertRegExp('/2 months, 1 week/', $result); - $result = $this->Time->timeAgoInWords(strtotime('+3 months +5 days'), array('end' => '4 month')); + $result = $this->Time->timeAgoInWords( + strtotime('+3 months +5 days'), + array('end' => '4 month') + ); $this->assertEquals('3 months, 5 days', $result); - $result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '3 month')); + $result = $this->Time->timeAgoInWords( + strtotime('-2 months -2 days'), + array('end' => '3 month') + ); $this->assertEquals('2 months, 2 days ago', $result); - $result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '3 month')); + $result = $this->Time->timeAgoInWords( + strtotime('-2 months -2 days'), + array('end' => '3 month') + ); $this->assertEquals('2 months, 2 days ago', $result); - $result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '3 month')); + $result = $this->Time->timeAgoInWords( + strtotime('+2 months +2 days'), + array('end' => '3 month') + ); $this->assertRegExp('/2 months/', $result); - $result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '1 month', 'format' => 'Y-m-d')); + $result = $this->Time->timeAgoInWords( + strtotime('+2 months +2 days'), + array('end' => '1 month', 'format' => 'Y-m-d') + ); $this->assertEquals('on ' . date('Y-m-d', strtotime('+2 months +2 days')), $result); - $result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '1 month', 'format' => 'Y-m-d')); + $result = $this->Time->timeAgoInWords( + strtotime('-2 months -2 days'), + array('end' => '1 month', 'format' => 'Y-m-d') + ); $this->assertEquals('on ' . date('Y-m-d', strtotime('-2 months -2 days')), $result); - $result = $this->Time->timeAgoInWords(strtotime('-13 months -5 days'), array('end' => '2 years')); + $result = $this->Time->timeAgoInWords( + strtotime('-13 months -5 days'), + array('end' => '2 years') + ); $this->assertEquals('1 year, 1 month, 5 days ago', $result); }