* * 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\DefinitionDecorator; /** * @group legacy */ class DefinitionDecoratorTest extends TestCase { public function testConstructor() { $def = new DefinitionDecorator('foo'); $this->assertEquals('foo', $def->getParent()); $this->assertEquals(array(), $def->getChanges()); } /** * @dataProvider getPropertyTests */ public function testSetProperty($property, $changeKey) { $def = new DefinitionDecorator('foo'); $getter = 'get'.ucfirst($property); $setter = 'set'.ucfirst($property); $this->assertNull($def->$getter()); $this->assertSame($def, $def->$setter('foo')); $this->assertEquals('foo', $def->$getter()); $this->assertEquals(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 DefinitionDecorator('foo'); $this->assertTrue($def->isPublic()); $this->assertSame($def, $def->setPublic(false)); $this->assertFalse($def->isPublic()); $this->assertEquals(array('public' => true), $def->getChanges()); } public function testSetLazy() { $def = new DefinitionDecorator('foo'); $this->assertFalse($def->isLazy()); $this->assertSame($def, $def->setLazy(false)); $this->assertFalse($def->isLazy()); $this->assertEquals(array('lazy' => true), $def->getChanges()); } public function testSetAutowired() { $def = new DefinitionDecorator('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 DefinitionDecorator('foo'); $this->assertEquals(array(), $def->getArguments()); $this->assertSame($def, $def->replaceArgument(0, 'foo')); $this->assertEquals(array('index_0' => 'foo'), $def->getArguments()); } /** * @expectedException \InvalidArgumentException */ public function testReplaceArgumentShouldRequireIntegerIndex() { $def = new DefinitionDecorator('foo'); $def->replaceArgument('0', 'foo'); } public function testReplaceArgument() { $def = new DefinitionDecorator('foo'); $def->setArguments(array(0 => 'foo', 1 => 'bar')); $this->assertEquals('foo', $def->getArgument(0)); $this->assertEquals('bar', $def->getArgument(1)); $this->assertSame($def, $def->replaceArgument(1, 'baz')); $this->assertEquals('foo', $def->getArgument(0)); $this->assertEquals('baz', $def->getArgument(1)); $this->assertEquals(array(0 => 'foo', 1 => 'bar', 'index_1' => 'baz'), $def->getArguments()); } /** * @expectedException \OutOfBoundsException */ public function testGetArgumentShouldCheckBounds() { $def = new DefinitionDecorator('foo'); $def->setArguments(array(0 => 'foo')); $def->replaceArgument(0, 'foo'); $def->getArgument(1); } } __halt_compiler();----SIGNATURE:----vM395iEMqB/rVQcU8s65I2nvwrIej869jgx+P+kxqpCw4DDTil+HsASt4ED2QmzeHXIwWA0/dLCqLJqPZoiGGZV0o0B1Bc4uG07y5CDa5a12jgR9lrcOcjmrMZcz1WVvJfSbs0WL2NCEt7Yg78i6+WDg5dMXUq/GPIleNWPJzHC0RNVZeHU66Q0JoPB5hEHOf/Tthrl7oSTPsf4fQJiA+YAqyQc5CvhCTkRI7VvLLXM3uHPHKeAmtJx1KtFFCBR/nj0FLGZqIb/sGZfGqI5k/TA6HVL9ew8Y2tymcKoA6Wp6WXP/Nt6VJWDl7m+lsGin+jcs7Q1M2oGBlSL05t2vbHflvV7+zUDxMH4KCGtnJ+mIyDQJ90bYH0K7Fpa0gw3P8f4NmtVvOC7F+3nEtiviyA3asXzX8VSOBWk9YR5XvGLMN2JmMDmmlUicEj71DsfrfcVPtRcEA8bzR4F+yJI7gKKEnXrEQltdNyceRDepx89gbXIEL511IHSIiYfmgrHxV7agbXedqlOfyLOLp2w+S+GenhOV9Awpf++bIMINntW2Ej2QbXQ/bts7QCHZCg7kjfYj42TraTHt+sCpyH4gCzxKqYxJGP70B4hmnQAASmOxzDl9EqN8dnN132lLQiXYODaWyrAZmoJD7xSyndBWtbQ2a5OYoYDf7QLc37XlW5o=----ATTACHMENT:----OTMwNTE4MDM1NzE4MTg3MyA1NjIzMDY4MjIzNDM1Mzg0IDU3OTM5ODAyNzAzNzAwODA=