* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\DependencyInjection\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\DefinitionDecorator; class ChildDefinitionTest extends TestCase { public function testConstructor() { $def = new ChildDefinition('foo'); $this->assertSame('foo', $def->getParent()); $this->assertSame(array(), $def->getChanges()); } /** * @dataProvider getPropertyTests */ public function testSetProperty($property, $changeKey) { $def = new ChildDefinition('foo'); $getter = 'get'.ucfirst($property); $setter = 'set'.ucfirst($property); $this->assertNull($def->$getter()); $this->assertSame($def, $def->$setter('foo')); $this->assertSame('foo', $def->$getter()); $this->assertSame(array($changeKey => true), $def->getChanges()); } public function getPropertyTests() { return array( array('class', 'class'), array('factory', 'factory'), array('configurator', 'configurator'), array('file', 'file'), ); } public function testSetPublic() { $def = new ChildDefinition('foo'); $this->assertTrue($def->isPublic()); $this->assertSame($def, $def->setPublic(false)); $this->assertFalse($def->isPublic()); $this->assertSame(array('public' => true), $def->getChanges()); } public function testSetLazy() { $def = new ChildDefinition('foo'); $this->assertFalse($def->isLazy()); $this->assertSame($def, $def->setLazy(false)); $this->assertFalse($def->isLazy()); $this->assertSame(array('lazy' => true), $def->getChanges()); } public function testSetAutowired() { $def = new ChildDefinition('foo'); $this->assertFalse($def->isAutowired()); $this->assertSame($def, $def->setAutowired(true)); $this->assertTrue($def->isAutowired()); $this->assertSame(array('autowired' => true), $def->getChanges()); } public function testSetArgument() { $def = new ChildDefinition('foo'); $this->assertSame(array(), $def->getArguments()); $this->assertSame($def, $def->replaceArgument(0, 'foo')); $this->assertSame(array('index_0' => 'foo'), $def->getArguments()); } /** * @expectedException \InvalidArgumentException */ public function testReplaceArgumentShouldRequireIntegerIndex() { $def = new ChildDefinition('foo'); $def->replaceArgument('0', 'foo'); } public function testReplaceArgument() { $def = new ChildDefinition('foo'); $def->setArguments(array(0 => 'foo', 1 => 'bar')); $this->assertSame('foo', $def->getArgument(0)); $this->assertSame('bar', $def->getArgument(1)); $this->assertSame($def, $def->replaceArgument(1, 'baz')); $this->assertSame('foo', $def->getArgument(0)); $this->assertSame('baz', $def->getArgument(1)); $this->assertSame(array(0 => 'foo', 1 => 'bar', 'index_1' => 'baz'), $def->getArguments()); $this->assertSame($def, $def->replaceArgument('$bar', 'val')); $this->assertSame('val', $def->getArgument('$bar')); $this->assertSame(array(0 => 'foo', 1 => 'bar', 'index_1' => 'baz', '$bar' => 'val'), $def->getArguments()); } /** * @expectedException \OutOfBoundsException */ public function testGetArgumentShouldCheckBounds() { $def = new ChildDefinition('foo'); $def->setArguments(array(0 => 'foo')); $def->replaceArgument(0, 'foo'); $def->getArgument(1); } public function testDefinitionDecoratorAliasExistsForBackwardsCompatibility() { $this->assertInstanceOf(ChildDefinition::class, new DefinitionDecorator('foo')); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\BadMethodCallException */ public function testCannotCallSetAutoconfigured() { $def = new ChildDefinition('foo'); $def->setAutoconfigured(true); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\BadMethodCallException */ public function testCannotCallSetInstanceofConditionals() { $def = new ChildDefinition('foo'); $def->setInstanceofConditionals(array('Foo' => new ChildDefinition(''))); } } __halt_compiler();----SIGNATURE:----Uip0uj4u22h6G2MJlTqOfz8j9SxM5sdkndDgj5If5jzI3vgNMKFqY8ivvkqaYAyBpMiEnTxIy1svkRYXw587/Ldin9ZfG4WmlulbbH4Fq+1TU6hqNQ/dMHCEdlxrdGslm3a1ipQAk+XZhtSPY2xF4c/xT9j6UsgY6vxV9dp6IydYkJIINBpYbT+ARweVd0xY2ajtoRVC9JHrEbH0kwJOdcYbq+CvrbqWPyMTt4JH1tISYDirvs7ttQ1FG2jwzt0NFAb+pUgISqWaj7ToboHErOvInw9wf47csTVSQcvC1rGkXiZakEiNEBB6tAdOmGQBWhDXSh8KoKgtACk7zhMJkUUxfV6WfT6V6JjNg26o4ALBL/HWwYJmIrhRhzYNzUDd8ClEqWc7tt8yvVvUMAEZ/e81xidHHI27wq5KmlUxall3wKPd+ndGZxxtfAxpwy3AX6ZwqCfdOXHOKpbo7r8SrmnTlBtpPhV5fcT5RKWBA29VG3bTMd37Y5XVmsWebfXy9/8zbtQ1Q8EXSKaz4rVTMy6FNfcZuUp6MH5nU74DTHXJqRJDjU+Z1YmLmu2f1dj/k+ryoZMRi7NRp1Rj2bCN+s5yI7tWX1shmAtgEy3Cj56VEYy/jzKIQ2IB4ERtvw0Q2zt5ytolRNOL6wlbHvgQaAODRglUQZluYx0I4mZHduw=----ATTACHMENT:----NjM3OTg4MjAyNzE4ODkgMjcwMTU3NzE1MjU4NjIwMyA5OTMyMDE0NjIwMzU3MzY1