33 lines
937 B
PHP
33 lines
937 B
PHP
<?php
|
|
|
|
namespace App\Tests;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Doctrine\ORM\Tools\SchemaTool;
|
|
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
|
|
abstract class DatabaseWebTestCase extends WebTestCase
|
|
{
|
|
protected KernelBrowser $client;
|
|
protected EntityManagerInterface $entityManager;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
self::ensureKernelShutdown();
|
|
$this->client = self::createClient();
|
|
|
|
$this->entityManager = static::getContainer()->get(EntityManagerInterface::class);
|
|
$metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
|
|
$schemaTool = new SchemaTool($this->entityManager);
|
|
$schemaTool->dropSchema($metadata);
|
|
$schemaTool->createSchema($metadata);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
parent::tearDown();
|
|
|
|
$this->entityManager->close();
|
|
}
|
|
}
|