Updated structure for tests config files

This commit is contained in:
Alejandro Celaya
2019-01-26 09:09:49 +01:00
parent e7c5cf0846
commit 87ba7a7179
10 changed files with 39 additions and 14 deletions

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\DbTest;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
abstract class DatabaseTestCase extends TestCase
{
protected const ENTITIES_TO_EMPTY = [];
/** @var EntityManagerInterface */
public static $em;
protected function getEntityManager(): EntityManagerInterface
{
return static::$em;
}
public function tearDown()
{
foreach (static::ENTITIES_TO_EMPTY as $entityClass) {
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->delete($entityClass, 'x');
$qb->getQuery()->execute();
}
$this->getEntityManager()->clear();
}
}