@covers Symfony\Component\DependencyInjection\Container::setParameter @covers Symfony\Component\DependencyInjection\Container::getParameter
public function testGetSetParameter() {
$sc = new Container(new ParameterBag(array(
'foo' => 'bar',
)));
$sc
->setParameter('bar', 'foo');
$this
->assertEquals('foo', $sc
->getParameter('bar'), '->setParameter() sets the value of a new parameter');
$sc
->setParameter('foo', 'baz');
$this
->assertEquals('baz', $sc
->getParameter('foo'), '->setParameter() overrides previously set parameter');
$sc
->setParameter('Foo', 'baz1');
$this
->assertEquals('baz1', $sc
->getParameter('foo'), '->setParameter() converts the key to lowercase');
$this
->assertEquals('baz1', $sc
->getParameter('FOO'), '->getParameter() converts the key to lowercase');
try {
$sc
->getParameter('baba');
$this
->fail('->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
} catch (\Exception $e) {
$this
->assertInstanceOf('\\InvalidArgumentException', $e, '->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
$this
->assertEquals('You have requested a non-existent parameter "baba".', $e
->getMessage(), '->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
}
}