Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/equals
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Oct 11, 2023
2 parents 0f6d8f7 + 1edcb8e commit b866b08
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 30 deletions.
2 changes: 0 additions & 2 deletions src/Console/Command/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion tests/BoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/Command/CompileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
44 changes: 21 additions & 23 deletions tests/Console/Command/DiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/Command/GenerateDockerFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/Command/InfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/Command/VerifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b866b08

Please sign in to comment.