Test service with factory is not tagged
This commit is contained in:
parent
2d2cd40ba6
commit
a8e9f4092c
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
|
||||
|
||||
class BarFactory
|
||||
{
|
||||
/**
|
||||
* @var iterable
|
||||
*/
|
||||
private $bars;
|
||||
|
||||
public function __construct(iterable $bars)
|
||||
{
|
||||
$this->bars = \iterator_to_array($bars);
|
||||
}
|
||||
|
||||
public function getDefaultBar(): BarInterface
|
||||
{
|
||||
return reset($this->bars);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
services:
|
||||
_instanceof:
|
||||
Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface:
|
||||
tags:
|
||||
- { name: bar }
|
||||
|
||||
Symfony\Component\DependencyInjection\Tests\Fixtures\Bar:
|
||||
public: true
|
||||
|
||||
Symfony\Component\DependencyInjection\Tests\Fixtures\BarFactory:
|
||||
arguments: [!tagged 'bar']
|
||||
|
||||
Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface:
|
||||
factory: ['@Symfony\Component\DependencyInjection\Tests\Fixtures\BarFactory', 'getDefaultBar']
|
@ -770,4 +770,15 @@ class YamlFileLoaderTest extends TestCase
|
||||
$definition = $container->getDefinition('foo');
|
||||
$this->assertSame([['interface' => 'SomeInterface']], $definition->getTag('proxy'));
|
||||
}
|
||||
|
||||
public function testServiceWithSameNameAsInterfaceAndFactoryIsNotTagged()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('service_instanceof_factory.yml');
|
||||
$container->compile();
|
||||
|
||||
$tagged = $container->findTaggedServiceIds('bar');
|
||||
$this->assertCount(1, $tagged);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user