import('/srv/in', ['stl'])); self::assertSame(1, $built); } public function testLazyServicesBuildTheEngineOnlyOnce(): void { $built = 0; $delegate = new FakeConsoleServices(jobs: [1, 2]); $services = new LazyConsoleServices(function () use (&$built, $delegate): ConsoleServices { $built++; return $delegate; }); $services->runWorkerOnce(static fn (): bool => false); $services->runWorkerOnce(static fn (): bool => false); self::assertSame(1, $built); self::assertSame(2, $delegate->runs); } public function testLazyServicesPropagateConstructionFailures(): void { $services = new LazyConsoleServices(static function (): ConsoleServices { throw new RuntimeException('bad configuration'); }); $this->expectException(RuntimeException::class); $services->runWorkerOnce(static fn (): bool => false); } }