. // }}} namespace App\Tests\EventListener; use App\Entity\GSActor; use App\EventListener\UpdateListener; use DateTime; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Event\PreUpdateEventArgs; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\UnitOfWork; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class UpdateListenerTest extends WebTestCase { public function testPreUpdate() { $actor = new GSActor(); $actor->setModified(new DateTime('1999-09-23')); static::assertSame($actor->getModified(), new DateTime('1999-09-23')); $em = $this->createMock(EntityManager::class); $uow = $this->createMock(UnitOfWork::class); $em->expects(static::once()) ->method('getUnitOfWork') ->willReturn($uow); $md = $this->createMock(ClassMetadata::class); $em->expects(static::once()) ->method('getClassMetadata') ->willReturn($md); $change_set = []; $args = new PreUpdateEventArgs($actor, $em, $change_set); $ul = new UpdateListener(); $ul->preUpdate($args); static::assertNotSame($actor->getModified(), new DateTime('1999-09-23')); } }