diff --git a/src/Console/Command/Diff.php b/src/Console/Command/Diff.php index f706ab5ab..0c4a0d031 100644 --- a/src/Console/Command/Diff.php +++ b/src/Console/Command/Diff.php @@ -29,7 +29,6 @@ use Webmozart\Assert\Assert; use function array_map; use function count; -// TODO: migrate to Safe API use function explode; use function implode; use function is_string; @@ -44,7 +43,6 @@ final class Diff implements Command private const FIRST_PHAR_ARG = 'pharA'; private const SECOND_PHAR_ARG = 'pharB'; - // TODO: replace by DiffMode::X->value once bumping to PHP 8.2 as the min version. private const LIST_FILES_DIFF_OPTION = 'list-diff'; private const GIT_DIFF_OPTION = 'git-diff'; private const GNU_DIFF_OPTION = 'gnu-diff'; diff --git a/tests/BoxTest.php b/tests/BoxTest.php index e6ac4a5ee..979ba8f46 100644 --- a/tests/BoxTest.php +++ b/tests/BoxTest.php @@ -48,7 +48,7 @@ use function implode; use function in_array; use function iterator_to_array; -use function realpath; +use function Safe\realpath; use function sprintf; use function str_replace; use function trim; diff --git a/tests/Console/Command/CompileTest.php b/tests/Console/Command/CompileTest.php index 3382552b2..dce69f130 100644 --- a/tests/Console/Command/CompileTest.php +++ b/tests/Console/Command/CompileTest.php @@ -56,7 +56,7 @@ use function preg_quote; use function preg_replace; use function random_int; -use function realpath; +use function Safe\realpath; use function sort; use function sprintf; use function str_replace; diff --git a/tests/Console/Command/DiffTest.php b/tests/Console/Command/DiffTest.php index 527231665..167bca291 100644 --- a/tests/Console/Command/DiffTest.php +++ b/tests/Console/Command/DiffTest.php @@ -26,8 +26,8 @@ use Symfony\Component\Console\Output\OutputInterface; use function array_splice; use function ob_get_clean; -use function ob_start; -use function realpath; +use function Safe\ob_start; +use function Safe\realpath; /** * @covers \KevinGH\Box\Console\Command\Diff @@ -69,15 +69,13 @@ public function test_it_can_display_the_diff_of_two_phar_files( $this->commandTester->execute( [ 'command' => 'diff', - 'pharA' => $pharAPath, - 'pharB' => $pharBPath, + 'pharA' => realpath($pharAPath), + 'pharB' => realpath($pharBPath), '--diff' => $diffMode->value, ], ); - $actualOutput = DisplayNormalizer::removeTrailingSpaces( - $this->commandTester->getDisplay(true), - ); + $actualOutput = $this->commandTester->getNormalizedDisplay(); if (null !== $expectedOutput) { self::assertSame($expectedOutput, $actualOutput); @@ -358,8 +356,8 @@ public static function diffPharsProvider(): iterable private static function commonDiffPharsProvider(): iterable { yield 'same PHAR' => [ - realpath(self::FIXTURES_DIR.'/simple-phar-foo.phar'), - realpath(self::FIXTURES_DIR.'/simple-phar-foo.phar'), + self::FIXTURES_DIR.'/simple-phar-foo.phar', + self::FIXTURES_DIR.'/simple-phar-foo.phar', <<<'OUTPUT' // Comparing the two archives... (do not check the signatures) @@ -376,8 +374,8 @@ private static function commonDiffPharsProvider(): iterable ]; yield 'different data; same content' => [ - realpath(self::FIXTURES_DIR.'/simple-phar-bar.phar'), - realpath(self::FIXTURES_DIR.'/simple-phar-bar-compressed.phar'), + self::FIXTURES_DIR.'/simple-phar-bar.phar', + self::FIXTURES_DIR.'/simple-phar-bar-compressed.phar', <<<'OUTPUT' // Comparing the two archives... (do not check the signatures) @@ -413,8 +411,8 @@ private static function listDiffPharsProvider(): iterable yield from self::commonDiffPharsProvider(); yield 'different files' => [ - realpath(self::FIXTURES_DIR.'/simple-phar-foo.phar'), - realpath(self::FIXTURES_DIR.'/simple-phar-bar.phar'), + self::FIXTURES_DIR.'/simple-phar-foo.phar', + self::FIXTURES_DIR.'/simple-phar-bar.phar', <<<'OUTPUT' // Comparing the two archives... (do not check the signatures) @@ -452,8 +450,8 @@ private static function listDiffPharsProvider(): iterable ]; yield 'same files different content' => [ - realpath(self::FIXTURES_DIR.'/simple-phar-bar.phar'), - realpath(self::FIXTURES_DIR.'/simple-phar-baz.phar'), + self::FIXTURES_DIR.'/simple-phar-bar.phar', + self::FIXTURES_DIR.'/simple-phar-baz.phar', <<<'OUTPUT' // Comparing the two archives... (do not check the signatures) @@ -489,8 +487,8 @@ public static function gitDiffPharsProvider(): iterable yield from self::commonDiffPharsProvider(); yield 'different files' => [ - realpath(self::FIXTURES_DIR.'/simple-phar-foo.phar'), - realpath(self::FIXTURES_DIR.'/simple-phar-bar.phar'), + self::FIXTURES_DIR.'/simple-phar-foo.phar', + self::FIXTURES_DIR.'/simple-phar-bar.phar', <<<'OUTPUT' // Comparing the two archives... (do not check the signatures) @@ -523,8 +521,8 @@ public static function gitDiffPharsProvider(): iterable ]; yield 'same files different content' => [ - realpath(self::FIXTURES_DIR.'/simple-phar-bar.phar'), - realpath(self::FIXTURES_DIR.'/simple-phar-baz.phar'), + self::FIXTURES_DIR.'/simple-phar-bar.phar', + self::FIXTURES_DIR.'/simple-phar-baz.phar', <<<'OUTPUT' // Comparing the two archives... (do not check the signatures) @@ -567,8 +565,8 @@ public static function GNUDiffPharsProvider(): iterable yield from self::commonDiffPharsProvider(); yield 'different files' => [ - realpath(self::FIXTURES_DIR.'/simple-phar-foo.phar'), - realpath(self::FIXTURES_DIR.'/simple-phar-bar.phar'), + self::FIXTURES_DIR.'/simple-phar-foo.phar', + self::FIXTURES_DIR.'/simple-phar-bar.phar', <<<'OUTPUT' // Comparing the two archives... (do not check the signatures) @@ -599,8 +597,8 @@ public static function GNUDiffPharsProvider(): iterable ]; yield 'same files different content' => [ - realpath(self::FIXTURES_DIR.'/simple-phar-bar.phar'), - realpath(self::FIXTURES_DIR.'/simple-phar-baz.phar'), + self::FIXTURES_DIR.'/simple-phar-bar.phar', + self::FIXTURES_DIR.'/simple-phar-baz.phar', Platform::isOSX() ? <<<'OUTPUT' diff --git a/tests/Console/Command/GenerateDockerFileTest.php b/tests/Console/Command/GenerateDockerFileTest.php index d6cfe2896..68c4d2a99 100644 --- a/tests/Console/Command/GenerateDockerFileTest.php +++ b/tests/Console/Command/GenerateDockerFileTest.php @@ -18,7 +18,7 @@ use Fidry\Console\ExitCode; use KevinGH\Box\Test\CommandTestCase; use KevinGH\Box\Test\RequiresPharReadonlyOff; -use function realpath; +use function Safe\realpath; /** * @covers \KevinGH\Box\Console\Command\GenerateDockerFile diff --git a/tests/Console/Command/InfoTest.php b/tests/Console/Command/InfoTest.php index b36a40e75..9fdf342c4 100644 --- a/tests/Console/Command/InfoTest.php +++ b/tests/Console/Command/InfoTest.php @@ -25,7 +25,7 @@ use function extension_loaded; use function implode; use function preg_replace; -use function realpath; +use function Safe\realpath; /** * @covers \KevinGH\Box\Console\Command\Info diff --git a/tests/Console/Command/VerifyTest.php b/tests/Console/Command/VerifyTest.php index 245cb7008..5ae412d02 100644 --- a/tests/Console/Command/VerifyTest.php +++ b/tests/Console/Command/VerifyTest.php @@ -21,7 +21,7 @@ use KevinGH\Box\Test\RequiresPharReadonlyOff; use Phar; use Symfony\Component\Console\Output\OutputInterface; -use function realpath; +use function Safe\realpath; /** * @covers \KevinGH\Box\Console\Command\Verify