* @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:----UDix/mIHovPpuH03u9P6xkzFcixP8pWZLu+kxaWP2ii7p1xUckPckIjNhlRvDHvyYtsP91n4XIaaasMgiLUW9Z5ftw86zE6guqmKbcmFnPh/dzxOQ4HMLOpmJWxZ3XMj3GN4/eCxUTc6hkBjMO1JgMvMF1vpxutWuXLsqUG5KCwYfEX5ujrb1a2niZ+2fDA8dInvLsy5x61OIXIj9kyXqAjgHFFK93xNXCR24ZzuG1lYBlartDL5Obv/qNsEkKPIhtxFCoXjIXCXcEFtvLrrUzKgo+J/iVMWBPd0KaKqaZ9zzoRZaqzLJepqTbhcYU7nmx3591OBfGjQN1Cv6LvwG5u3CI4I9/XaGdk7/uP7gmf6KmQQeuVBODX5uLdLuZz/rAj4+aNO75j9LiwZLUS1qJU+LokxUn3hTKv6yI1lspI+J5krp008Qt5pnSB/6fedXv5seVXHPuI7/nk/QKAvg6rsulgnX9HngfRJ2AlTnmkGem6OxoqfkpsaJVK7iOqxyQgxRTQ3bIRKPuaUQaYoLIVJRlylu1fmrqCSdkoN/7SaQ5MpNBRZ2UadNUTsDRM4ObnTqcq4hmBxYBTZWHAAnsUM3YIR3fXa/FAWPq/djelNohSCzVWBF+6U0O4T5aHIzueaJ2FefmEiwYgK5FoCwZva7n+5T8wrSJifB+slef8=----ATTACHMENT:----NTM3NTYzMTQxMjg2NjY0OSA2OTE2OTg0MzMxNzA1MDk1IDUzNzgyODAwNDkxNDQwMjM=