* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class TimeTest extends TestCase { public function testTime() { $time = new Time('19:35:20'); $this->assertEquals(19, $time->getHour()); $this->assertEquals(35, $time->getMinute()); $this->assertEquals(20, $time->getSecond()); $this->assertEquals(0, $time->getMicroSecond()); $this->assertEquals(0, $time->getOffset()); $this->assertInstanceOf('DateTimeZone', $time->getTimeZone()); $this->assertEquals('19:35:20', $time->toString()); $this->assertEquals('"19:35:20"', \json_encode($time)); } public function testTimeOffset() { $time = new Time('19:35:20+01:00'); $this->assertEquals(19, $time->getHour()); $this->assertEquals(35, $time->getMinute()); $this->assertEquals(20, $time->getSecond()); $this->assertEquals(0, $time->getMicroSecond()); $this->assertEquals(3600, $time->getOffset()); $this->assertInstanceOf('DateTimeZone', $time->getTimeZone()); $this->assertEquals('19:35:20+01:00', $time->toString()); } public function testTimeMicroSeconds() { $time = new Time('19:35:20.1234'); $this->assertEquals(19, $time->getHour()); $this->assertEquals(35, $time->getMinute()); $this->assertEquals(20, $time->getSecond()); $this->assertEquals(123400, $time->getMicroSecond()); $this->assertEquals(0, $time->getOffset()); $this->assertInstanceOf('DateTimeZone', $time->getTimeZone()); $this->assertEquals('19:35:20.123400', $time->toString()); } public function testTimeMicroSecondsAndOffset() { $time = new Time('19:35:20.1234+01:00'); $this->assertEquals(19, $time->getHour()); $this->assertEquals(35, $time->getMinute()); $this->assertEquals(20, $time->getSecond()); $this->assertEquals(123400, $time->getMicroSecond()); $this->assertEquals(3600, $time->getOffset()); $this->assertInstanceOf('DateTimeZone', $time->getTimeZone()); $this->assertEquals('19:35:20.123400+01:00', $time->toString()); } public function testConstructorFull() { $time = new Time(13, 37, 12); $this->assertEquals('13:37:12', $time->toString()); } public function testToString() { $time = new Time(13, 37, 12); $this->assertEquals('13:37:12', (string) $time); } /** * @expectedException \InvalidArgumentException */ public function testTimeEmpty() { new Time(''); } /** * @expectedException \InvalidArgumentException */ public function testTimeInvalid() { new Time('foo'); } /** * @expectedException \InvalidArgumentException */ public function testTimeInvalidOffset() { new Time('19:35:20+50:00'); } /** * @expectedException \InvalidArgumentException */ public function testTimeInvalidMicroSeconds() { new Time('19:35:20.foo'); } public function testFromDateTime() { $time = Time::fromDateTime(new \DateTime('2015-04-25T19:35:20')); $this->assertEquals('19:35:20', $time->toString()); } } __halt_compiler();----SIGNATURE:----ugq27ZOCLYsYCfldlEAfvJbtYFXXfHX066HhQ9OdtlU6eGAjExNEMmpN63I8LpUd+75IX8lhj7Qij24lUUbMF0FzOnGpI9eUgWfP9pERDvkek/GixAbwQ10fxZGbXR3DODKVxLmxyogxguoPyQdNHS1rU6Ee+nolvUVKi60lx7tVbK1zF9RkdQa6/nb1W75929kVYGySkQnEJAAdTDPhnwAs1si99DBOl87rSfgDSr3gTB19h0b+Mb9p9NVMxWxBC9IuiZuHFVg6nBzDwe2RulHR39MNW1lrXh2K6ZfkskmBnuRglfF0uwOqglMX8LZAtoaWMTdqr4PQGqGkPcGg1SRg88WtoXHxA1/faB+RyaqKPDweFdZApdPaaG+Oj9L3QIEAC9vyaD98MG0268kDx6I854c148lENgxVXg9oRWjFgphh8Idj0a+06WtsZgJG+PVAUKhrLkindEKi3+suZlF6BM4vFt12Kz9nrAh6lqNBPqPiaamU7ZVfh3RfUzGa8qNK4bF3ntutUk3VG/XRVEpOla6iojwIR+GywGQiLzlUYK9yNu4iv0JM+FtkHHi8fsSDnbLCJdNxfMPHkPmKz6Q53kgfqkqFQj86B/JT6FrAft4UjFk9BP5n+X7d9L8Y2LrbD6DSSoua2Yf0SFolV5KQsWS6Z2jw54tMAIw1kCc=----ATTACHMENT:----Mzg3NzAzNTc4MTM4ODU5NCAxNDc1MTM1MjQ2NjE1OTQgOTQzODY3NTAyNTQwOTAyMQ==