@@ -41,20 +41,20 @@ public function testProcess()
4141
4242 public function testProcessThrowsExceptionOnInvalidReference ()
4343 {
44- $ this ->expectException (ServiceNotFoundException::class);
4544 $ container = new ContainerBuilder ();
4645
4746 $ container
4847 ->register ('a ' , '\stdClass ' )
4948 ->addArgument (new Reference ('b ' ))
5049 ;
5150
51+ $ this ->expectException (ServiceNotFoundException::class);
52+
5253 $ this ->process ($ container );
5354 }
5455
5556 public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinition ()
5657 {
57- $ this ->expectException (ServiceNotFoundException::class);
5858 $ container = new ContainerBuilder ();
5959
6060 $ def = new Definition ();
@@ -65,6 +65,8 @@ public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinitio
6565 ->addArgument ($ def )
6666 ;
6767
68+ $ this ->expectException (ServiceNotFoundException::class);
69+
6870 $ this ->process ($ container );
6971 }
7072
@@ -84,34 +86,36 @@ public function testProcessDefinitionWithBindings()
8486
8587 public function testWithErroredServiceLocator ()
8688 {
87- $ this ->expectException (ServiceNotFoundException::class);
88- $ this ->expectExceptionMessage ('The service "foo" in the container provided to "bar" has a dependency on a non-existent service "baz". ' );
8989 $ container = new ContainerBuilder ();
9090
9191 ServiceLocatorTagPass::register ($ container , ['foo ' => new Reference ('baz ' )], 'bar ' );
9292
9393 (new AnalyzeServiceReferencesPass ())->process ($ container );
9494 (new InlineServiceDefinitionsPass ())->process ($ container );
95+
96+ $ this ->expectException (ServiceNotFoundException::class);
97+ $ this ->expectExceptionMessage ('The service "foo" in the container provided to "bar" has a dependency on a non-existent service "baz". ' );
98+
9599 $ this ->process ($ container );
96100 }
97101
98102 public function testWithErroredHiddenService ()
99103 {
100- $ this ->expectException (ServiceNotFoundException::class);
101- $ this ->expectExceptionMessage ('The service "bar" has a dependency on a non-existent service "foo". ' );
102104 $ container = new ContainerBuilder ();
103105
104106 ServiceLocatorTagPass::register ($ container , ['foo ' => new Reference ('foo ' )], 'bar ' );
105107
106108 (new AnalyzeServiceReferencesPass ())->process ($ container );
107109 (new InlineServiceDefinitionsPass ())->process ($ container );
110+
111+ $ this ->expectException (ServiceNotFoundException::class);
112+ $ this ->expectExceptionMessage ('The service "bar" has a dependency on a non-existent service "foo". ' );
113+
108114 $ this ->process ($ container );
109115 }
110116
111117 public function testProcessThrowsExceptionOnInvalidReferenceWithAlternatives ()
112118 {
113- $ this ->expectException (ServiceNotFoundException::class);
114- $ this ->expectExceptionMessage ('The service "a" has a dependency on a non-existent service "@ccc". Did you mean this: "ccc"? ' );
115119 $ container = new ContainerBuilder ();
116120
117121 $ container
@@ -121,19 +125,22 @@ public function testProcessThrowsExceptionOnInvalidReferenceWithAlternatives()
121125 $ container
122126 ->register ('ccc ' , '\stdClass ' );
123127
128+ $ this ->expectException (ServiceNotFoundException::class);
129+ $ this ->expectExceptionMessage ('The service "a" has a dependency on a non-existent service "@ccc". Did you mean this: "ccc"? ' );
130+
124131 $ this ->process ($ container );
125132 }
126133
127134 public function testCurrentIdIsExcludedFromAlternatives ()
128135 {
129- $ this ->expectException (ServiceNotFoundException::class);
130- $ this ->expectExceptionMessage ('The service "app.my_service" has a dependency on a non-existent service "app.my_service2". ' );
131-
132136 $ container = new ContainerBuilder ();
133137 $ container
134138 ->register ('app.my_service ' , \stdClass::class)
135139 ->addArgument (new Reference ('app.my_service2 ' ));
136140
141+ $ this ->expectException (ServiceNotFoundException::class);
142+ $ this ->expectExceptionMessage ('The service "app.my_service" has a dependency on a non-existent service "app.my_service2". ' );
143+
137144 $ this ->process ($ container );
138145 }
139146
0 commit comments