Skip to content

Commit

Permalink
[DependencyInjection] Replaced try/catch block with an @ExpectedExcep…
Browse files Browse the repository at this point in the history
…tion annotation in a test.
  • Loading branch information
jakzal committed Jun 17, 2013
1 parent caaaec3 commit 494e803
Showing 1 changed file with 8 additions and 14 deletions.
Expand Up @@ -50,31 +50,25 @@ public function testIniFileCanBeLoaded()
/**
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::__construct
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::load
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The file "foo.ini" does not exist (in:
*/
public function testExceptionIsRaisedWhenIniFileDoesNotExist()
{
try {
$this->loader->load('foo.ini');
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
} catch (\Exception $e) {
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file does not exist');
$this->assertStringStartsWith('The file "foo.ini" does not exist (in: ', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file does not exist');
}
$this->loader->load('foo.ini');
}

/**
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::__construct
* @covers Symfony\Component\DependencyInjection\Loader\IniFileLoader::load
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "nonvalid.ini" file is not valid.
*/
public function testExceptionIsRaisedWhenIniFileCannotBeParsed()
{
try {
@$this->loader->load('nonvalid.ini');
$this->fail('->load() throws an InvalidArgumentException if the loaded file is not parseable');
} catch (\Exception $e) {
$this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the loaded file is not parseable');
$this->assertEquals('The "nonvalid.ini" file is not valid.', $e->getMessage(), '->load() throws an InvalidArgumentException if the loaded file is not parseable');
}
@$this->loader->load('nonvalid.ini');
}

/**
Expand Down

0 comments on commit 494e803

Please sign in to comment.