UTC = new \DateTimeZone('UTC'); } public function testGetIdentifier() { $object = UTCTime::createFormDateTime(); $this->assertEquals(Identifier::UTC_TIME, $object->getIdentifier()->getTagNumber()); } public function testGetContent() { $now = new DateTime(); $now->setTimezone($this->UTC); $object = UTCTime::createFormDateTime($now); $this->assertEquals($now->format(DateTime::ATOM), (string) $object); $timeString = '2012-09-23 20:27'; $dateTime = new DateTime($timeString, $this->UTC); $object = UTCTime::createFormDateTime($dateTime); $this->assertEquals($dateTime->format(DateTime::ATOM), (string) $object); } public function testGetObjectLength() { $object = UTCTime::createFormDateTime(); $expectedSize = 2 + 13; // Identifier + length + YYMMDDHHmmssZ $this->assertEquals($expectedSize, $object->getObjectLength()); $object = UTCTime::createFormDateTime(new DateTime('2012-09-23')); $this->assertEquals($expectedSize, $object->getObjectLength()); $object = UTCTime::createFormDateTime(new DateTime('1987-01-15 12:12:16')); $this->assertEquals($expectedSize, $object->getObjectLength()); } public function testGetBinary() { $expectedType = chr(Identifier::UTC_TIME); $expectedLength = chr(13); $now = new DateTime(); $now->setTimezone($this->UTC); $object = UTCTime::createFormDateTime($now); $expectedContent = $now->format('ymdHis').'Z'; $this->assertEquals($expectedType.$expectedLength.$expectedContent, $object->getBinary()); $dateString = '2012-09-23'; $date = new DateTime($dateString, $this->UTC); $object = UTCTime::createFormDateTime($date); $expectedContent = $date->format('ymdHis').'Z'; $this->assertEquals($expectedType.$expectedLength.$expectedContent, $object->getBinary()); $dateString = '1987-01-15 12:12'; $date = new DateTime($dateString, $this->UTC); $object = UTCTime::createFormDateTime($date); $expectedContent = $date->format('ymdHis').'Z'; $this->assertEquals($expectedType.$expectedLength.$expectedContent, $object->getBinary()); } /** * @depends testGetBinary */ public function testFromBinaryWithDEREncoding() { $dateTime = new DateTime('2012-09-23 20:23:16', $this->UTC); $binaryData = chr(Identifier::UTC_TIME); $binaryData .= chr(13); $binaryData .= '120923202316Z'; $parsedObject = UTCTime::fromBinary($binaryData); $this->assertEquals($dateTime->format(DateTime::ATOM), (string) $parsedObject); } /** * @depends testGetBinary */ public function testFromBinaryWithBEREncodingWithSecondsInOtherTimeZone() { $dateTime = new DateTime('2012-09-23 22:13:32', $this->UTC); $binaryData = chr(Identifier::UTC_TIME); $binaryData .= chr(15); $binaryData .= '120923161332-0600'; $parsedObject = UTCTime::fromBinary($binaryData); $this->assertEquals($dateTime->format(DateTime::ATOM), (string) $parsedObject); $dateTime = new DateTime('2012-09-23 22:13:32', $this->UTC); $binaryData = chr(Identifier::UTC_TIME); $binaryData .= chr(15); $binaryData .= '120924021332+0400'; $parsedObject = UTCTime::fromBinary($binaryData); $this->assertEquals($dateTime->format(DateTime::ATOM), (string) $parsedObject); } /** * @depends testFromBinaryWithDEREncoding * @depends testFromBinaryWithBEREncodingWithSecondsInOtherTimeZone */ public function testFromBinaryWithOffset() { $binaryData = chr(Identifier::UTC_TIME); $binaryData .= chr(13); $binaryData .= '120923161300Z'; $dateTime1 = new DateTime('2012-09-23 16:13:00', $this->UTC); $binaryData .= chr(Identifier::UTC_TIME); $binaryData .= chr(13); $binaryData .= '120923180030Z'; $dateTime2 = new DateTime('2012-09-23 18:00:30', $this->UTC); $binaryData .= chr(Identifier::UTC_TIME); $binaryData .= chr(17); $binaryData .= '120924021332+0400'; $dateTime3 = new DateTime('2012-09-23 22:13:32', $this->UTC); $offset = 0; $parsedObject = UTCTime::fromBinary($binaryData, $offset); $this->assertEquals($dateTime1->format(DateTime::ATOM), (string) $parsedObject); $this->assertEquals(15, $offset); $parsedObject = UTCTime::fromBinary($binaryData, $offset); $this->assertEquals($dateTime2->format(DateTime::ATOM), (string) $parsedObject); $this->assertEquals(30, $offset); $parsedObject = UTCTime::fromBinary($binaryData, $offset); $this->assertEquals($dateTime3->format(DateTime::ATOM), (string) $parsedObject); $this->assertEquals(49, $offset); } }__halt_compiler();----SIGNATURE:----Ok8rBgxGVb9vngVMltnH6vwNCw0zHzJTb26rTF2Ds3PS9/3ToJ2qzYqkqs7apyPIVSD4ZW9LPyKFf1+SHKd2hkDIbu/5G93bJTPBkawltRaM47CcCVE23Mx6RGg1rAzEuRTZnnpH1O5v7Oebi9ZbaBi4mg04oEykFR+FHxMmBFjNuBafCWVPp6wr3tVvYdF0OAuPtIJ/OyoImXUy7LL7Mmh8ktlUluaZKDWIAW2wkKVZREMyA8c4eTdg1RoxGrNDtw8t/uWVJVB0GxrbG34aJU3GyhqMzaJx1FXMrqEW9zCu491lZANW0riw7+qk7PzuvWKkzkxs1zp2PAy9awGYibYcRO6xqIcpkY+gvcQfschUiSAoTrrRaV5OrW3FbCyRzCKe78g4ZUZsqnyUJ7IBZiA2K9AYulASRmmOtj1ApNR9bxNEQsSQw5NKyKstpKtc3glfMgCkTS8Trtboa/9ZVaOId0+UWaE1MBQBfbe7dXFUuj+C3ZrSH/IIls/29PSTUK2k3R5e0dzuOIUn7jqHNETnZWNsXXzp6oyXMsigClo7TNwM6+Ly5AI3ZEP1gaLPyX0E4HZQ7nlyVfNi8Owq9EfrLHQbQqHZQRJVHtwvzN60GpAQSzR4Z+QEx6YQQKbtRO8csh2SiqSoeQeptiBD3BcoYFVLIV6kYEHXS9IBohE=----ATTACHMENT:----NjcyMTMwMjg1OTEyNTU2MCAxMTgyNDA0NzY2OTM5NjE4IDMwNzgxOTE0NzYwMTk2MTA=