[DependencyInjection] Fixed incorrect report for private services if required service does not exist
This commit is contained in:
parent
42061de4e4
commit
39bd05c5bc
@ -82,13 +82,14 @@ class PassConfig
|
|||||||
new ReplaceAliasByActualDefinitionPass(),
|
new ReplaceAliasByActualDefinitionPass(),
|
||||||
new RemoveAbstractDefinitionsPass(),
|
new RemoveAbstractDefinitionsPass(),
|
||||||
new RemoveUnusedDefinitionsPass(),
|
new RemoveUnusedDefinitionsPass(),
|
||||||
|
new AnalyzeServiceReferencesPass(),
|
||||||
|
new CheckExceptionOnInvalidReferenceBehaviorPass(),
|
||||||
new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()),
|
new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()),
|
||||||
new AnalyzeServiceReferencesPass(),
|
new AnalyzeServiceReferencesPass(),
|
||||||
new DefinitionErrorExceptionPass(),
|
new DefinitionErrorExceptionPass(),
|
||||||
]];
|
]];
|
||||||
|
|
||||||
$this->afterRemovingPasses = [[
|
$this->afterRemovingPasses = [[
|
||||||
new CheckExceptionOnInvalidReferenceBehaviorPass(),
|
|
||||||
new ResolveHotPathPass(),
|
new ResolveHotPathPass(),
|
||||||
]];
|
]];
|
||||||
}
|
}
|
||||||
|
@ -1316,6 +1316,47 @@ class ContainerBuilderTest extends TestCase
|
|||||||
$container->compile();
|
$container->compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetThrownServiceNotFoundExceptionWithCorrectServiceId()
|
||||||
|
{
|
||||||
|
$this->expectException(ServiceNotFoundException::class);
|
||||||
|
$this->expectExceptionMessage('The service "child_service" has a dependency on a non-existent service "non_existent_service".');
|
||||||
|
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->register('child_service', \stdClass::class)
|
||||||
|
->setPublic(false)
|
||||||
|
->addArgument([
|
||||||
|
'non_existent' => new Reference('non_existent_service'),
|
||||||
|
])
|
||||||
|
;
|
||||||
|
$container->register('parent_service', \stdClass::class)
|
||||||
|
->setPublic(true)
|
||||||
|
->addArgument([
|
||||||
|
'child_service' => new Reference('child_service'),
|
||||||
|
])
|
||||||
|
;
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUnusedServiceRemovedByPassAndServiceNotFoundExceptionWasNotThrown()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->register('service', \stdClass::class)
|
||||||
|
->setPublic(false)
|
||||||
|
->addArgument([
|
||||||
|
'non_existent_service' => new Reference('non_existent_service'),
|
||||||
|
])
|
||||||
|
;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$container->compile();
|
||||||
|
} catch (ServiceNotFoundException $e) {
|
||||||
|
$this->fail('Should not be thrown');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addToAssertionCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
public function testServiceLocator()
|
public function testServiceLocator()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
Reference in New Issue
Block a user