public function testTimeAgo() { $this->assertEquals('few seconds ago', StringUtils::timeAgo(time())); $this->assertEquals('few seconds ago', StringUtils::timeAgo(time() - 5)); $this->assertEquals(date('d.m.Y H:i', strtotime('1 month ago')), StringUtils::timeAgo(strtotime('1 month ago'))); $this->assertNotEquals(date('d.m.Y H:i', strtotime('1 month ago')), StringUtils::timeAgo(strtotime('1 month ago'), 1, '2 months ago')); $this->assertEquals(date('d.m.Y', strtotime('1 month ago')), StringUtils::timeAgo(strtotime('1 month ago'), 1, '3 weeks ago', 'd.m.Y')); $this->assertEquals('1 minute 5 seconds ago', StringUtils::timeAgo(time() - 65, 2)); $this->assertEquals('1 minute ago', StringUtils::timeAgo(time() - 65)); $this->assertEquals('1 hour 13 minutes ago', StringUtils::timeAgo(time() - 73 * 60, 2)); $this->assertEquals('1 hour 13 minutes 17 seconds ago', StringUtils::timeAgo(time() - 73 * 60 - 17, 3)); $this->assertEquals('1 hour 13 minutes ago', StringUtils::timeAgo(time() - 73 * 60 - 17, 2)); $this->assertEquals('1 hour ago', StringUtils::timeAgo(time() - 60 * 60 - 13)); $this->assertEquals('1 hour ago', StringUtils::timeAgo(time() - 60 * 60)); }