* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\DependencyInjection\Tests\Compiler; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; require_once __DIR__.'/../Fixtures/includes/foo.php'; class ReplaceAliasByActualDefinitionPassTest extends TestCase { public function testProcess() { $container = new ContainerBuilder(); $aDefinition = $container->register('a', '\stdClass'); $aDefinition->setFactory(array(new Reference('b'), 'createA')); $bDefinition = new Definition('\stdClass'); $bDefinition->setPublic(false); $container->setDefinition('b', $bDefinition); $container->setAlias('a_alias', 'a'); $container->setAlias('b_alias', 'b'); $container->setAlias('container', 'service_container'); $this->process($container); $this->assertTrue($container->has('a'), '->process() does nothing to public definitions.'); $this->assertTrue($container->hasAlias('a_alias')); $this->assertFalse($container->has('b'), '->process() removes non-public definitions.'); $this->assertTrue( $container->has('b_alias') && !$container->hasAlias('b_alias'), '->process() replaces alias to actual.' ); $this->assertTrue($container->has('container')); $resolvedFactory = $aDefinition->getFactory(); $this->assertSame('b_alias', (string) $resolvedFactory[0]); } /** * @expectedException \InvalidArgumentException */ public function testProcessWithInvalidAlias() { $container = new ContainerBuilder(); $container->setAlias('a_alias', 'a'); $this->process($container); } protected function process(ContainerBuilder $container) { $pass = new ReplaceAliasByActualDefinitionPass(); $pass->process($container); } } __halt_compiler();----SIGNATURE:----CBmHQO32vJd9KAtZdUrMchi3v3PMrM4RugMsAntFHYLmuPyQ9v6GTlFuqF/S2vQ8/SVF2qgGHEAatzpn2ol195B6F7kAdP27tcSNO22yxdINfB7Q6VaQwMAIneXKN1jz42619yyS7LdfhAo9RVdPYQVlJwUuxpyWdWWtJ/2szbDdAwDaVOOM4wzL+QHPaCXpyqo+L6BXQVK6FC+/Tw9+I4jT02zouwJqVZPvGxYVvS+ohIG6R2edLRvfPrAece+45uupHgIfzK23h+vyUqCtXMHlrR9tOUT9jmm3hL0UrSV+Nrckw1Dn/xYhwlsY77HG6To+yD7liWhOL6ihan/3jaVHpYqKKNz9I8kx7cv1aNKY9skf7xmF8IOGOannl52QY5HIm5iIgH1n6lf2lUH5SGB13ejojMuCvnzcP+knBSGASEF7E/JST8i+Xkq9UWxgbNdufMpxTmFJfpiRzZt/OKuu8t15h84/fuwY3bgiGvQPoPBqz2TuWj0UoHqxLFiQi+ZzrePtaC3lABOwoFWQ8EHd3ZF135tzpkBRDmeRrg+h1GwGCFyt24WTrd9UqmxlqD2uIHD+uQ5Z7trm7Dm5KNTc9sl3A+kj531DadrDJwKK7tLTodcHp5PXm2P1Up/2FkAHoqZMNJUeSmI2PHcaZWwn7Vdb+0X7kG55mO8gNCc=----ATTACHMENT:----NzkzMTk1NDU3NzMzMzkzMiA3NjM0NTE1ODk3ODY1NjQzIDU3NzUzMzg4MTI0MjEwMjA=