You are here

public function ContainerTest::testSetAlsoSetsScopedService in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testSetAlsoSetsScopedService()

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerTest.php, line 191

Class

ContainerTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testSetAlsoSetsScopedService() {
  $c = new Container();
  $c
    ->addScope(new Scope('foo'));
  $c
    ->enterScope('foo');
  $c
    ->set('foo', $foo = new \stdClass(), 'foo');
  $scoped = $this
    ->getField($c, 'scopedServices');
  $this
    ->assertTrue(isset($scoped['foo']['foo']), '->set() sets a scoped service');
  $this
    ->assertSame($foo, $scoped['foo']['foo'], '->set() sets a scoped service');
}