ensure that an uncompiled instance isn't changed by a compiled one

This commit is contained in:
Daniel Seifert 2024-08-27 14:59:43 +02:00
parent 2408572bae
commit b7cc4d70ba
2 changed files with 18 additions and 0 deletions

View File

@ -50,6 +50,7 @@ class d3DicHandler implements d3DicHandlerInterface
*/
public static function getUncompiledInstance(): Container
{
if (self::$_instance !== null && self::$_instance->isCompiled()) {self::removeInstance();}
return oxNew(d3DicHandler::class)->createInstance(false);
}

View File

@ -89,6 +89,7 @@ class d3DicHandlerTest extends TestCase
{
$sut = new d3DicHandler();
// test new instance
$containerBuilder = $this->callMethod(
$sut,
'getUncompiledInstance'
@ -100,6 +101,22 @@ class d3DicHandlerTest extends TestCase
);
$this->assertFalse($containerBuilder->isCompiled());
// test if compiled instance is getting resetted
$this->callMethod(
$sut,
'removeInstance'
);
$this->callMethod(
$sut,
'getInstance'
);
$containerBuilder = $this->callMethod(
$sut,
'getUncompiledInstance'
);
$this->assertFalse($containerBuilder->isCompiled());
}
/**