Skip to content

Commit

Permalink
feat(requirement-checker): Improve the required PHP version required …
Browse files Browse the repository at this point in the history
…message (#1119)
  • Loading branch information
danepowell authored Oct 23, 2023
1 parent d184034 commit 2d8daf1
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 56 deletions.
28 changes: 14 additions & 14 deletions requirement-checker/tests/CheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ public function provideRequirements(): iterable

$requirements->addRequirement(
new ConditionIsFulfilled(),
'The application requires the version "7.2.0" or greater.',
'The application requires the version "7.2.0" or greater. Got "7.2.2"',
'This application requires the PHP version "7.2.0" or greater.',
'This application requires the PHP version "7.2.0" or greater. Got "7.2.2"',
);
$requirements->addRequirement(
new class() implements IsFulfilled {
Expand All @@ -182,7 +182,7 @@ public function __invoke(): bool
/path/to/php.ini
> Checking Box requirements:
The application requires the version "7.2.0" or greater.
This application requires the PHP version "7.2.0" or greater.
✔ The package "acme/foo" requires the extension "random".
Expand All @@ -199,8 +199,8 @@ public function __invoke(): bool

$requirements->addRequirement(
new ConditionIsFulfilled(),
'The application requires the version "7.2.0" or greater. Got "7.2.2"',
'The application requires the version "7.2.0" or greater.'
'This application requires the PHP version "7.2.0" or greater. Got "7.2.2"',
'This application requires the PHP version "7.2.0" or greater.'
);
$requirements->addRequirement(
new ConditionIsFulfilled(),
Expand Down Expand Up @@ -239,8 +239,8 @@ public function __invoke(): bool

$requirements->addRequirement(
new ConditionIsFulfilled(),
'The application requires the version "7.2.0" or greater. Got "7.2.2"',
'The application requires the version "7.2.0" or greater.'
'This application requires the PHP version "7.2.0" or greater. Got "7.2.2"',
'This application requires the PHP version "7.2.0" or greater.'
);
$requirements->addRequirement(
new ConditionIsFulfilled(),
Expand All @@ -262,8 +262,8 @@ public function __invoke(): bool

$requirements->addRequirement(
new ConditionIsFulfilled(),
'The application requires the version "7.2.0" or greater. Got "7.2.2"',
'The application requires the version "7.2.0" or greater.'
'This application requires the PHP version "7.2.0" or greater. Got "7.2.2"',
'This application requires the PHP version "7.2.0" or greater.'
);
$requirements->addRequirement(
new ConditionIsNotFulfilled(),
Expand All @@ -285,7 +285,7 @@ public function __invoke(): bool
/path/to/php.ini
> Checking Box requirements:
The application requires the version "7.2.0" or greater. Got "7.2.2"
This application requires the PHP version "7.2.0" or greater. Got "7.2.2"
✘ The package "acme/foo" requires the extension "random".
Expand All @@ -309,8 +309,8 @@ public function __invoke(): bool

$requirements->addRequirement(
new ConditionIsFulfilled(),
'The application requires the version "7.2.0" or greater. Got "7.2.2"',
'The application requires the version "7.2.0" or greater.'
'This application requires the PHP version "7.2.0" or greater. Got "7.2.2"',
'This application requires the PHP version "7.2.0" or greater.'
);
$requirements->addRequirement(
new ConditionIsNotFulfilled(),
Expand Down Expand Up @@ -355,8 +355,8 @@ public function __invoke(): bool

$requirements->addRequirement(
new ConditionIsFulfilled(),
'The application requires the version "7.2.0" or greater. Got "7.2.2"',
'The application requires the version "7.2.0" or greater.'
'This application requires the PHP version "7.2.0" or greater. Got "7.2.2"',
'This application requires the PHP version "7.2.0" or greater.'
);
$requirements->addRequirement(
new ConditionIsNotFulfilled(),
Expand Down
16 changes: 8 additions & 8 deletions src/RequirementChecker/Requirement.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ public static function forPHP(string $requiredPhpVersion, ?string $packageName):
$packageName,
null === $packageName
? sprintf(
'The application requires a version matching "%s".',
'This application requires a PHP version matching "%s".',
$requiredPhpVersion,
)
: sprintf(
'The package "%s" requires a version matching "%s".',
'The package "%s" requires a PHP version matching "%s".',
$packageName,
$requiredPhpVersion,
),
null === $packageName
? sprintf(
'The application requires a version matching "%s".',
'This application requires a PHP version matching "%s".',
$requiredPhpVersion,
)
: sprintf(
'The package "%s" requires a version matching "%s".',
'The package "%s" requires a PHP version matching "%s".',
$packageName,
$requiredPhpVersion,
),
Expand All @@ -65,7 +65,7 @@ public static function forRequiredExtension(string $extension, ?string $packageN
$packageName,
null === $packageName
? sprintf(
'The application requires the extension "%s".',
'This application requires the extension "%s".',
$extension,
)
: sprintf(
Expand All @@ -75,7 +75,7 @@ public static function forRequiredExtension(string $extension, ?string $packageN
),
null === $packageName
? sprintf(
'The application requires the extension "%s". You either need to enable it or request the application to be shipped with a polyfill for this extension.',
'This application requires the extension "%s". You either need to enable it or request the application to be shipped with a polyfill for this extension.',
$extension,
)
: sprintf(
Expand All @@ -94,7 +94,7 @@ public static function forConflictingExtension(string $extension, ?string $packa
$packageName,
null === $packageName
? sprintf(
'The application conflicts with the extension "%s".',
'This application conflicts with the extension "%s".',
$extension,
)
: sprintf(
Expand All @@ -104,7 +104,7 @@ public static function forConflictingExtension(string $extension, ?string $packa
),
null === $packageName
? sprintf(
'The application conflicts with the extension "%s". You need to disable it in order to run this application.',
'This application conflicts with the extension "%s". You need to disable it in order to run this application.',
$extension,
)
: sprintf(
Expand Down
44 changes: 22 additions & 22 deletions tests/DockerFileGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,20 @@ public static function generatorRequirementsProvider(): iterable
[
'type' => 'php',
'condition' => '^7.1',
'message' => 'The application requires the version "^7.1" or greater.',
'helpMessage' => 'The application requires the version "^7.1" or greater.',
'message' => 'This application requires the PHP version "^7.1" or greater.',
'helpMessage' => 'This application requires the PHP version "^7.1" or greater.',
],
[
'type' => 'extension',
'condition' => 'zlib',
'message' => 'The application requires the extension "zlib". Enable it or install a polyfill.',
'helpMessage' => 'The application requires the extension "zlib".',
'message' => 'This application requires the extension "zlib". Enable it or install a polyfill.',
'helpMessage' => 'This application requires the extension "zlib".',
],
[
'type' => 'extension',
'condition' => 'phar',
'message' => 'The application requires the extension "phar". Enable it or install a polyfill.',
'helpMessage' => 'The application requires the extension "phar".',
'message' => 'This application requires the extension "phar". Enable it or install a polyfill.',
'helpMessage' => 'This application requires the extension "phar".',
],
[
'type' => 'extension',
Expand Down Expand Up @@ -212,20 +212,20 @@ public static function generatorRequirementsProvider(): iterable
[
'type' => 'php',
'condition' => '^7.1',
'message' => 'The application requires the version "^7.1" or greater.',
'helpMessage' => 'The application requires the version "^7.1" or greater.',
'message' => 'This application requires the PHP version "^7.1" or greater.',
'helpMessage' => 'This application requires the PHP version "^7.1" or greater.',
],
[
'type' => 'php',
'condition' => '~7.1.0',
'message' => 'The application requires the version "^7.1" or greater.',
'helpMessage' => 'The application requires the version "^7.1" or greater.',
'message' => 'This application requires the PHP version "^7.1" or greater.',
'helpMessage' => 'This application requires the PHP version "^7.1" or greater.',
],
[
'type' => 'extension',
'condition' => 'zlib',
'message' => 'The application requires the extension "zlib". Enable it or install a polyfill.',
'helpMessage' => 'The application requires the extension "zlib".',
'message' => 'This application requires the extension "zlib". Enable it or install a polyfill.',
'helpMessage' => 'This application requires the extension "zlib".',
],
],
'box.phar',
Expand All @@ -247,14 +247,14 @@ public static function generatorRequirementsProvider(): iterable
[
'type' => 'php',
'condition' => '^7.1',
'message' => 'The application requires the version "^7.1" or greater.',
'helpMessage' => 'The application requires the version "^7.1" or greater.',
'message' => 'This application requires the PHP version "^7.1" or greater.',
'helpMessage' => 'This application requires the PHP version "^7.1" or greater.',
],
[
'type' => 'php',
'condition' => '~7.1.0',
'message' => 'The application requires the version "^7.1" or greater.',
'helpMessage' => 'The application requires the version "^7.1" or greater.',
'message' => 'This application requires the PHP version "^7.1" or greater.',
'helpMessage' => 'This application requires the PHP version "^7.1" or greater.',
],
],
'box.phar',
Expand All @@ -275,20 +275,20 @@ public static function generatorRequirementsProvider(): iterable
[
'type' => 'php',
'condition' => '^7.1',
'message' => 'The application requires the version "^7.1" or greater.',
'helpMessage' => 'The application requires the version "^7.1" or greater.',
'message' => 'This application requires the PHP version "^7.1" or greater.',
'helpMessage' => 'This application requires the PHP version "^7.1" or greater.',
],
[
'type' => 'php',
'condition' => '~7.1.0',
'message' => 'The application requires the version "^7.1" or greater.',
'helpMessage' => 'The application requires the version "^7.1" or greater.',
'message' => 'This application requires the PHP version "^7.1" or greater.',
'helpMessage' => 'This application requires the PHP version "^7.1" or greater.',
],
[
'type' => 'extension',
'condition' => 'zlib',
'message' => 'The application requires the extension "zlib". Enable it or install a polyfill.',
'helpMessage' => 'The application requires the extension "zlib".',
'message' => 'This application requires the extension "zlib". Enable it or install a polyfill.',
'helpMessage' => 'This application requires the extension "zlib".',
],
[
'type' => 'extension',
Expand Down
16 changes: 8 additions & 8 deletions tests/RequirementChecker/RequirementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function test_it_can_be_created_for_a_php_version(): void
'type' => 'php',
'condition' => '^8.2',
'source' => null,
'message' => 'The application requires a version matching "^8.2".',
'helpMessage' => 'The application requires a version matching "^8.2".',
'message' => 'This application requires a PHP version matching "^8.2".',
'helpMessage' => 'This application requires a PHP version matching "^8.2".',
];

$actual = $requirement->toArray();
Expand All @@ -49,8 +49,8 @@ public function test_it_can_be_created_for_a_php_version_for_a_package(): void
'type' => 'php',
'condition' => '^8.2',
'source' => 'box/test',
'message' => 'The package "box/test" requires a version matching "^8.2".',
'helpMessage' => 'The package "box/test" requires a version matching "^8.2".',
'message' => 'The package "box/test" requires a PHP version matching "^8.2".',
'helpMessage' => 'The package "box/test" requires a PHP version matching "^8.2".',
];

$actual = $requirement->toArray();
Expand All @@ -67,8 +67,8 @@ public function test_it_can_be_created_for_an_extension_constraint(): void
'type' => 'extension',
'condition' => 'mbstring',
'source' => null,
'message' => 'The application requires the extension "mbstring".',
'helpMessage' => 'The application requires the extension "mbstring". You either need to enable it or request the application to be shipped with a polyfill for this extension.',
'message' => 'This application requires the extension "mbstring".',
'helpMessage' => 'This application requires the extension "mbstring". You either need to enable it or request the application to be shipped with a polyfill for this extension.',
];

$actual = $requirement->toArray();
Expand Down Expand Up @@ -103,8 +103,8 @@ public function test_it_can_be_created_for_a_conflicting_extension_constraint():
'type' => 'extension-conflict',
'condition' => 'mbstring',
'source' => null,
'message' => 'The application conflicts with the extension "mbstring".',
'helpMessage' => 'The application conflicts with the extension "mbstring". You need to disable it in order to run this application.',
'message' => 'This application conflicts with the extension "mbstring".',
'helpMessage' => 'This application conflicts with the extension "mbstring". You need to disable it in order to run this application.',
];

$actual = $requirement->toArray();
Expand Down
8 changes: 4 additions & 4 deletions tests/RequirementChecker/RequirementsDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ public static function jsonAndLockContentsProvider(): iterable
'type' => 'php',
'condition' => '^7.4',
'source' => 'acme/foo',
'message' => 'The package "acme/foo" requires a version matching "^7.4".',
'helpMessage' => 'The package "acme/foo" requires a version matching "^7.4".',
'message' => 'The package "acme/foo" requires a PHP version matching "^7.4".',
'helpMessage' => 'The package "acme/foo" requires a PHP version matching "^7.4".',
),
1 =>
array (
'type' => 'extension',
'condition' => 'zlib',
'source' => NULL,
'message' => 'The application requires the extension "zlib".',
'helpMessage' => 'The application requires the extension "zlib". You either need to enable it or request the application to be shipped with a polyfill for this extension.',
'message' => 'This application requires the extension "zlib".',
'helpMessage' => 'This application requires the extension "zlib". You either need to enable it or request the application to be shipped with a polyfill for this extension.',
),
2 =>
array (
Expand Down

0 comments on commit 2d8daf1

Please sign in to comment.