* * 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:----w4R+7gWbcb9ROm0EKy5BYe/5semr2uEjENLm82dceDt616apt6EEcfMg9yVMC57D0g86SmhXJEFjcVE2UPrA67hgY9k3PKSCrAkOU21DS4z8nAxhiTrWIaT0A8IDF3eot83EdYF9Rc7buaptnPwXrElCSwmqljuyqH9QIrEXs0BULGvtjyQOHCK8xbOUWMVXZJxJ8MjECMdg9NOKqFYhn8SlTsIJLWI+fsBY+3nmJ6W0Uk890POyi7z5hIyUWKsbVzHHa6b02fQdcX90GEpuG1xo50QBGjmLy16Nfw0vfJJGYaGtwjPvjanm99L+fCQPidiEdnWKsRAw27ec8APn8zX7QM/grx7u8cHXd4Q9EC63+zAgrwiDuxRQVe+JMhLYyCdOhkDf5+OgxlzvnLBni0L1PQuXx7jvZsM6m3+kFldpkmGnx5lRPUuddsB+iVETPhDWuh7csPncwiyfEj0ZX72bpSOR7+5f0MIWen8NCGoRpYj640X2W2+WUTiDN+STvhjI4v1horYu8/Qnb+Celj/RQw73EytYMTxgnDBXs38EzOPsn94P73RBjCKGCRljaTG42uBfzaybdx17bZBxzJsoLFhxNWCZY1tOGGnEP8ZPo5bi9sIv3eyXSuixvTxp2sZliTmMr6D3g7pQhYos281XTxdl7BVAIT4doesEoFA=----ATTACHMENT:----NTc0NzA0MTkwMDA5MzMzMCA0MDg4OTE3Mzg5NDI1OTQ5IDg2MjA3MjI4NjIwNjUxMTg=