From 3abb3c9114eb666051c5c215a9370491dee72967 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Mon, 3 Jan 2022 11:21:23 +0000 Subject: [PATCH] Fixed Markdown output not returning skipped items --- composer.json | 4 ++++ src/Formatter/MarkdownPipedToSymfonyConsoleFormatter.php | 9 ++++++++- .../MarkdownPipedToSymfonyConsoleFormatterTest.php | 7 ++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ecf7d863..becd45ac 100644 --- a/composer.json +++ b/composer.json @@ -52,6 +52,10 @@ "sort-packages": true, "platform": { "php": "8.0.99" + }, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "infection/extension-installer": true } } } diff --git a/src/Formatter/MarkdownPipedToSymfonyConsoleFormatter.php b/src/Formatter/MarkdownPipedToSymfonyConsoleFormatter.php index 2932c555..edc706ec 100644 --- a/src/Formatter/MarkdownPipedToSymfonyConsoleFormatter.php +++ b/src/Formatter/MarkdownPipedToSymfonyConsoleFormatter.php @@ -45,6 +45,13 @@ static function (Change $change): bool { }, ...$arrayOfChanges ), '') + . "\n# Skipped\n" + . Str\join($this->convertFilteredChangesToMarkdownBulletList( + static function (Change $change): bool { + return $change->isSkipped(); + }, + ...$arrayOfChanges + ), '') ); } @@ -58,7 +65,7 @@ private function convertFilteredChangesToMarkdownBulletList(callable $filterFunc return Vec\map( Vec\filter($changes, $filterFunction), static function (Change $change): string { - return ' - ' . Str\replace_every(Str\trim($change->__toString()), ['ADDED: ' => '', 'CHANGED: ' => '', 'REMOVED: ' => '']) . "\n"; + return ' - ' . Str\replace_every(Str\trim($change->__toString()), ['ADDED: ' => '', 'CHANGED: ' => '', 'REMOVED: ' => '', 'SKIPPED: ' => '']) . "\n"; } ); } diff --git a/test/unit/Formatter/MarkdownPipedToSymfonyConsoleFormatterTest.php b/test/unit/Formatter/MarkdownPipedToSymfonyConsoleFormatterTest.php index dd988b7b..382c21ce 100644 --- a/test/unit/Formatter/MarkdownPipedToSymfonyConsoleFormatterTest.php +++ b/test/unit/Formatter/MarkdownPipedToSymfonyConsoleFormatterTest.php @@ -4,6 +4,7 @@ namespace RoaveTest\BackwardCompatibility\Formatter; +use Exception; use PHPUnit\Framework\TestCase; use Roave\BackwardCompatibility\Change; use Roave\BackwardCompatibility\Changes; @@ -32,6 +33,9 @@ public function testWrite(): void - [BC] Something removed - Something removed +# Skipped + - [BC] A failure happened + EOF; $output->expects(self::once()) @@ -46,7 +50,8 @@ public function testWrite(): void Change::changed('Something changed', true), Change::changed('Something changed', false), Change::removed('Something removed', true), - Change::removed('Something removed', false) + Change::removed('Something removed', false), + Change::skippedDueToFailure(new Exception('A failure happened')), )); } }