diff --git a/tests/CompileInjectorTest.php b/tests/CompileInjectorTest.php index be66c6e..0c7bf9b 100644 --- a/tests/CompileInjectorTest.php +++ b/tests/CompileInjectorTest.php @@ -28,7 +28,7 @@ protected function setUp(): void public function testCompile(): void { - $this->injector->compile(); + $this->injector->compile(new FakeLazyModule()()); // built in script $this->assertFileExists(__DIR__ . '/tmp/-Ray_Compiler_Annotation_Compile.php'); $this->assertFileExists(__DIR__ . '/tmp/-Ray_Di_Annotation_ScriptDir.php'); @@ -83,6 +83,7 @@ public function testUnbound(): void public function testUnboundCompileLogFile(): void { $this->expectException(Unbound::class); - $this->injector->getInstance(FakeCar2::class); + $this->assertFileExists(__DIR__ . '/tmp/_bindings.log'); + $this->injector->getInstance(FakeCar3::class); } } diff --git a/tests/VisitorCompilerTest.php b/tests/VisitorCompilerTest.php index 18d2f53..2ca20c0 100644 --- a/tests/VisitorCompilerTest.php +++ b/tests/VisitorCompilerTest.php @@ -71,13 +71,13 @@ public function testDependencyCompile(): Container assert($dependency instanceof AcceptInterface); $code = $dependency->accept(new CompileVisitor($container)); $expected = <<<'EOT' -$instance = new \Ray\Compiler\FakeCar($prototype('Ray\Compiler\FakeEngineInterface-', ['Ray\Compiler\FakeCar', '__construct', 'engine'])); -$instance->setTires($prototype('Ray\Compiler\FakeTyreInterface-', ['Ray\Compiler\FakeCar', 'setTires', 'frontTyre']), $prototype('Ray\Compiler\FakeTyreInterface-', ['Ray\Compiler\FakeCar', 'setTires', 'rearTyre']), NULL); -$instance->setHardtop($prototype('Ray\Compiler\FakeHardtopInterface-', ['Ray\Compiler\FakeCar', 'setHardtop', 'hardtop'])); -$instance->setMirrors($singleton('Ray\Compiler\FakeMirrorInterface-right', ['Ray\Compiler\FakeCar', 'setMirrors', 'rightMirror']), $singleton('Ray\Compiler\FakeMirrorInterface-left', ['Ray\Compiler\FakeCar', 'setMirrors', 'leftMirror'])); -$instance->setSpareMirror($singleton('Ray\Compiler\FakeMirrorInterface-right', ['Ray\Compiler\FakeCar', 'setSpareMirror', 'rightMirror'])); -$instance->setHandle($prototype('Ray\Compiler\FakeHandleInterface-', ['Ray\Compiler\FakeCar', 'setHandle', 'handle'])); -$instance->setOil($prototype('Ray\Compiler\FakeOilInterface-', ['Ray\Compiler\FakeCar', 'setOil', 'oil'])); +$instance = new \Ray\Compiler\FakeCar(\Ray\Compiler\prototype($scriptDir, '/Ray_Compiler_FakeEngineInterface-.php', ['Ray\Compiler\FakeCar', '__construct', 'engine'])); +$instance->setTires(\Ray\Compiler\prototype($scriptDir, '/Ray_Compiler_FakeTyreInterface-.php', ['Ray\Compiler\FakeCar', 'setTires', 'frontTyre']), \Ray\Compiler\prototype($scriptDir, '/Ray_Compiler_FakeTyreInterface-.php', ['Ray\Compiler\FakeCar', 'setTires', 'rearTyre']), NULL); +$instance->setHardtop(\Ray\Compiler\prototype($scriptDir, '/Ray_Compiler_FakeHardtopInterface-.php', ['Ray\Compiler\FakeCar', 'setHardtop', 'hardtop'])); +$instance->setMirrors(\Ray\Compiler\singleton($scriptDir, $singletons, 'Ray\Compiler\FakeMirrorInterface-right', '/Ray_Compiler_FakeMirrorInterface-right.php', ['Ray\Compiler\FakeCar', 'setMirrors', 'rightMirror']), \Ray\Compiler\singleton($scriptDir, $singletons, 'Ray\Compiler\FakeMirrorInterface-left', '/Ray_Compiler_FakeMirrorInterface-left.php', ['Ray\Compiler\FakeCar', 'setMirrors', 'leftMirror'])); +$instance->setSpareMirror(\Ray\Compiler\singleton($scriptDir, $singletons, 'Ray\Compiler\FakeMirrorInterface-right', '/Ray_Compiler_FakeMirrorInterface-right.php', ['Ray\Compiler\FakeCar', 'setSpareMirror', 'rightMirror'])); +$instance->setHandle(\Ray\Compiler\prototype($scriptDir, '/Ray_Compiler_FakeHandleInterface-.php', ['Ray\Compiler\FakeCar', 'setHandle', 'handle'])); +$instance->setOil(\Ray\Compiler\prototype($scriptDir, '/Ray_Compiler_FakeOilInterface-.php', ['Ray\Compiler\FakeCar', 'setOil', 'oil'])); $instance->postConstruct(); $isSingleton = false; return $instance;