* * 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\ResolveParameterPlaceHoldersPass; use Symfony\Component\DependencyInjection\ContainerBuilder; class ResolveParameterPlaceHoldersPassTest extends TestCase { private $compilerPass; private $container; private $fooDefinition; protected function setUp() { $this->compilerPass = new ResolveParameterPlaceHoldersPass(); $this->container = $this->createContainerBuilder(); $this->compilerPass->process($this->container); $this->fooDefinition = $this->container->getDefinition('foo'); } public function testClassParametersShouldBeResolved() { $this->assertSame('Foo', $this->fooDefinition->getClass()); } public function testFactoryParametersShouldBeResolved() { $this->assertSame(array('FooFactory', 'getFoo'), $this->fooDefinition->getFactory()); } public function testArgumentParametersShouldBeResolved() { $this->assertSame(array('bar', array('bar' => 'baz')), $this->fooDefinition->getArguments()); } public function testMethodCallParametersShouldBeResolved() { $this->assertSame(array(array('foobar', array('bar', array('bar' => 'baz')))), $this->fooDefinition->getMethodCalls()); } public function testPropertyParametersShouldBeResolved() { $this->assertSame(array('bar' => 'baz'), $this->fooDefinition->getProperties()); } public function testFileParametersShouldBeResolved() { $this->assertSame('foo.php', $this->fooDefinition->getFile()); } public function testAliasParametersShouldBeResolved() { $this->assertSame('foo', $this->container->getAlias('bar')->__toString()); } public function testBindingsShouldBeResolved() { list($boundValue) = $this->container->getDefinition('foo')->getBindings()['$baz']->getValues(); $this->assertSame($this->container->getParameterBag()->resolveValue('%env(BAZ)%'), $boundValue); } private function createContainerBuilder() { $containerBuilder = new ContainerBuilder(); $containerBuilder->setParameter('foo.class', 'Foo'); $containerBuilder->setParameter('foo.factory.class', 'FooFactory'); $containerBuilder->setParameter('foo.arg1', 'bar'); $containerBuilder->setParameter('foo.arg2', array('%foo.arg1%' => 'baz')); $containerBuilder->setParameter('foo.method', 'foobar'); $containerBuilder->setParameter('foo.property.name', 'bar'); $containerBuilder->setParameter('foo.property.value', 'baz'); $containerBuilder->setParameter('foo.file', 'foo.php'); $containerBuilder->setParameter('alias.id', 'bar'); $fooDefinition = $containerBuilder->register('foo', '%foo.class%'); $fooDefinition->setFactory(array('%foo.factory.class%', 'getFoo')); $fooDefinition->setArguments(array('%foo.arg1%', array('%foo.arg1%' => 'baz'))); $fooDefinition->addMethodCall('%foo.method%', array('%foo.arg1%', '%foo.arg2%')); $fooDefinition->setProperty('%foo.property.name%', '%foo.property.value%'); $fooDefinition->setFile('%foo.file%'); $fooDefinition->setBindings(array('$baz' => '%env(BAZ)%')); $containerBuilder->setAlias('%alias.id%', 'foo'); return $containerBuilder; } } __halt_compiler();----SIGNATURE:----BpXzKcsGc1mhUbtvhYwuJoMjQwDXMgIerKsDrmMnn9AJ+mAXZSP4ouTzKHkZ+bk48vq7bRRny14EtM+YRup+bOnZ4sNPPt9MXNBg9coB0TjqmoR59FE+KlDtnpW2NyvZ3UkCPMsjGbldvpjXOj309s1pIQRs6ynyvGDnB4lYJGDor5U2jgQu3/dUAzLfLx1zZlCeNeFInpr38ZtkhhT8vSvpIFjOGywhgJrtsj24dKGZVSz+pst/dovVW3GquE+GWE84M3MhYbluxHd53LWoy3rKLltne03qejbUrkOwsNuR5ooRHFzavU8hNo6AxnAFGbdHdikS9NavuWjKa/uQD/oSDma0nfM1OaM6xn9wdiosec+137R8WzNfLss65ehjcuYk0GaSaRWzoBoRfwkztFS5PqbSm50cmWoU/FMtgzhO1S72uTA9TBCL1kB6lTKomSGoDs9/qQFDpBG71qeFkXBGQzG4Vt5HbEE/q8yN8dT85w5rUvAXbcZ5bRoGbR3KirskplPWiX3nRv2YFFoFQv6crAYU5YF/Sfkq11vdXx6Ypk2YuT2vvRliyoO8ulJSGLEUuiub38hHc1IvATvH10ymlGQ+D4SfMfo2OeFCb4wZBFmrwa9mbM5dqjVcvvVFOx6FtkwAP5JPx1sxl1JxsqDeCDblG+YbRRotaeR1cgQ=----ATTACHMENT:----NzIzNDI3NDQ2MjQ1NTQxNiA3MTc2NTkyMDMxOTc4NjE3IDQ0MjU3MzQ1NTE5NzgzMA==