public function it_can_add_a_penalty_from_a_rent(EventDispatcherInterface $dispatcher, ObjectManager $manager, Locker $locker, FinancialPenalty $penalty, FinancialPenaltyRepository $penaltyRepository, Rental $rental, User $user) { $rental->getLocker()->shouldBeCalled(); $locker->getCode()->shouldBeCalled(); $comment = 'Penalización automática por retraso al entregar la taquilla 100'; $rental->getUser()->shouldBeCalled(); $penaltyRepository->createNew()->shouldBeCalled()->willReturn($penalty); $penalty->setUser($user)->shouldBeCalled(); $penalty->setAmount($this->amount)->shouldBeCalled(); $penalty->setComment($comment)->shouldBeCalled(); $penalty->setRental($rental)->shouldBeCalled(); $manager->persist($penalty)->shouldBeCalled(); $manager->flush()->shouldBeCalled(); $dispatcher->dispatch(PenaltyEvents::PENALTY_CREATED, Argument::type(PenaltyEvent::class))->shouldBeCalled(); $this->penalizeRental($rental); }