Browse Source

FromatterDateTest - fixed tests on PHP7

tags/3.0.0-alpha1
SilverFire - Dima Naumenko 9 years ago
parent
commit
c1b0d1263b
  1. 12
      tests/framework/i18n/FormatterDateTest.php

12
tests/framework/i18n/FormatterDateTest.php

@ -137,23 +137,23 @@ class FormatterDateTest extends TestCase
public function testAsDatetime() public function testAsDatetime()
{ {
$value = time(); $value = time();
$this->assertSame(date('M j, Y g:i:s A', $value), $this->formatter->asDatetime($value)); $this->assertRegExp(date('~M j, Y,? g:i:s A~', $value), $this->formatter->asDatetime($value));
$this->assertSame(date('Y/m/d h:i:s A', $value), $this->formatter->asDatetime($value, 'php:Y/m/d h:i:s A')); $this->assertSame(date('Y/m/d h:i:s A', $value), $this->formatter->asDatetime($value, 'php:Y/m/d h:i:s A'));
$value = new DateTime(); $value = new DateTime();
$this->assertSame(date('M j, Y g:i:s A', $value->getTimestamp()), $this->formatter->asDatetime($value)); $this->assertRegExp(date('~M j, Y,? g:i:s A~', $value->getTimestamp()), $this->formatter->asDatetime($value));
$this->assertSame(date('Y/m/d h:i:s A', $value->getTimestamp()), $this->formatter->asDatetime($value, 'php:Y/m/d h:i:s A')); $this->assertSame(date('Y/m/d h:i:s A', $value->getTimestamp()), $this->formatter->asDatetime($value, 'php:Y/m/d h:i:s A'));
if (version_compare(PHP_VERSION, '5.5.0', '>=')) { if (version_compare(PHP_VERSION, '5.5.0', '>=')) {
$value = new \DateTimeImmutable(); $value = new \DateTimeImmutable();
$this->assertSame(date('M j, Y g:i:s A', $value->getTimestamp()), $this->formatter->asDatetime($value)); $this->assertRegExp(date('~M j, Y,? g:i:s A~', $value->getTimestamp()), $this->formatter->asDatetime($value));
$this->assertSame(date('Y/m/d h:i:s A', $value->getTimestamp()), $this->formatter->asDatetime($value, 'php:Y/m/d h:i:s A')); $this->assertSame(date('Y/m/d h:i:s A', $value->getTimestamp()), $this->formatter->asDatetime($value, 'php:Y/m/d h:i:s A'));
} }
// empty input // empty input
$this->assertSame('Jan 1, 1970 12:00:00 AM', $this->formatter->asDatetime('')); $this->assertRegExp('~Jan 1, 1970,? 12:00:00 AM~', $this->formatter->asDatetime(''));
$this->assertSame('Jan 1, 1970 12:00:00 AM', $this->formatter->asDatetime(0)); $this->assertRegExp('~Jan 1, 1970,? 12:00:00 AM~', $this->formatter->asDatetime(0));
$this->assertSame('Jan 1, 1970 12:00:00 AM', $this->formatter->asDatetime(false)); $this->assertRegExp('~Jan 1, 1970,? 12:00:00 AM~', $this->formatter->asDatetime(false));
// null display // null display
$this->assertSame($this->formatter->nullDisplay, $this->formatter->asDatetime(null)); $this->assertSame($this->formatter->nullDisplay, $this->formatter->asDatetime(null));
} }

Loading…
Cancel
Save