|
@@ 32-46 (lines=15) @@
|
| 29 |
|
$this->definitionAnalyzer = new DefinitionAnalyzer(new DefinitionValidator()); |
| 30 |
|
} |
| 31 |
|
|
| 32 |
|
public function testServiceFactoryMethodDoesNotHaveArguments() |
| 33 |
|
{ |
| 34 |
|
$containerBuilder = new ContainerBuilder(); |
| 35 |
|
$containerBuilder->addDefinitions([ |
| 36 |
|
'factory' => new Definition(EmptyConstructorFactory::class), |
| 37 |
|
]); |
| 38 |
|
|
| 39 |
|
$definition = new Definition(EmptyConstructor::class); |
| 40 |
|
$definition->setFactory([ |
| 41 |
|
new Reference('factory'), |
| 42 |
|
'create', |
| 43 |
|
]); |
| 44 |
|
|
| 45 |
|
$this->assertFalse($this->definitionAnalyzer->shouldDefinitionBeAutowired($containerBuilder, $definition)); |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
public function testFactoryMethodDoesNotHaveArguments() |
| 49 |
|
{ |
|
@@ 59-75 (lines=17) @@
|
| 56 |
|
$this->assertFalse($this->definitionAnalyzer->shouldDefinitionBeAutowired(new ContainerBuilder(), $definition)); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
public function testServiceFactoryBuiltClassHaveMissingArgumentsTypehints() |
| 60 |
|
{ |
| 61 |
|
$containerBuilder = new ContainerBuilder(); |
| 62 |
|
$containerBuilder->addDefinitions([ |
| 63 |
|
'factory' => new Definition(MissingArgumentsTypehintsFactory::class), |
| 64 |
|
]); |
| 65 |
|
|
| 66 |
|
$definition = new Definition(MissingArgumentsTypehints::class); |
| 67 |
|
$definition->setFactory([ |
| 68 |
|
new Reference('factory'), |
| 69 |
|
'create', |
| 70 |
|
]); |
| 71 |
|
|
| 72 |
|
$definition->setArguments(['@someService']); |
| 73 |
|
|
| 74 |
|
$this->assertFalse($this->definitionAnalyzer->shouldDefinitionBeAutowired($containerBuilder, $definition)); |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
public function testFactoryBuiltClassHaveMissingArgumentsTypehints() |
| 78 |
|
{ |
|
@@ 90-106 (lines=17) @@
|
| 87 |
|
$this->assertFalse($this->definitionAnalyzer->shouldDefinitionBeAutowired(new ContainerBuilder(), $definition)); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
public function testServiceFactoryBuiltClassHaveNotMissingArgumentsTypehints() |
| 91 |
|
{ |
| 92 |
|
$containerBuilder = new ContainerBuilder(); |
| 93 |
|
$containerBuilder->addDefinitions([ |
| 94 |
|
'factory' => new Definition(NotMissingArgumentsTypehintsFactory::class), |
| 95 |
|
]); |
| 96 |
|
|
| 97 |
|
$definition = new Definition(NotMissingArgumentsTypehints::class); |
| 98 |
|
$definition->setFactory([ |
| 99 |
|
new Reference('factory'), |
| 100 |
|
'create', |
| 101 |
|
]); |
| 102 |
|
|
| 103 |
|
$definition->setArguments(['@someService']); |
| 104 |
|
|
| 105 |
|
$this->assertTrue($this->definitionAnalyzer->shouldDefinitionBeAutowired($containerBuilder, $definition)); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
public function testFactoryBuiltClassHaveNotMissingArgumentsTypehints() |
| 109 |
|
{ |