mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 01:54:41 +08:00
Updated structure for tests config files
This commit is contained in:
31
module/Common/test-db/DbTest/DatabaseTestCase.php
Normal file
31
module/Common/test-db/DbTest/DatabaseTestCase.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user