Skip to content

Commit

Permalink
[Console] fixed style creation when providing an unknown tag option
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Aug 7, 2014
1 parent 72b7063 commit 8814920
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Symfony/Component/Console/Formatter/OutputFormatter.php
Expand Up @@ -215,7 +215,11 @@ private function createStyleFromString($string)
} elseif ('bg' == $match[0]) {
$style->setBackground($match[1]);
} else {
$style->setOption($match[1]);
try {
$style->setOption($match[1]);
} catch (\InvalidArgumentException $e) {
return false;
}
}
}

Expand Down
Expand Up @@ -151,7 +151,7 @@ public function testNonStyleTag()
{
$formatter = new OutputFormatter(true);

$this->assertEquals("\033[32msome \033[0m\033[32m<tag>\033[0m\033[32m styled \033[0m\033[32m<p>\033[0m\033[32msingle-char tag\033[0m\033[32m</p>\033[0m", $formatter->format('<info>some <tag> styled <p>single-char tag</p></info>'));
$this->assertEquals("\033[32msome \033[0m\033[32m<tag>\033[0m\033[32m \033[0m\033[32m<setting=value>\033[0m\033[32m styled \033[0m\033[32m<p>\033[0m\033[32msingle-char tag\033[0m\033[32m</p>\033[0m", $formatter->format('<info>some <tag> <setting=value> styled <p>single-char tag</p></info>'));
}

public function testFormatLongString()
Expand Down

0 comments on commit 8814920

Please sign in to comment.