Skip to content
Permalink
Browse files

Update tests for strfime() in timeAgoInWords()

Add test asserts for testTimeAgoInWordsWithFormat with strftime format
  • Loading branch information...
mstra001 authored and markstory committed Sep 9, 2014
1 parent 244acc7 commit d6abfcaf90c673efe71fa5debbabbb37736ac7cf
Showing with 15 additions and 3 deletions.
  1. +15 −3 lib/Cake/Test/Case/Utility/CakeTimeTest.php
@@ -263,28 +263,40 @@ public function testTimeAgoInWordsAccuracy() {
}
/**
* Test the format option of timeAgoInWords()
* Test the format option of timeAgoInWords() with date() and strftime compatible strings
*
* @return void
*/
public function testTimeAgoInWordsWithFormat() {
$result = $this->Time->timeAgoInWords('2007-9-25', 'Y-m-d');
$this->assertEquals('on 2007-09-25', $result);
$result = $this->Time->timeAgoInWords('2007-9-25', 'Y-m-d');
$this->assertEquals('on 2007-09-25', $result);
$result = $this->Time->timeAgoInWords('2007-9-25', '%x');
$this->assertEquals('on '. strftime('%x', strtotime('2007-9-25')), $result);
$result = $this->Time->timeAgoInWords(
strtotime('+2 weeks +2 days'),
'Y-m-d'
);
$this->assertRegExp('/^2 weeks, [1|2] day(s)?$/', $result);
$result = $this->Time->timeAgoInWords(
strtotime('+2 weeks +2 days'),
'%x'
);
$this->assertRegExp('/^2 weeks, [1|2] day(s)?$/', $result);
$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' => '%x')
);
$this->assertEquals('on ' . strftime('%x', strtotime('+2 months +2 days')), $result);
}
/**

0 comments on commit d6abfca

Please sign in to comment.
You can’t perform that action at this time.