public function testDateWithPreUpdate() { // Given $user = new BaseUser(); $user->setCreatedAt(\DateTime::createFromFormat('Y-m-d', '2012-01-01')); $today = new \DateTime(); // When $user->preUpdate(); // Then $this->assertTrue($user->getCreatedAt() instanceof \DateTime, 'Should contain a DateTime object'); $this->assertEquals('2012-01-01', $user->getCreatedAt()->format('Y-m-d'), 'Should be created at 2012-01-01.'); $this->assertTrue($user->getUpdatedAt() instanceof \DateTime, 'Should contain a DateTime object'); $this->assertEquals($today->format('Y-m-d'), $user->getUpdatedAt()->format('Y-m-d'), 'Should be updated today'); }