Skip to content

Commit

Permalink
refactor: Rename DiffMode::LIST to ::FILE_NAME
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Oct 11, 2023
1 parent 3a8ca01 commit f947582
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/Console/Command/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getConfiguration(): Configuration
DiffMode::values(),
),
),
DiffMode::LIST->value,
DiffMode::FILE_NAME->value,
),
new InputOption(
self::CHECK_OPTION,
Expand Down Expand Up @@ -210,11 +210,11 @@ private static function getDiffMode(IO $io): DiffMode
'⚠️ <warning>Using the option "%s" is deprecated. Use "--%s=%s" instead.</warning>',
self::LIST_FILES_DIFF_OPTION,
self::DIFF_OPTION,
DiffMode::LIST->value,
DiffMode::FILE_NAME->value,
),
);

return DiffMode::LIST;
return DiffMode::FILE_NAME;
}

return DiffMode::from($io->getOption(self::DIFF_OPTION)->asNonEmptyString());
Expand Down
2 changes: 1 addition & 1 deletion src/Phar/DiffMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

enum DiffMode: string
{
case LIST = 'list';
case FILE_NAME = 'file-name';
case GIT = 'git';
case GNU = 'gnu';

Expand Down
2 changes: 1 addition & 1 deletion src/Phar/PharDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function equals(): bool
*/
public function diff(DiffMode $mode): null|string|array
{
if (DiffMode::LIST === $mode) {
if (DiffMode::FILE_NAME === $mode) {
return $this->listDiff();
}

Expand Down
18 changes: 9 additions & 9 deletions tests/Console/Command/DiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function test_it_can_display_the_list_diff_of_two_phar_files(): void
);

$expectedOutput = <<<'OUTPUT'
⚠️ <warning>Using the option "list-diff" is deprecated. Use "--diff=list" instead.</warning>
⚠️ <warning>Using the option "list-diff" is deprecated. Use "--diff=file-name" instead.</warning>
// Comparing the two archives...
Expand Down Expand Up @@ -133,7 +133,7 @@ public function test_it_can_display_the_git_diff_of_two_phar_files(): void
);

$expectedOutput = <<<'OUTPUT'
⚠️ <warning>Using the option "list-diff" is deprecated. Use "--diff=list" instead.</warning>
⚠️ <warning>Using the option "list-diff" is deprecated. Use "--diff=file-name" instead.</warning>
// Comparing the two archives...
Expand Down Expand Up @@ -300,15 +300,15 @@ public function test_it_does_not_swallow_exceptions_in_debug_mode(): void

public static function diffPharsProvider(): iterable
{
foreach (self::listDiffPharsProvider() as $label => $set) {
foreach (self::fileNameDiffPharsProvider() as $label => $set) {
array_splice(
$set,
2,
0,
[DiffMode::LIST],
[DiffMode::FILE_NAME],
);

yield '[list] '.$label => $set;
yield '[file-name] '.$label => $set;
}

foreach (self::gitDiffPharsProvider() as $label => $set) {
Expand Down Expand Up @@ -398,9 +398,9 @@ private static function commonDiffPharsProvider(DiffMode $diffMode): iterable
];
}

private static function listDiffPharsProvider(): iterable
private static function fileNameDiffPharsProvider(): iterable
{
yield from self::commonDiffPharsProvider(DiffMode::LIST);
yield from self::commonDiffPharsProvider(DiffMode::FILE_NAME);

yield 'different files' => [
self::FIXTURES_DIR.'/simple-phar-foo.phar',
Expand Down Expand Up @@ -436,7 +436,7 @@ private static function listDiffPharsProvider(): iterable
Metadata: None
Contents: 1 file (6.64KB)
// Comparing the two archives contents (list diff)...
// Comparing the two archives contents (file-name diff)...
--- Files present in "simple-phar-foo.phar" but not in "simple-phar-bar.phar"
+++ Files present in "simple-phar-bar.phar" but not in "simple-phar-foo.phar"
Expand Down Expand Up @@ -487,7 +487,7 @@ private static function listDiffPharsProvider(): iterable
-Contents: 1 file (6.64KB)
+Contents: 1 file (6.61KB)
// Comparing the two archives contents (list diff)...
// Comparing the two archives contents (file-name diff)...
No difference could be observed with this mode.

Expand Down

0 comments on commit f947582

Please sign in to comment.