[DependencyInjection] Test Definition and DefinitionDecorator exceptions

This commit is contained in:
Jeremy Mikola 2011-10-27 17:59:47 -04:00
parent 323f80d233
commit 4bbb685557
2 changed files with 32 additions and 0 deletions

View File

@ -69,4 +69,14 @@ 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');
}
}

View File

@ -221,6 +221,28 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
$this->assertSame(array('foo', 'bar'), $def->getArguments());
}
/**
* @expectedException OutOfBoundsException
*/
public function testGetArgumentShouldCheckBounds()
{
$def = new Definition('stdClass');
$def->addArgument('foo');
$def->getArgument(1);
}
/**
* @expectedException OutOfBoundsException
*/
public function testReplaceArgumentShouldCheckBounds()
{
$def = new Definition('stdClass');
$def->addArgument('foo');
$def->replaceArgument(1, 'bar');
}
public function testSetGetProperties()
{
$def = new Definition('stdClass');