From 7deb9232361820835c9436e26c9277d92aa1a645 Mon Sep 17 00:00:00 2001 From: Stefan Warman Date: Tue, 30 Apr 2013 20:39:15 +0100 Subject: [PATCH] added additional tests to cover invalid argument exceptions in OutputFormatterStyle component --- .../Tests/Formatter/OutputFormatterStyleTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php index b2875e9f4d..6890a9b839 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php @@ -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'); + } } }