mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 04:19:44 +01:00
AbstractContainerAwareTestCase: add simple container cache
This commit is contained in:
parent
4748eadb7b
commit
0af1db6d23
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user