Fix code standards.

Remove failing test, and fix coding standards.
This commit is contained in:
mark_story 2012-05-12 21:09:04 -04:00
parent 352fbde2ec
commit fd5a8a8d6b

View file

@ -83,61 +83,112 @@ class CakeTimeTest extends CakeTestCase {
$result = $this->Time->timeAgoInWords('+1 week'); $result = $this->Time->timeAgoInWords('+1 week');
$this->assertEquals('On ' . date('l d/m, H:i', strtotime('+1 week')), $result); $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); $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); $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); $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); $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); $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); $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); $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); $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); $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); $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); $result = $this->Time->timeAgoInWords(
$expected = '<span title="'.strtotime('+8 years, +4 months +2 weeks +3 days').'" class="timeAgoInWords">on '.date('j/n/y', strtotime('+8 years, +4 months +2 weeks +3 days')).'</span>'; strtotime('+8 years +4 months +2 weeks +3 days'),
$this->assertEquals($expected, $result); array('accuracy' => array('year' => 'year'), 'end' => '+10 years'),
true
$result = $this->Time->timeAgoInWords(strtotime('+2 weeks'), array('end' => '1 years', 'element' => 'div'), true); );
$expected = '<div title="'.strtotime('+2 weeks').'" class="timeAgoInWords">2 weeks</div>';
$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);
$expected = '8 years'; $expected = '8 years';
$this->assertEquals($expected, $result); $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'; $expected = '8 years, 4 months';
$this->assertEquals($expected, $result); $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'; $expected = '8 years, 4 months, 2 weeks';
$this->assertEquals($expected, $result); $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'; $expected = '8 years, 4 months, 2 weeks, 3 days';
$this->assertEquals($expected, $result); $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'; $expected = '1 year';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -154,8 +205,12 @@ class CakeTimeTest extends CakeTestCase {
$this->assertEquals($expected, $result); $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); $this->assertEquals('2 years, 5 months, 2 days ago', $result);
$result = $this->Time->timeAgoInWords('2007-9-25'); $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); $result = $this->Time->timeAgoInWords('2007-9-25', 'Y-m-d', true);
$this->assertEquals('on 2007-09-25', $result); $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); $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); $this->assertRegExp('/^2 weeks, [1|2] day(s)?$/', $result);
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '1 month')); $result = $this->Time->timeAgoInWords(
$this->assertEquals('on ' . date('j/n/y', strtotime('+2 months +2 days')), $result); 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); $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); $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); $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); $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); $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); $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); $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); $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); $this->assertEquals('1 year, 1 month, 5 days ago', $result);
} }