public function it_can_return_a_locker_after_due_date(Locker $locker, Rental $rental, EntityManager $manager, EventDispatcherInterface $dispatcher, TimePenaltyService $penaltyService) { $rental->getDaysLate()->shouldBeCalled()->willReturn(1); $rental->setReturnAt(Argument::type(\DateTime::class))->shouldBeCalled(); $penaltyService->penalizeRental($rental)->shouldBeCalled(); $locker->setOwner(null)->shouldBeCalled(); $locker->setStatus(Locker::AVAILABLE)->shouldBeCalled(); $manager->persist($rental)->shouldBeCalled(); $manager->persist($locker)->shouldBeCalled(); $manager->flush()->shouldBeCalled(); $dispatcher->dispatch(RentalEvents::LOCKER_RETURNED, Argument::type(RentalEvent::class))->shouldBeCalled(); $this->returnRental($rental); }