This commit is contained in:
lubiana 2025-06-09 19:56:08 +02:00
parent 66c4c1fe4f
commit 2c2e34b71e
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
42 changed files with 910 additions and 939 deletions

View file

@ -1,10 +1,13 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
namespace Tests;
use Exception;
use Override;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\SchemaTool;
use Tests\TestCase;
abstract class DbTestCase extends TestCase
{
@ -13,7 +16,7 @@ abstract class DbTestCase extends TestCase
$em = $this->getContainer()->get(EntityManagerInterface::class);
$metadata = $em->getMetadataFactory()->getAllMetadata();
if (empty($metadata)) {
throw new \Exception('No metadata found. Did you forget to map entities?');
throw new Exception('No metadata found. Did you forget to map entities?');
}
$schemaTool = new SchemaTool($em);
$schemaTool->dropDatabase(); // Clean slate, in case anything exists
@ -21,12 +24,13 @@ abstract class DbTestCase extends TestCase
parent::setUp();
}
#[Override]
protected function tearDown(): void
{
$em = $this->getContainer()->get(EntityManagerInterface::class);
$metadata = $em->getMetadataFactory()->getAllMetadata();
if (empty($metadata)) {
throw new \Exception('No metadata found. Did you forget to map entities?');
throw new Exception('No metadata found. Did you forget to map entities?');
}
$schemaTool = new SchemaTool($em);
$schemaTool->dropDatabase(); // Clean slate, in case anything exists