```
✨ feat(revervation): [Ajoute la création de session de réservation et le flow] 🐛 fix(PurgeCommandTest): [Utilise addCommand au lieu de add pour les commandes] 📝 chore(deps): [Mise à jour des dépendances Composer et corrections] 🐛 fix(KeycloakAuthenticator): [Corrige le type nullable de l'exception start] ✨ feat(Customer): [Ajoute les sessions de commandes aux entités Customer] ♻️ refactor(AppLogger): [Refactorise l'AppLogger pour obtenir l'UserAgent] ✨ feat(FlowReserve): [Ajoute une action de validation du panier] ```
This commit is contained in:
68
tests/Event/Signature/DevisSubscriberTest.php
Normal file
68
tests/Event/Signature/DevisSubscriberTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Event\Signature;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Devis;
|
||||
use App\Event\Signature\DevisSend;
|
||||
use App\Event\Signature\DevisSubscriber;
|
||||
use App\Service\Mailer\Mailer;
|
||||
use App\Service\Signature\Client;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[AllowMockObjectsWithoutExpectations]
|
||||
class DevisSubscriberTest extends TestCase
|
||||
{
|
||||
private $entityManager;
|
||||
private $mailer;
|
||||
private $client;
|
||||
private $subscriber;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user