futtern/tests/DbWebTest.php
lubiana b479fbf5ed
All checks were successful
/ ls (pull_request) Successful in 31s
/ ls (push) Successful in 31s
#21 add planned closing time to food order
2024-06-27 17:14:59 +02:00

33 lines
1,021 B
PHP

<?php declare(strict_types=1);
namespace App\Tests;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Tools\SchemaTool;
use Override;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
abstract class DbWebTest extends WebTestCase
{
abstract public function getEntityClass(): string;
protected KernelBrowser $client;
protected EntityManagerInterface $manager;
protected EntityRepository $repository;
#[Override]
protected function setUp(): void
{
$this->client = static::createClient();
$this->manager = static::getContainer()->get('doctrine')->getManager();
$schemaTool = new SchemaTool($this->manager);
$metadata = $this->manager->getMetadataFactory()
->getAllMetadata();
$schemaTool->dropDatabase();
$schemaTool->updateSchema($metadata);
$this->repository = $this->manager->getRepository($this->getEntityClass());
}
}