Skip to content

Commit

Permalink
fix: compatibility with symfony 5.x and phpunit kernel test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ramunasdronga committed Mar 15, 2023
1 parent fab7e37 commit afe3e49
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Test/AbstractElasticsearchTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private function populateElastic(IndexService $indexService, array $documents =
protected function tearDown(): void
{
parent::tearDown();

self::$cachedContainer = null;
foreach ($this->indexes as $name => $index) {
try {
$index->dropIndex();
Expand All @@ -84,9 +84,12 @@ protected function tearDown(): void

protected static function getContainer($reinitialize = false, $kernelOptions = []): ContainerInterface
{
if (!self::$cachedContainer && !$reinitialize) {
// static::bootKernel($kernelOptions);
if ($reinitialize && self::$booted) {
self::ensureKernelShutdown();
self::$cachedContainer = null;
}

if (!self::$cachedContainer) {
self::$cachedContainer = static::createClient(['environment' => 'test'])->getContainer();
}

Expand Down

0 comments on commit afe3e49

Please sign in to comment.