Rich-Model Mahlzeit (MahlzeitStatus, Wochentag) mit Invarianten und Zustandsübergängen; DTOs + MahlzeitFactory (reine Mapping-Funktionen); Manager (create hängt an Ende an: maxSortOrder+1, find → 404) und Create/Update/Delete-UseCases mit Transaktion + Events nach Commit. Data-Layer: MahlzeitEntity (Tabelle essens_mahlzeiten, wochentage als CSV), Mapper (CSV/Enum/null), Provider (find/list/maxSortOrder), Processor (create/save/delete). DI-Bindings in services.yaml. ClockInterface (Logic) + SystemClock (Data). Tests: Model/Factory/UseCase-Unit + Provider/Processor/Mapper-Integration (In-Mem-SQLite). composer test grün (53 Tests, 161 Assertions).
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Integration\Data\Essen;
|
|
|
|
use App\Data\Essen\Entity\MahlzeitEntity;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Doctrine\ORM\Tools\SchemaTool;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
|
|
/**
|
|
* Basis für DB-Integrationstests auf In-Memory-SQLite:
|
|
* Kernel booten, Schema erzeugen, sauberen EntityManager liefern.
|
|
*/
|
|
abstract class DatabaseTestCase extends KernelTestCase
|
|
{
|
|
protected EntityManagerInterface $em;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$container = static::getContainer();
|
|
$this->em = $container->get('doctrine')->getManager();
|
|
|
|
$schemaTool = new SchemaTool($this->em);
|
|
$schemaTool->dropSchema($this->em->getMetadataFactory()->getAllMetadata());
|
|
$schemaTool->createSchema($this->em->getMetadataFactory()->getAllMetadata());
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
$this->em->close();
|
|
parent::tearDown();
|
|
}
|
|
|
|
/** @return list<MahlzeitEntity> */
|
|
protected function alleEntitaeten(): array
|
|
{
|
|
return $this->em->getRepository(MahlzeitEntity::class)->findAll();
|
|
}
|
|
}
|