File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -82,13 +82,14 @@ public function __construct()
82
82
new ReplaceAliasByActualDefinitionPass (),
83
83
new RemoveAbstractDefinitionsPass (),
84
84
new RemoveUnusedDefinitionsPass (),
85
+ new AnalyzeServiceReferencesPass (),
86
+ new CheckExceptionOnInvalidReferenceBehaviorPass (),
85
87
new InlineServiceDefinitionsPass (new AnalyzeServiceReferencesPass ()),
86
88
new AnalyzeServiceReferencesPass (),
87
89
new DefinitionErrorExceptionPass (),
88
90
]];
89
91
90
92
$ this ->afterRemovingPasses = [[
91
- new CheckExceptionOnInvalidReferenceBehaviorPass (),
92
93
new ResolveHotPathPass (),
93
94
]];
94
95
}
Original file line number Diff line number Diff line change @@ -1316,6 +1316,47 @@ public function testNoClassFromNsSeparatorId()
1316
1316
$ container ->compile ();
1317
1317
}
1318
1318
1319
+ public function testGetThrownServiceNotFoundExceptionWithCorrectServiceId ()
1320
+ {
1321
+ $ this ->expectException (ServiceNotFoundException::class);
1322
+ $ this ->expectExceptionMessage ('The service "child_service" has a dependency on a non-existent service "non_existent_service". ' );
1323
+
1324
+ $ container = new ContainerBuilder ();
1325
+ $ container ->register ('child_service ' , \stdClass::class)
1326
+ ->setPublic (false )
1327
+ ->addArgument ([
1328
+ 'non_existent ' => new Reference ('non_existent_service ' ),
1329
+ ])
1330
+ ;
1331
+ $ container ->register ('parent_service ' , \stdClass::class)
1332
+ ->setPublic (true )
1333
+ ->addArgument ([
1334
+ 'child_service ' => new Reference ('child_service ' ),
1335
+ ])
1336
+ ;
1337
+
1338
+ $ container ->compile ();
1339
+ }
1340
+
1341
+ public function testUnusedServiceRemovedByPassAndServiceNotFoundExceptionWasNotThrown ()
1342
+ {
1343
+ $ container = new ContainerBuilder ();
1344
+ $ container ->register ('service ' , \stdClass::class)
1345
+ ->setPublic (false )
1346
+ ->addArgument ([
1347
+ 'non_existent_service ' => new Reference ('non_existent_service ' ),
1348
+ ])
1349
+ ;
1350
+
1351
+ try {
1352
+ $ container ->compile ();
1353
+ } catch (ServiceNotFoundException $ e ) {
1354
+ $ this ->fail ('Should not be thrown ' );
1355
+ }
1356
+
1357
+ $ this ->addToAssertionCount (1 );
1358
+ }
1359
+
1319
1360
public function testServiceLocator ()
1320
1361
{
1321
1362
$ container = new ContainerBuilder ();
You can’t perform that action at this time.
0 commit comments