Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Getting the time helper code coverage up to 99%

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8228 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 44fa8d5fd0eb9868d788179eeb95659470961238 1 parent 11c6641
@tim-kos tim-kos authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 cake/tests/cases/libs/view/helpers/time.test.php
View
17 cake/tests/cases/libs/view/helpers/time.test.php
@@ -276,6 +276,23 @@ function testTimeAgoInWords() {
$fourHours = $this->Time->timeAgoInWords(strtotime('-5 days, -2 hours'), array('userOffset' => -4));
$result = $this->Time->timeAgoInWords(strtotime('-5 days, -2 hours'), array('userOffset' => 4));
$this->assertEqual($fourHours, $result);
+
+ $result = $this->Time->timeAgoInWords(strtotime('-2 hours'));
+ $expected = '2 hours ago';
+ $this->assertEqual($expected, $result);
+
+ $result = $this->Time->timeAgoInWords(strtotime('-12 minutes'));
+ $expected = '12 minutes ago';
+ $this->assertEqual($expected, $result);
+
+ $result = $this->Time->timeAgoInWords(strtotime('-12 seconds'));
+ $expected = '12 seconds ago';
+ $this->assertEqual($expected, $result);
+
+ $time = strtotime('-3 years -12 months');
+ $result = $this->Time->timeAgoInWords($time);
+ $expected = 'on ' . date('j/n/y', $time);
+ $this->assertEqual($expected, $result);
}
/**
* testRelative method
Please sign in to comment.
Something went wrong with that request. Please try again.