Skip to content

Commit 33cfd50

Browse files
minor #57451 [DependencyInjection] Add test coverage for AutowireCallable::buildDefinition() (alexandre-daubois)
This PR was merged into the 6.4 branch. Discussion ---------- [DependencyInjection] Add test coverage for `AutowireCallable::buildDefinition()` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Add tests for #57310 Commits ------- 55d2703 [DependencyInjection] Add test coverage for `AutowireCallable::buildDefinition()`
2 parents 265aca5 + 55d2703 commit 33cfd50

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Symfony/Component/DependencyInjection/Tests/Attribute/AutowireCallableTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,35 @@ public function testArrayCallableWithServiceOnly()
9393
self::assertEquals([new Reference('my_service'), '__invoke'], $attribute->value);
9494
self::assertFalse($attribute->lazy);
9595
}
96+
97+
public function testLazyAsArrayInDefinition()
98+
{
99+
$attribute = new AutowireCallable(callable: [Foo::class, 'myMethod'], lazy: 'my_lazy_class');
100+
101+
self::assertSame([Foo::class, 'myMethod'], $attribute->value);
102+
103+
$definition = $attribute->buildDefinition('my_value', 'my_custom_type', new \ReflectionParameter([Foo::class, 'myMethod'], 'myParameter'));
104+
105+
self::assertSame('my_lazy_class', $definition->getClass());
106+
self::assertTrue($definition->isLazy());
107+
}
108+
109+
public function testLazyIsFalseInDefinition()
110+
{
111+
$attribute = new AutowireCallable(callable: [Foo::class, 'myMethod'], lazy: false);
112+
113+
self::assertFalse($attribute->lazy);
114+
115+
$definition = $attribute->buildDefinition('my_value', 'my_custom_type', new \ReflectionParameter([Foo::class, 'myMethod'], 'myParameter'));
116+
117+
self::assertSame('my_custom_type', $definition->getClass());
118+
self::assertFalse($definition->isLazy());
119+
}
120+
}
121+
122+
class Foo
123+
{
124+
public function myMethod(callable $myParameter)
125+
{
126+
}
96127
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy