X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FParameterBag%2FParameterBagTest.php;fp=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FParameterBag%2FParameterBagTest.php;h=391e0eb3ff7de9945ec25c4cf00f1f94d3667d34;hp=ae6b1990954ba196afde928c98c8af94f46d0a9c;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/symfony/dependency-injection/Tests/ParameterBag/ParameterBagTest.php b/vendor/symfony/dependency-injection/Tests/ParameterBag/ParameterBagTest.php index ae6b19909..391e0eb3f 100644 --- a/vendor/symfony/dependency-injection/Tests/ParameterBag/ParameterBagTest.php +++ b/vendor/symfony/dependency-injection/Tests/ParameterBag/ParameterBagTest.php @@ -72,37 +72,37 @@ class ParameterBagTest extends TestCase } } - public function testGetThrowParameterNotFoundException() + /** + * @dataProvider provideGetThrowParameterNotFoundExceptionData + */ + public function testGetThrowParameterNotFoundException($parameterKey, $exceptionMessage) { $bag = new ParameterBag(array( 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz', + 'fiz' => array('bar' => array('boo' => 12)), )); - try { - $bag->get('foo1'); - $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); - $this->assertEquals('You have requested a non-existent parameter "foo1". Did you mean this: "foo"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices'); + if (method_exists($this, 'expectException')) { + $this->expectException(ParameterNotFoundException::class); + $this->expectExceptionMessage($exceptionMessage); + } else { + $this->setExpectedException(ParameterNotFoundException::class, $exceptionMessage); } - try { - $bag->get('bag'); - $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); - $this->assertEquals('You have requested a non-existent parameter "bag". Did you mean one of these: "bar", "baz"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices'); - } + $bag->get($parameterKey); + } - try { - $bag->get(''); - $this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist'); - $this->assertEquals('You have requested a non-existent parameter "".', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices'); - } + public function provideGetThrowParameterNotFoundExceptionData() + { + return array( + array('foo1', 'You have requested a non-existent parameter "foo1". Did you mean this: "foo"?'), + array('bag', 'You have requested a non-existent parameter "bag". Did you mean one of these: "bar", "baz"?'), + array('', 'You have requested a non-existent parameter "".'), + + array('fiz.bar.boo', 'You have requested a non-existent parameter "fiz.bar.boo". You cannot access nested array items, do you want to inject "fiz" instead?'), + ); } public function testHas()