@@ 37-59 (lines=23) @@ | ||
34 | $autowiringCompilerPass->process($containerBuilder); |
|
35 | } |
|
36 | ||
37 | public function testAutowireConstructor() |
|
38 | { |
|
39 | $containerBuilder = new ContainerBuilder(); |
|
40 | $classMultiMap = new ClassMultiMap($containerBuilder); |
|
41 | $classMapBuildCompilerPass = new ClassMapBuildCompilerPass($classMultiMap); |
|
42 | $autowiringCompilerPass = new AutowiringCompilerPass($classMultiMap, new AnnotationReader(), new PhpParser()); |
|
43 | ||
44 | $autowiredServiceDefinition = $containerBuilder->setDefinition("autowiredService", new Definition(AutowiredClass::class)); |
|
45 | $containerBuilder->setDefinition("someService", new Definition(SomeClass::class)); |
|
46 | ||
47 | $this->assertSame([], $autowiredServiceDefinition->getArguments()); |
|
48 | ||
49 | $classMapBuildCompilerPass->process($containerBuilder); |
|
50 | $autowiringCompilerPass->process($containerBuilder); |
|
51 | ||
52 | $arguments = $autowiredServiceDefinition->getArguments(); |
|
53 | $this->assertNotSame([], $arguments); |
|
54 | ||
55 | /** @var Reference $reference */ |
|
56 | $reference = $arguments[0]; |
|
57 | $this->assertInstanceOf(Reference::class, $reference); |
|
58 | $this->assertSame("someService", (string)$reference); |
|
59 | } |
|
60 | ||
61 | public function testAutowireConstructorWithInterface() |
|
62 | { |
|
@@ 61-83 (lines=23) @@ | ||
58 | $this->assertSame("someService", (string)$reference); |
|
59 | } |
|
60 | ||
61 | public function testAutowireConstructorWithInterface() |
|
62 | { |
|
63 | $containerBuilder = new ContainerBuilder(); |
|
64 | $classMultiMap = new ClassMultiMap($containerBuilder); |
|
65 | $classMapBuildCompilerPass = new ClassMapBuildCompilerPass($classMultiMap); |
|
66 | $autowiringCompilerPass = new AutowiringCompilerPass($classMultiMap, new AnnotationReader(), new PhpParser()); |
|
67 | ||
68 | $autowiredServiceDefinition = $containerBuilder->setDefinition("autowiredService", new Definition(InterfaceAutowiredClass::class)); |
|
69 | $containerBuilder->setDefinition("someService", new Definition(SomeClass::class)); |
|
70 | ||
71 | $this->assertSame([], $autowiredServiceDefinition->getArguments()); |
|
72 | ||
73 | $classMapBuildCompilerPass->process($containerBuilder); |
|
74 | $autowiringCompilerPass->process($containerBuilder); |
|
75 | ||
76 | $arguments = $autowiredServiceDefinition->getArguments(); |
|
77 | $this->assertNotSame([], $arguments); |
|
78 | ||
79 | /** @var Reference $reference */ |
|
80 | $reference = $arguments[0]; |
|
81 | $this->assertInstanceOf(Reference::class, $reference); |
|
82 | $this->assertSame("someService", (string)$reference); |
|
83 | } |
|
84 | ||
85 | public function testAutowireConstructorWithInterfaceOptionally() |
|
86 | { |