diff --git a/src/lib/parquet-viewer/tests/Flow/ParquetViewer/Tests/Integration/ReadMetadataTest.php b/src/lib/parquet-viewer/tests/Flow/ParquetViewer/Tests/Integration/ReadMetadataTest.php index 08f129904..9c7f61403 100644 --- a/src/lib/parquet-viewer/tests/Flow/ParquetViewer/Tests/Integration/ReadMetadataTest.php +++ b/src/lib/parquet-viewer/tests/Flow/ParquetViewer/Tests/Integration/ReadMetadataTest.php @@ -6,6 +6,9 @@ use Flow\ParquetViewer\Parquet; use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Console\Style\{OutputStyle, SymfonyStyle}; use Symfony\Component\Console\Tester\ApplicationTester; final class ReadMetadataTest extends TestCase @@ -24,10 +27,11 @@ public function test_reading_metadata_from_non_json_file() : void 'file' => $path, ]); - self::assertStringContainsString( - 'not a valid parquet file', - $tester->getDisplay() + $expected = $this->captureConsoleOutput( + fn (OutputStyle $io) => $io->error("File \"{$path}\" is not a valid parquet file") ); + + self::assertStringContainsString($expected, $tester->getDisplay()); self::assertSame(1, $tester->getStatusCode()); } @@ -56,4 +60,15 @@ public function test_reading_metadata_from_parquet_file() : void self::assertStringContainsString('Page Headers', $tester->getDisplay()); self::assertSame(0, $tester->getStatusCode()); } + + private function captureConsoleOutput(\Closure $closure) : string + { + $output = new BufferedOutput(); + + $io = new SymfonyStyle(new ArrayInput([]), $output); + + $closure($io); + + return $output->fetch(); + } }