|
@@ -69,4 +69,42 @@ class DefinitionDecoratorTest extends \PHPUnit_Framework_TestCase
|
|
|
$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);
|
|
|
+ }
|
|
|
}
|