public function testGetTimestamp() { $this->assertEquals(strtotime($this->datetime), $this->o->getTimestamp()); $o = new DateTime($time = time()); $this->assertEquals($time, $o->getTimestamp()); $o = new DateTime($this->datetime . '.1234'); $this->assertEquals(strtotime($this->datetime), $o->getTimestamp()); try { $o = new DateTime('0000-00-00 00:00:00'); $this->assertEquals($time, $o->getTimestamp()); $this->fail('Exception expected!'); } catch (\Exception $e) { $this->assertEquals('DateTime::format(): The DateTime object has not been correctly initialized by its constructor', $e->getMessage()); } }