diff --git a/tests/AbstractContainerAwareTestCase.php b/tests/AbstractContainerAwareTestCase.php index cbd0c7b6326..a11e37e7c57 100644 --- a/tests/AbstractContainerAwareTestCase.php +++ b/tests/AbstractContainerAwareTestCase.php @@ -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); } }