コード例 #1
0
 public function testProcessWithoutAlias()
 {
     $container = $this->createContainerBuilderMock();
     $container->expects($this->once())->method('findTaggedServiceIds')->with($this->identicalTo('lug.resource'))->will($this->returnValue([$resource = 'my.resource' => []]));
     $container->expects($this->once())->method('getDefinition')->with($this->identicalTo($resource))->will($this->returnValue($resourceDefinition = $this->createDefinitionMock()));
     $resourceDefinition->expects($this->once())->method('getArgument')->with($this->identicalTo(0))->will($this->returnValue($resourceName = 'resource_name'));
     $container->expects($this->once())->method('hasAlias')->with($this->identicalTo($manager = 'lug.manager.' . $resourceName))->will($this->returnValue(false));
     $container->expects($this->never())->method('getAlias')->with($this->identicalTo($manager));
     $this->compiler->process($container);
 }
コード例 #2
0
 public function testProcess()
 {
     $container = $this->createContainerBuilderMock();
     $container->expects($this->once())->method('findTaggedServiceIds')->with($this->identicalTo('lug.resource'))->will($this->returnValue([$resource = 'my.resource' => []]));
     $container->expects($this->exactly(2))->method('getDefinition')->will($this->returnValueMap([[$resource, $resourceDefinition = $this->createDefinitionMock()], [$alias = 'manager_alias', $aliasDefinition = $this->createDefinitionMock()]]));
     $resourceDefinition->expects($this->once())->method('getArgument')->with($this->identicalTo(0))->will($this->returnValue($resourceName = 'resource_name'));
     $container->expects($this->once())->method('getAlias')->with($this->identicalTo('lug.manager.' . $resourceName))->will($this->returnValue($alias));
     $aliasDefinition->expects($this->once())->method('hasTag')->with($this->identicalTo($tag = 'lug.manager'))->will($this->returnValue(false));
     $aliasDefinition->expects($this->once())->method('addTag')->with($this->identicalTo($tag), $this->identicalTo(['resource' => $resourceName]));
     $this->compiler->process($container);
 }