testitest
This commit is contained in:
parent
43ca79f650
commit
66c4c1fe4f
30 changed files with 4443 additions and 184 deletions
36
tests/DbTestCase.php
Normal file
36
tests/DbTestCase.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Tests\TestCase;
|
||||
|
||||
abstract class DbTestCase extends TestCase
|
||||
{
|
||||
protected function setUp(): 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?');
|
||||
}
|
||||
$schemaTool = new SchemaTool($em);
|
||||
$schemaTool->dropDatabase(); // Clean slate, in case anything exists
|
||||
$schemaTool->createSchema($metadata);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
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?');
|
||||
}
|
||||
$schemaTool = new SchemaTool($em);
|
||||
$schemaTool->dropDatabase(); // Clean slate, in case anything exists
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue