| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [x] Pas de régression - [x] TU/TI/TF rédigée - [x] TU/TI/TF OK - [ ] CHANGELOG modifié Co-authored-by: Matthieu <mtholot19@gmail.com> Reviewed-on: MALIO-DEV/Coltura#8 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #8.
This commit is contained in:
74
tests/Fixtures/SiteAware/FakeSiteAwareEntity.php
Normal file
74
tests/Fixtures/SiteAware/FakeSiteAwareEntity.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Fixtures\SiteAware;
|
||||
|
||||
use App\Module\Sites\Domain\Entity\Site;
|
||||
use App\Shared\Domain\Contract\SiteAwareInterface;
|
||||
use App\Shared\Domain\Contract\SiteInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Entite fictive utilisee UNIQUEMENT en tests (ticket 4 module Sites).
|
||||
*
|
||||
* Implemente SiteAwareInterface pour valider que l'outillage
|
||||
* (SiteScopedQueryExtension + SiteAwareInjectionProcessor) se comporte
|
||||
* correctement sans avoir a adopter le pattern sur une entite metier
|
||||
* reelle. Le mapping Doctrine n'est charge qu'en environnement `test`
|
||||
* via un bloc `when@test` dans `config/packages/doctrine.yaml`, donc
|
||||
* cette classe n'existe jamais dans un schema prod.
|
||||
*
|
||||
* Le nom de table `fake_site_aware_entity` est volontairement verbeux
|
||||
* pour reduire le risque de collision avec une future table metier.
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'fake_site_aware_entity')]
|
||||
class FakeSiteAwareEntity implements SiteAwareInterface
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 100)]
|
||||
private string $name;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Site::class)]
|
||||
#[ORM\JoinColumn(name: 'site_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
|
||||
private ?Site $site = null;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getSite(): ?SiteInterface
|
||||
{
|
||||
return $this->site;
|
||||
}
|
||||
|
||||
public function setSite(SiteInterface $site): void
|
||||
{
|
||||
if (!$site instanceof Site) {
|
||||
throw new InvalidArgumentException('FakeSiteAwareEntity requires a concrete Site (Doctrine ManyToOne target).');
|
||||
}
|
||||
$this->site = $site;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user