← Back
Editing: ReportControlProviderTrait.php
<?php namespace App\Tests\Unit\Report\Control; use App\Entity\Adresse; use App\Entity\Agency; use App\Entity\AgencyPrestataire; use App\Entity\Controle; use App\Entity\Prestataire; use App\Entity\Solution; use App\Entity\User; use App\Entity\UserEmailAlias; use DateTime; use Symfony\Bridge\Twig\Mime\TemplatedEmail; trait ReportControlProviderTrait { protected User $mockAgent; protected User $mockManager; protected Adresse $mockAddress; protected Solution $mockSolution; protected Prestataire $mockProvider; protected Agency $mockAgency; public function __construct(?string $name = null, array $data = [], $dataName = '') { $this->initMockObjects(); parent::__construct($name, $data, $dataName); } protected function getControlProvider(): iterable { $control1 = (new Controle()) ->setAgent($this->mockAgent) ->setReceiveReport(true) ->setAdresse($this->mockAddress); yield [ $control1, ['rapport' => true], 1, ['agent@bar.com', 'agent-alias@bar.com'], ]; $control2 = (new Controle()) ->setAgent($this->mockAgent) ->setAlertePrestataire(true) ->setReceiveReport(true) ->setAdresse($this->mockAddress); yield [ $control2, ['rapport' => true], 3, ['agent@bar.com', 'manager@bar.com', 'provider@provider.com', 'agent-alias@bar.com', 'manager-alias@bar.com'], ]; } protected function initMockObjects(): void { $this->mockSolution = $this->getSolution(); $this->mockAgency = $this->getAgency(); $this->mockProvider = $this->getProvider(); $this->mockManager = $this->getManager(); $this->mockAgent = $this->getAgent(); $this->mockAddress = $this->getAddress(); } protected function getAgent(): User { return (new User()) ->setEmail('agent@bar.com') ->setEmailCanonical('foo@bar.com') ->setUsername('foo@bar.com') ->setUsernameCanonical('foo@bar.com') ->addEmailAlias((new UserEmailAlias())->setEmail('agent-alias@bar.com')) ->setRoles(['ROLE_USER', 'ROLE_AGENT']); } protected function getManager(): User { return (new User()) ->setEmail('manager@bar.com') ->setEmailCanonical('manager@bar.com') ->setUsername('manager@bar.com') ->setUsernameCanonical('manager@bar.com') ->addEmailAlias((new UserEmailAlias())->setEmail('manager-alias@bar.com')) ->setRoles(['ROLE_USER', 'ROLE_MANAGER']); } protected function getAddress(): Adresse { return (new Adresse()) ->addPrestataire($this->mockProvider) ->setManager($this->mockManager) ->setAgency($this->mockAgency) ->setSolution($this->mockSolution) ->setVoie('1 rue test') ->setVille('Fontenay sous test') ->setCodePostal('94AH23'); } protected function getProvider(): Prestataire { return (new Prestataire()) ->setNom('Foo provider') ->addAgencyPrestataire( (new AgencyPrestataire()) ->setMailContact('provider@provider.com') ); } protected function getSolution(): Solution { return (new Solution()) ->setEmail('contact@arithmetic.fr'); } protected function getAgency(): Agency { return (new Agency()) ->setNom('Agency test') ->setMailContact('foo@agency.bar'); } }
Save File
Cancel