From 909f97f8027941a77b29be5b2a12367f9d66be4d Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 25 Mar 2020 22:25:16 +0100 Subject: [PATCH 1/2] add missing gitattributes for phpunit-bridge --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index ebb928704..84c7add05 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ /Tests export-ignore /phpunit.xml.dist export-ignore +/.gitattributes export-ignore /.gitignore export-ignore From bf60d5e606cd595391c5f82bf6b570d9573fa120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20P=C3=A9delagrabe?= Date: Thu, 26 Mar 2020 14:31:51 +0100 Subject: [PATCH 2/2] [Console] Fix OutputStream for PHP 7.4 --- Output/StreamOutput.php | 6 +----- Tests/Fixtures/stream_output_file.txt | 0 Tests/Output/StreamOutputTest.php | 8 ++++++++ 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 Tests/Fixtures/stream_output_file.txt diff --git a/Output/StreamOutput.php b/Output/StreamOutput.php index 7ff602763..74b9b54e8 100644 --- a/Output/StreamOutput.php +++ b/Output/StreamOutput.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Console\Output; use Symfony\Component\Console\Exception\InvalidArgumentException; -use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Formatter\OutputFormatterInterface; /** @@ -74,10 +73,7 @@ protected function doWrite($message, $newline) $message .= PHP_EOL; } - if (false === @fwrite($this->stream, $message)) { - // should never happen - throw new RuntimeException('Unable to write output.'); - } + @fwrite($this->stream, $message); fflush($this->stream); } diff --git a/Tests/Fixtures/stream_output_file.txt b/Tests/Fixtures/stream_output_file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/Output/StreamOutputTest.php b/Tests/Output/StreamOutputTest.php index d843fa4a4..86d503806 100644 --- a/Tests/Output/StreamOutputTest.php +++ b/Tests/Output/StreamOutputTest.php @@ -56,4 +56,12 @@ public function testDoWrite() rewind($output->getStream()); $this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream'); } + + public function testDoWriteOnFailure() + { + $resource = fopen(__DIR__.'/../Fixtures/stream_output_file.txt', 'r', false); + $output = new StreamOutput($resource); + rewind($output->getStream()); + $this->assertEquals('', stream_get_contents($output->getStream())); + } }