AbstractContainerAwareTestCase: add simple container cache

This commit is contained in:
Tomas Votruba 2018-04-08 17:45:14 +02:00
parent 4748eadb7b
commit 0af1db6d23

View File

@ -13,6 +13,11 @@ abstract class AbstractContainerAwareTestCase extends TestCase
*/
protected $container;
/**
* @var ContainerInterface
*/
private static $cachedContainer;
/**
* Constructs a test case with the given name.
*
@ -20,8 +25,12 @@ abstract class AbstractContainerAwareTestCase extends TestCase
*/
public function __construct(?string $name = null, array $data = [], string $dataName = '')
{
parent::__construct($name, $data, $dataName);
if (! self::$cachedContainer) {
self::$cachedContainer = (new ContainerFactory())->create();
}
$this->container = (new ContainerFactory())->create();
$this->container = self::$cachedContainer;
parent::__construct($name, $data, $dataName);
}
}