You are here

public function DefinitionTest::testSetGetDecoratedService in Service Container 7

Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php \Symfony\Component\DependencyInjection\Tests\DefinitionTest::testSetGetDecoratedService()

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php, line 56

Class

DefinitionTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testSetGetDecoratedService() {
  $def = new Definition('stdClass');
  $this
    ->assertNull($def
    ->getDecoratedService());
  $def
    ->setDecoratedService('foo', 'foo.renamed');
  $this
    ->assertEquals(array(
    'foo',
    'foo.renamed',
  ), $def
    ->getDecoratedService());
  $def
    ->setDecoratedService(null);
  $this
    ->assertNull($def
    ->getDecoratedService());
  $def = new Definition('stdClass');
  $def
    ->setDecoratedService('foo');
  $this
    ->assertEquals(array(
    'foo',
    null,
  ), $def
    ->getDecoratedService());
  $def
    ->setDecoratedService(null);
  $this
    ->assertNull($def
    ->getDecoratedService());
  $def = new Definition('stdClass');
  $this
    ->setExpectedException('InvalidArgumentException', 'The decorated service inner name for "foo" must be different than the service name itself.');
  $def
    ->setDecoratedService('foo', 'foo');
}