Created
April 8, 2012 22:56
-
-
Save marijn/2340257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DateTimeTest extends PHPUnit_Framework_TestCase | |
{ | |
private $dateTimeZone; | |
public function setUp() | |
{ | |
$this->dateTimeZone = new DateTimeZone("UTC"); | |
} | |
public function tearDown() | |
{ | |
$this->dateTimeZone = null; | |
} | |
public function testCreateDateTimeForNowWithMilliSeconds() | |
{ | |
$microtime = sprintf('%.f', microtime(true)); | |
$composed = DateTime::createFromFormat('U.u', $microtime, $this->dateTimeZone); | |
$expected = new DateTime('now', $this->dateTimeZone); | |
foreach (array('Y', 'm', 'd', 'H', 'i', 's') as $modifier) { | |
$this->assertEquals($expected->format($modifier), $composed->format($modifier)); | |
} | |
$this->assertEquals($composed->format('U.u'), $microtime); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment