← Back
Editing: ControlSubscriberTest.php
<?php namespace App\Tests\Unit\EventSubscriber; use App\Entity\Controle; use App\Event\ControlSentEvent; use App\EventSubscriber\ControlSubscriber; use App\Report\Control\ReportControlFactory; use App\Repository\AddressReminderRepository; use App\Tests\Unit\Report\Control\ReportControlProviderTrait; use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; class ControlSubscriberTest extends TestCase { use ProphecyTrait; use ReportControlProviderTrait; private ControlSubscriber $subscriber; /** @var ObjectProphecy|AddressReminderRepository */ private ObjectProphecy $addressReminderRepository; /** @var ObjectProphecy|EntityManagerInterface */ private ObjectProphecy $emStub; /** @var ObjectProphecy|ReportControlFactory */ private ObjectProphecy $reportControlFactoryStub; protected function setUp(): void { $this->emStub = $this->prophesize(EntityManagerInterface::class); $this->addressReminderRepository = $this->prophesize(AddressReminderRepository::class); $this->reportControlFactoryStub = $this->prophesize(ReportControlFactory::class); $this->subscriber = new ControlSubscriber( $this->emStub->reveal(), $this->addressReminderRepository->reveal(), $this->reportControlFactoryStub->reveal() ); } /** * @dataProvider getControlProvider */ public function testEmails( Controle $control, array $receivedControl ): void { $this->addressReminderRepository->findBy(Argument::any())->willReturn([]); $sentEvent = new ControlSentEvent($control, $receivedControl); $this->subscriber->onControlSent($sentEvent); $this->reportControlFactoryStub->send($control)->shouldHaveBeenCalled(); } }
Save File
Cancel