コード例 #1
0
 /**
  * Test element wrapping in timeAgoInWords
  *
  * @return void
  */
 public function testTimeAgoInWords()
 {
     $Time = new TimeHelper($this->View);
     $timestamp = strtotime('+8 years, +4 months +2 weeks +3 days');
     $result = $Time->timeAgoInWords($timestamp, array('end' => '1 years', 'element' => 'span'));
     $expected = array('span' => array('title' => $timestamp, 'class' => 'time-ago-in-words'), 'on ' . date('n/j/y', $timestamp), '/span');
     $this->assertHtml($expected, $result);
     $result = $Time->timeAgoInWords($timestamp, array('end' => '1 years', 'element' => array('title' => 'testing', 'rel' => 'test')));
     $expected = array('span' => array('title' => 'testing', 'class' => 'time-ago-in-words', 'rel' => 'test'), 'on ' . date('n/j/y', $timestamp), '/span');
     $this->assertHtml($expected, $result);
     $timestamp = strtotime('+2 weeks');
     $result = $Time->timeAgoInWords($timestamp, array('end' => '1 years', 'element' => 'div'));
     $expected = array('div' => array('title' => $timestamp, 'class' => 'time-ago-in-words'), '2 weeks', '/div');
     $this->assertHtml($expected, $result);
 }
コード例 #2
0
ファイル: TimeHelperTest.php プロジェクト: rashmi/newrepo
 /**
  * Test output timezone with timeAgoInWords
  *
  * @return void
  */
 public function testTimeAgoInWordsOutputTimezone()
 {
     $Time = new TimeHelper($this->View, ['outputTimezone' => 'America/Vancouver']);
     $timestamp = new Time('+8 years, +4 months +2 weeks +3 days');
     $result = $Time->timeAgoInWords($timestamp, ['end' => '1 years', 'element' => 'span']);
     $vancouver = clone $timestamp;
     $vancouver->timezone('America/Vancouver');
     $expected = ['span' => ['title' => $vancouver->__toString(), 'class' => 'time-ago-in-words'], 'on ' . $vancouver->format('n/j/y'), '/span'];
     $this->assertHtml($expected, $result);
 }