Files
kimai2/tests/Repository/AbstractRepositoryTest.php

59 lines
1.1 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
*/
private $entityManager;
/**
* {@inheritdoc}
*/
protected function setUp()
{
$kernel = self::bootKernel();
$this->entityManager = $kernel->getContainer()
->get('doctrine')
->getManager();
}
/**
* @return EntityManager
*/
protected function getEntityManager()
{
return $this->entityManager;
}
/**
* {@inheritdoc}
*/
protected function tearDown()
{
parent::tearDown();
$this->entityManager->close();
$this->entityManager = null; // avoid memory leaks
}
}