Files
kimai2/tests/Repository/AbstractRepositoryTest.php
2019-10-24 17:35:05 +02:00

59 lines
1.2 KiB
PHP

<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Repository;
use App\Tests\KernelTestTrait;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* A base test class for AbstractRepository implementations.
*/
abstract class AbstractRepositoryTest extends KernelTestCase
{
use KernelTestTrait;
/**
* @var EntityManager|null
*/
private $entityManager;
/**
* {@inheritdoc}
*/
protected function setUp(): void
{
$kernel = self::bootKernel();
$this->entityManager = $kernel->getContainer()
->get('doctrine')
->getManager();
}
/**
* @return EntityManager
*/
protected function getEntityManager()
{
return $this->entityManager;
}
/**
* {@inheritdoc}
*/
protected function tearDown(): void
{
parent::tearDown();
$this->entityManager->close();
$this->entityManager = null; // avoid memory leaks
}
}