Skip to content

Commit

Permalink
fix: Allow the info command to work on the old RequirementChecker (#1157
Browse files Browse the repository at this point in the history
)

Closes #1126.
  • Loading branch information
theofidry authored Nov 9, 2023
1 parent 4cfda8d commit d944fb9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Binary file modified fixtures/info/req-checker-old-req.phar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/RequirementChecker/Requirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static function fromArray(array $value): self
return new self(
RequirementType::from($value['type']),
$value['condition'],
$value['source'],
$value['source'] ?? null,
$value['message'],
$value['helpMessage'],
);
Expand Down
6 changes: 3 additions & 3 deletions tests/Console/Command/InfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,18 +677,18 @@ public static function inputProvider(): iterable
Files Compression: None
Signature: SHA-1
Signature Hash: 92123D3800E1F6AD1CD1D4099B8D16BC51097A5C
Signature Hash: EEA3F86AA1B61484EE961055F43AA61805071CB1
Metadata: None
Timestamp: 1697988440 (2023-10-22T15:27:20+00:00)
Timestamp: 1699390728 (2023-11-07T20:58:48+00:00)
RequirementChecker:
Required:
- PHP >=5.3 (root)
- ext-phar (root)
Contents: 47 files (148.01KB)
Contents: 47 files (147.97KB)
// Use the --list|-l option to list the content of the PHAR.

Expand Down
20 changes: 20 additions & 0 deletions tests/RequirementChecker/RequirementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ public function test_it_can_be_created_for_a_conflicting_extension_constraint_fo
self::assertItCanBeCreatedFromItsArrayForm($requirement, $actual);
}

public function test_it_can_be_created_for_a_legacy_requirement(): void
{
$expected = new Requirement(
RequirementType::EXTENSION_CONFLICT,
'mbstring',
null,
'The package "box/test" conflicts with the extension "mbstring".',
'The package "box/test" conflicts with the extension "mbstring". You need to disable it in order to run this application.',
);

$actual = Requirement::fromArray([
'type' => 'extension-conflict',
'condition' => 'mbstring',
'message' => 'The package "box/test" conflicts with the extension "mbstring".',
'helpMessage' => 'The package "box/test" conflicts with the extension "mbstring". You need to disable it in order to run this application.',
]);

self::assertEquals($expected, $actual);
}

private static function assertItCanBeCreatedFromItsArrayForm(Requirement $expected, array $arrayForm): void
{
$actual = Requirement::fromArray($arrayForm);
Expand Down

0 comments on commit d944fb9

Please sign in to comment.