*/ private array $envBackup = []; protected function setUp(): void { $this->envBackup = $_ENV; } protected function tearDown(): void { $_ENV = $this->envBackup; } public function testGetContainerReturnsPreloadedContainer(): void { $bootstrap = Bootstrap::create(); $container = new class implements ContainerInterface { public function get(string $id): mixed { throw new \RuntimeException('Not expected'); } public function has(string $id): bool { return false; } }; $this->setPrivateProperty($bootstrap, 'container', $container); self::assertSame($container, $bootstrap->getContainer()); self::assertSame($container, $bootstrap->initializeInfrastructure()); } public function testCreateHttpAppReturnsPreloadedApp(): void { $bootstrap = Bootstrap::create(); $app = AppFactory::create(); $this->setPrivateProperty($bootstrap, 'app', $app); self::assertSame($app, $bootstrap->createHttpApp()); } public function testInitializeReturnsPreloadedAppWhenAutoProvisioningDisabled(): void { $_ENV['APP_ENV'] = 'production'; $_ENV['APP_AUTO_PROVISION'] = '0'; $bootstrap = Bootstrap::create(); $container = new class implements ContainerInterface { public function get(string $id): mixed { throw new \RuntimeException('Not expected'); } public function has(string $id): bool { return false; } }; $app = AppFactory::create(); $this->setPrivateProperty($bootstrap, 'container', $container); $this->setPrivateProperty($bootstrap, 'app', $app); self::assertSame($app, $bootstrap->initialize()); } private function setPrivateProperty(object $object, string $property, mixed $value): void { $reflection = new \ReflectionProperty($object, $property); $reflection->setAccessible(true); $reflection->setValue($object, $value); } }