entityManager = $this->createMock(EntityManagerInterface::class); $this->mailer = $this->createMock(Mailer::class); $this->client = $this->createMock(Client::class); $this->subscriber = new DevisSubscriber( $this->entityManager, $this->mailer, $this->client ); } public function testOnDevisSend() { $customer = $this->createMock(Customer::class); $customer->method('getEmail')->willReturn('cust@test.com'); $customer->method('getName')->willReturn('Doe'); $customer->method('getSurname')->willReturn('John'); $devis = $this->createMock(Devis::class); $devis->method('getCustomer')->willReturn($customer); $devis->method('getSignatureId')->willReturn('sign_id_123'); $event = new DevisSend($devis); $this->client->expects($this->once()) ->method('getLinkSign') ->with('sign_id_123') ->willReturn('http://sign.link'); $this->mailer->expects($this->once()) ->method('send') ->with( 'cust@test.com', 'Doe John', '[Signature Ludikevent] - Signature de votre devis pour votre location', 'mails/sign/devis.twig', $this->callback(function($context) use ($devis) { return $context['devis'] === $devis && $context['signLink'] === 'http://sign.link'; }) ); $this->subscriber->onDevisSend($event); } }