Closed kenjis closed 4 months ago
The return type is object
:
https://github.com/auraphp/Aura.Di/blob/d1908d3170a453682447052d091a4e1a81974ace/src/Injection/Factory.php#L93
And the Doc comment says: https://github.com/auraphp/Aura.Di/blob/d1908d3170a453682447052d091a4e1a81974ace/src/Injection/Factory.php#L82-L84
The test should be:
--- a/tests/ContainerTest.php
+++ b/tests/ContainerTest.php
@@ -190,6 +190,19 @@ class ContainerTest extends TestCase
$this->assertSame($items, $instance->getItems());
}
+ public function testLazyNewInvokable()
+ {
+ $lazy = $this->container->lazyNew(
+ 'Aura\Di\Fake\FakeInvokableClass',
+ ['foo' => 'construct']
+ );
+ $invoke = $lazy('LazyNew');
+ $this->assertInstanceOf('Aura\Di\Fake\FakeInvokableClass', $invoke);
+
+ $output = $invoke('FakeInvokableClass');
+ $this->assertSame('LazyNewFakeInvokableClass', $output);
+ }
+
public function testLockedMagicGet()
{
$this->container->lock();
Tha lazyNew will return an object. I am not sure what you are trying to get from these tests. I did tried your test and looks ok. Is there any specific question or answer you want to address here ?
The return type is a LazyNew
object, which is an implementation of the LazyInterface
.
In 4.x.
The following test code is correct or not?