'bar']); $storedObject = $exportGeneration->getStoredObject(); // 3. Mock ExportGenerationRepository to return the ExportGeneration $exportGenerationRepository = $this->prophesize(ExportGenerationRepository::class); $exportGenerationRepository ->find($exportGeneration->getId()) ->willReturn($exportGeneration); // 4. Mock EntityManagerInterface and set expectations $entityManager = $this->prophesize(EntityManagerInterface::class); $entityManager->remove($exportGeneration)->shouldBeCalled(); $entityManager->flush()->shouldBeCalled(); // 6. Create message $message = new RemoveExportGenerationMessage($exportGeneration); // 7. Handler instantiation $handler = new RemoveExportGenerationMessageHandler( $exportGenerationRepository->reveal(), $entityManager->reveal(), new NullLogger(), $clock ); // Pre-condition: deleteAt not set. $this->assertNull($storedObject->getDeleteAt()); // Act $handler->__invoke($message); // Assert $this->assertEquals($now, $storedObject->getDeleteAt(), 'deleteAt of stored object was updated'); } }