rector/tests/AbstractContainerAwareTestCase.php

37 lines
849 B
PHP
Raw Normal View History

2017-08-18 22:59:59 +02:00
<?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;
2017-08-18 22:59:59 +02:00
/**
* Constructs a test case with the given name.
*
* @param mixed[] $data
*/
2017-08-20 01:02:11 +02:00
public function __construct(?string $name = null, array $data = [], string $dataName = '')
2017-08-18 22:59:59 +02:00
{
2018-07-25 13:06:07 +02:00
if (self::$cachedContainer === null) {
self::$cachedContainer = (new ContainerFactory())->create();
}
$this->container = self::$cachedContainer;
2017-08-18 22:59:59 +02:00
parent::__construct($name, $data, $dataName);
2017-08-18 22:59:59 +02:00
}
}