From a93b8e10f5954be0853eec693c13e84c4bd9e6f2 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Fri, 15 Dec 2017 11:24:35 -0800 Subject: Kanboard requires at least PHP 5.6 now --- .../Tests/Formatter/OutputFormatterTest.php | 73 +++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) (limited to 'vendor/symfony/console/Tests/Formatter/OutputFormatterTest.php') diff --git a/vendor/symfony/console/Tests/Formatter/OutputFormatterTest.php b/vendor/symfony/console/Tests/Formatter/OutputFormatterTest.php index b8d5ca6d..a1aa8013 100644 --- a/vendor/symfony/console/Tests/Formatter/OutputFormatterTest.php +++ b/vendor/symfony/console/Tests/Formatter/OutputFormatterTest.php @@ -11,10 +11,11 @@ namespace Symfony\Component\Console\Tests\Formatter; +use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Formatter\OutputFormatterStyle; -class OutputFormatterTest extends \PHPUnit_Framework_TestCase +class OutputFormatterTest extends TestCase { public function testEmptyTag() { @@ -27,6 +28,9 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase $formatter = new OutputFormatter(true); $this->assertEquals('fooformat('foo\\assertEquals('foo << bar', $formatter->format('foo << bar')); + $this->assertEquals('foo << bar \\', $formatter->format('foo << bar \\')); + $this->assertEquals("foo << \033[32mbar \\ baz\033[39m \\", $formatter->format('foo << bar \\ baz \\')); $this->assertEquals('some info', $formatter->format('\\some info\\')); $this->assertEquals('\\some info\\', OutputFormatter::escape('some info')); @@ -152,6 +156,67 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase $this->assertEquals("\033[34;41msome text\033[39;49m", $formatter->format('some text')); } + /** + * @param string $tag + * @param string|null $expected + * @param string|null $input + * + * @dataProvider provideInlineStyleOptionsCases + */ + public function testInlineStyleOptions($tag, $expected = null, $input = null) + { + $styleString = substr($tag, 1, -1); + $formatter = new OutputFormatter(true); + $method = new \ReflectionMethod($formatter, 'createStyleFromString'); + $method->setAccessible(true); + $result = $method->invoke($formatter, $styleString); + if (null === $expected) { + $this->assertFalse($result); + $expected = $tag.$input.''; + $this->assertSame($expected, $formatter->format($expected)); + } else { + /* @var OutputFormatterStyle $result */ + $this->assertInstanceOf(OutputFormatterStyle::class, $result); + $this->assertSame($expected, $formatter->format($tag.$input.'')); + $this->assertSame($expected, $formatter->format($tag.$input.'')); + } + } + + public function provideInlineStyleOptionsCases() + { + return array( + array(''), + array(''), + array('', "\033[32m[test]\033[39m", '[test]'), + array('', "\033[32;44ma\033[39;49m", 'a'), + array('', "\033[32;1mb\033[39;22m", 'b'), + array('', "\033[32;7m\033[39;27m", ''), + array('', "\033[32;1;4mz\033[39;22;24m", 'z'), + array('', "\033[32;1;4;7md\033[39;22;24;27m", 'd'), + ); + } + + /** + * @group legacy + * @dataProvider provideInlineStyleTagsWithUnknownOptions + * @expectedDeprecation Unknown style options are deprecated since version 3.2 and will be removed in 4.0. Exception "Invalid option specified: "%s". Expected one of (bold, underscore, blink, reverse, conceal)". + */ + public function testInlineStyleOptionsUnknownAreDeprecated($tag, $option) + { + $formatter = new OutputFormatter(true); + $formatter->format($tag); + } + + public function provideInlineStyleTagsWithUnknownOptions() + { + return array( + array('', 'abc'), + array('', 'abc'), + array('', 'xyz'), + array('', 'efg'), + ); + } + public function testNonStyleTag() { $formatter = new OutputFormatter(true); @@ -195,6 +260,9 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase $this->assertEquals( 'some question', $formatter->format('some question') ); + $this->assertEquals( + 'some text with inline style', $formatter->format('some text with inline style') + ); $formatter->setDecorated(true); @@ -210,6 +278,9 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase $this->assertEquals( "\033[30;46msome question\033[39;49m", $formatter->format('some question') ); + $this->assertEquals( + "\033[31msome text with inline style\033[39m", $formatter->format('some text with inline style') + ); } public function testContentWithLineBreaks() -- cgit v1.2.3