added additional tests to cover invalid argument exceptions in OutputFormatterStyle component

This commit is contained in:
Stefan Warman 2013-04-30 20:39:15 +01:00 committed by Fabien Potencier
parent 759293c9f5
commit 7deb923236

View File

@ -73,5 +73,21 @@ class OutputFormatterStyleTest extends \PHPUnit_Framework_TestCase
$style->setOptions(array('bold'));
$this->assertEquals("\033[1mfoo\033[0m", $style->apply('foo'));
try {
$style->setOption('foo');
$this->fail('->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
} catch (\Exception $e) {
$this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
$this->assertContains('Invalid option specified: "foo"', $e->getMessage(), '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
}
try {
$style->unsetOption('foo');
$this->fail('->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
} catch (\Exception $e) {
$this->assertInstanceOf('\InvalidArgumentException', $e, '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
$this->assertContains('Invalid option specified: "foo"', $e->getMessage(), '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
}
}
}