rector/tests/AbstractContainerAwareTestCase.php
2018-07-25 14:18:37 +02:00

37 lines
849 B
PHP

<?php declare(strict_types=1);
namespace Rector\Tests;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Rector\DependencyInjection\ContainerFactory;
abstract class AbstractContainerAwareTestCase extends TestCase
{
/**
* @var ContainerInterface
*/
protected $container;
/**
* @var ContainerInterface
*/
private static $cachedContainer;
/**
* Constructs a test case with the given name.
*
* @param mixed[] $data
*/
public function __construct(?string $name = null, array $data = [], string $dataName = '')
{
if (self::$cachedContainer === null) {
self::$cachedContainer = (new ContainerFactory())->create();
}
$this->container = self::$cachedContainer;
parent::__construct($name, $data, $dataName);
}
}