@@ -256,6 +256,18 @@ public function testGetReturnsNullOnInactiveScope()
256256 $ this ->assertNull ($ sc ->get ('inactive ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ));
257257 }
258258
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+
259271 public function testHas ()
260272 {
261273 $ sc = new ProjectServiceContainer ();
@@ -287,14 +299,17 @@ public function testEnterLeaveCurrentScope()
287299 $ container ->addScope (new Scope ('foo ' ));
288300
289301 $ container ->enterScope ('foo ' );
302+ $ container ->set ('foo ' , new \stdClass (), 'foo ' );
290303 $ scoped1 = $ container ->get ('scoped ' );
291304 $ scopedFoo1 = $ container ->get ('scoped_foo ' );
292305
293306 $ container ->enterScope ('foo ' );
307+ $ container ->set ('foo ' , new \stdClass (), 'foo ' );
294308 $ scoped2 = $ container ->get ('scoped ' );
295309 $ scoped3 = $ container ->get ('SCOPED ' );
296310 $ scopedFoo2 = $ container ->get ('scoped_foo ' );
297311
312+ $ container ->set ('foo ' , null , 'foo ' );
298313 $ container ->leaveScope ('foo ' );
299314 $ scoped4 = $ container ->get ('scoped ' );
300315 $ scopedFoo3 = $ container ->get ('scoped_foo ' );
@@ -641,6 +656,12 @@ protected function getScopedSynchronizedFooService()
641656 return $ this ->services ['scoped_bar ' ] = $ this ->scopedServices ['foo ' ]['scoped_bar ' ] = new \stdClass ();
642657 }
643658
659+ protected function synchronizeFooService ()
660+ {
661+ // Typically get the service to pass it to a setter
662+ $ this ->get ('foo ' );
663+ }
664+
644665 protected function synchronizeScopedSynchronizedFooService ()
645666 {
646667 $ this ->synchronized = true ;
0 commit comments