@@ -256,6 +256,18 @@ public function testGetReturnsNullOnInactiveScope()
256
256
$ this ->assertNull ($ sc ->get ('inactive ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ));
257
257
}
258
258
259
+ /**
260
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
261
+ * @expectedExcepionMessage You have requested a synthetic service ("request"). The DIC does not know how to construct this service.
262
+ */
263
+ public function testGetSyntheticServiceAlwaysThrows ()
264
+ {
265
+ require_once __DIR__ .'/Fixtures/php/services9.php ' ;
266
+
267
+ $ container = new \ProjectServiceContainer ();
268
+ $ container ->get ('request ' , ContainerInterface::NULL_ON_INVALID_REFERENCE );
269
+ }
270
+
259
271
public function testHas ()
260
272
{
261
273
$ sc = new ProjectServiceContainer ();
@@ -287,14 +299,17 @@ public function testEnterLeaveCurrentScope()
287
299
$ container ->addScope (new Scope ('foo ' ));
288
300
289
301
$ container ->enterScope ('foo ' );
302
+ $ container ->set ('foo ' , new \stdClass (), 'foo ' );
290
303
$ scoped1 = $ container ->get ('scoped ' );
291
304
$ scopedFoo1 = $ container ->get ('scoped_foo ' );
292
305
293
306
$ container ->enterScope ('foo ' );
307
+ $ container ->set ('foo ' , new \stdClass (), 'foo ' );
294
308
$ scoped2 = $ container ->get ('scoped ' );
295
309
$ scoped3 = $ container ->get ('SCOPED ' );
296
310
$ scopedFoo2 = $ container ->get ('scoped_foo ' );
297
311
312
+ $ container ->set ('foo ' , null , 'foo ' );
298
313
$ container ->leaveScope ('foo ' );
299
314
$ scoped4 = $ container ->get ('scoped ' );
300
315
$ scopedFoo3 = $ container ->get ('scoped_foo ' );
@@ -641,6 +656,12 @@ protected function getScopedSynchronizedFooService()
641
656
return $ this ->services ['scoped_bar ' ] = $ this ->scopedServices ['foo ' ]['scoped_bar ' ] = new \stdClass ();
642
657
}
643
658
659
+ protected function synchronizeFooService ()
660
+ {
661
+ // Typically get the service to pass it to a setter
662
+ $ this ->get ('foo ' );
663
+ }
664
+
644
665
protected function synchronizeScopedSynchronizedFooService ()
645
666
{
646
667
$ this ->synchronized = true ;
0 commit comments