|
@@ 23-42 (lines=20) @@
|
| 20 |
|
class AutowiringCompilerPassPropertyTest extends TestCase |
| 21 |
|
{ |
| 22 |
|
|
| 23 |
|
public function testAutowireProperty() |
| 24 |
|
{ |
| 25 |
|
$containerBuilder = new ContainerBuilder(); |
| 26 |
|
$classMultiMap = new ClassMultiMap($containerBuilder); |
| 27 |
|
|
| 28 |
|
$classMapBuildCompilerPass = new ClassMapBuildCompilerPass($classMultiMap); |
| 29 |
|
$autowiringCompilerPass = new AutowiringCompilerPass($classMultiMap, new AnnotationReader(), new PhpParser()); |
| 30 |
|
|
| 31 |
|
$autowiredServiceDefinition = $containerBuilder->setDefinition("autowiredService", new Definition(AutowiredPropertyClass::class)); |
| 32 |
|
$containerBuilder->setDefinition("someService", new Definition(SomeClass::class)); |
| 33 |
|
|
| 34 |
|
$this->assertSame([], $autowiredServiceDefinition->getProperties()); |
| 35 |
|
|
| 36 |
|
$classMapBuildCompilerPass->process($containerBuilder); |
| 37 |
|
$autowiringCompilerPass->process($containerBuilder); |
| 38 |
|
|
| 39 |
|
$reference = $autowiredServiceDefinition->getProperties()["property"]; |
| 40 |
|
$this->assertInstanceOf(Reference::class, $reference); |
| 41 |
|
$this->assertSame("someService", (string)$reference); |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
public function testAutowireTraitProperty() |
| 45 |
|
{ |
|
@@ 44-63 (lines=20) @@
|
| 41 |
|
$this->assertSame("someService", (string)$reference); |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
public function testAutowireTraitProperty() |
| 45 |
|
{ |
| 46 |
|
$containerBuilder = new ContainerBuilder(); |
| 47 |
|
$classMultiMap = new ClassMultiMap($containerBuilder); |
| 48 |
|
|
| 49 |
|
$classMapBuildCompilerPass = new ClassMapBuildCompilerPass($classMultiMap); |
| 50 |
|
$autowiringCompilerPass = new AutowiringCompilerPass($classMultiMap, new AnnotationReader(), new PhpParser()); |
| 51 |
|
|
| 52 |
|
$autowiredServiceDefinition = $containerBuilder->setDefinition("service", new Definition(AutowiredClassUsesPropertyTrait::class)); |
| 53 |
|
$containerBuilder->setDefinition("bar", new Definition(Bar::class)); |
| 54 |
|
|
| 55 |
|
$this->assertSame([], $autowiredServiceDefinition->getProperties()); |
| 56 |
|
|
| 57 |
|
$classMapBuildCompilerPass->process($containerBuilder); |
| 58 |
|
$autowiringCompilerPass->process($containerBuilder); |
| 59 |
|
|
| 60 |
|
$reference = $autowiredServiceDefinition->getProperties()["property"]; |
| 61 |
|
$this->assertInstanceOf(Reference::class, $reference); |
| 62 |
|
$this->assertSame("bar", (string)$reference); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
public function testAutowireOverriddenTraitProperty() |
| 66 |
|
{ |
|
@@ 65-85 (lines=21) @@
|
| 62 |
|
$this->assertSame("bar", (string)$reference); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
public function testAutowireOverriddenTraitProperty() |
| 66 |
|
{ |
| 67 |
|
$containerBuilder = new ContainerBuilder(); |
| 68 |
|
$classMultiMap = new ClassMultiMap($containerBuilder); |
| 69 |
|
|
| 70 |
|
$classMapBuildCompilerPass = new ClassMapBuildCompilerPass($classMultiMap); |
| 71 |
|
$autowiringCompilerPass = new AutowiringCompilerPass($classMultiMap, new AnnotationReader(), new PhpParser()); |
| 72 |
|
|
| 73 |
|
$autowiredServiceDefinition = $containerBuilder->setDefinition("service", new Definition(AutowiredClassOverridesPropertyTrait::class)); |
| 74 |
|
$containerBuilder->setDefinition("bar", new Definition(Bar::class)); |
| 75 |
|
$containerBuilder->setDefinition("bar2", new Definition(Bar2::class)); |
| 76 |
|
|
| 77 |
|
$this->assertSame([], $autowiredServiceDefinition->getProperties()); |
| 78 |
|
|
| 79 |
|
$classMapBuildCompilerPass->process($containerBuilder); |
| 80 |
|
$autowiringCompilerPass->process($containerBuilder); |
| 81 |
|
|
| 82 |
|
$reference = $autowiredServiceDefinition->getProperties()["property"]; |
| 83 |
|
$this->assertInstanceOf(Reference::class, $reference); |
| 84 |
|
$this->assertSame("bar2", (string)$reference); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
|
} |
| 88 |
|
|