Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ public function __construct()
new ReplaceAliasByActualDefinitionPass(),
new RemoveAbstractDefinitionsPass(),
new RemoveUnusedDefinitionsPass(),
new AnalyzeServiceReferencesPass(),
new CheckExceptionOnInvalidReferenceBehaviorPass(),
new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()),
new AnalyzeServiceReferencesPass(),
new DefinitionErrorExceptionPass(),
]];

$this->afterRemovingPasses = [[
new CheckExceptionOnInvalidReferenceBehaviorPass(),
new ResolveHotPathPass(),
]];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,47 @@ public function testNoClassFromNsSeparatorId()
$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()
{
$container = new ContainerBuilder();
Expand Down