* * 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\CheckDefinitionValidityPass; use Symfony\Component\DependencyInjection\ContainerBuilder; class CheckDefinitionValidityPassTest extends TestCase { /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException */ public function testProcessDetectsSyntheticNonPublicDefinitions() { $container = new ContainerBuilder(); $container->register('a')->setSynthetic(true)->setPublic(false); $this->process($container); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException */ public function testProcessDetectsNonSyntheticNonAbstractDefinitionWithoutClass() { $container = new ContainerBuilder(); $container->register('a')->setSynthetic(false)->setAbstract(false); $this->process($container); } public function testProcess() { $container = new ContainerBuilder(); $container->register('a', 'class'); $container->register('b', 'class')->setSynthetic(true)->setPublic(true); $container->register('c', 'class')->setAbstract(true); $container->register('d', 'class')->setSynthetic(true); $this->process($container); $this->addToAssertionCount(1); } public function testValidTags() { $container = new ContainerBuilder(); $container->register('a', 'class')->addTag('foo', array('bar' => 'baz')); $container->register('b', 'class')->addTag('foo', array('bar' => null)); $container->register('c', 'class')->addTag('foo', array('bar' => 1)); $container->register('d', 'class')->addTag('foo', array('bar' => 1.1)); $this->process($container); $this->addToAssertionCount(1); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException */ public function testInvalidTags() { $container = new ContainerBuilder(); $container->register('a', 'class')->addTag('foo', array('bar' => array('baz' => 'baz'))); $this->process($container); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\EnvParameterException */ public function testDynamicPublicServiceName() { $container = new ContainerBuilder(); $env = $container->getParameterBag()->get('env(BAR)'); $container->register("foo.$env", 'class')->setPublic(true); $this->process($container); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\EnvParameterException */ public function testDynamicPublicAliasName() { $container = new ContainerBuilder(); $env = $container->getParameterBag()->get('env(BAR)'); $container->setAlias("foo.$env", 'class')->setPublic(true); $this->process($container); } public function testDynamicPrivateName() { $container = new ContainerBuilder(); $env = $container->getParameterBag()->get('env(BAR)'); $container->register("foo.$env", 'class'); $container->setAlias("bar.$env", 'class'); $this->process($container); $this->addToAssertionCount(1); } protected function process(ContainerBuilder $container) { $pass = new CheckDefinitionValidityPass(); $pass->process($container); } } __halt_compiler();----SIGNATURE:----cKbxm0cXghAgctFRL9wheK4oJcdK9ou77/u0KiJwGIcm4jCkkG5HphAsq6RGBYNYQMu0FnZJBWudgY9kQBRPXh9g0YIXhj4Nn3Fr2KNLefL9nTsV6dSyQ/RDt+LiY77VYy/Ckl8Xu0pOd/pOGJ018aUlsfn6D1hdC/wv8hES2JDTAyEZNzUdNKlzo5Zue7cvAcB3iSEw32ncJx511RI+oWI6HG2h78kS9Ze2oZBxkBN9j41rSfPbzcGSlVyCTNl3ijz/Y7FGoLJUZ8tw+ZZQhsvbQS8wwvVvL3n3Y/N/TpDjvJy7ybY2zQv+Y4Cj0gCx1KQK4Lc+Z35SKa4ehnnkcFmRQ+36156y/PA5sI4ltrmsc/FexDB62nKdbEWAclHTdh4cFcvA/2ME8PYOvaQtV0flp/5a14S/Xfobc2wYfTItZOSvoan3bUvmDKrRCsSaWLs+oxHrpY1TB+lD/42t1gtc+0AP65k99CCR44I9sju0ZkvC/vIogw18242sVmzm6M3XKB/YctLbqng9YNr7gBPspFd4iA64X4KC+4kExh6ua76RtDgF2tNhdK5j3apbMrM5MKdpRyhDtVxRc0oNOP/wq2pVEGi63P3UeuNOXvAZV+489G4wFL4TAID2ZHfjrx+5HL3z5aoi/be8nhAS5zgYXX4QiE7jOZWjiskvOFI=----ATTACHMENT:----NjA2MjgwNzY5NTY3NTIyIDI2MTYzMDA5OTExMzI2OTcgMTg3NTA4NTgyODQ3NzI5OA==