Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(requirement-checker): Fix the constraint message displayed #876

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ Box Requirements Checker

> Checking Box requirements:
✘ The application requires a version matching "^10".
✔ The application requires the extension "phar".
✔ The package "package-with-extensions" requires the extension "json".
✔ The application requires the extension "phar". Enable it or install a
polyfill.
✔ The package "package-with-extensions" requires the extension "json". Enable
it or install a polyfill.
✘ The package "package-with-extensions" requires the extension "ldap". Enable
it or install a polyfill.
✘ The package "package-with-extensions" requires the extension "random".
Expand All @@ -23,8 +25,6 @@ Fix the following mandatory requirements:
=========================================

* The application requires a version matching "^10".
* The package "package-with-extensions" requires the extension "ldap". Enable
it or install a polyfill.
* The package "package-with-extensions" requires the extension "random". Enable
it or install a polyfill.
* The package "package-with-extensions" requires the extension "ldap".
* The package "package-with-extensions" requires the extension "random".

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ Box Requirements Checker

> Checking Box requirements:
✘ The application requires a version matching "^10".
✔ The application requires the extension "phar".
✔ The package "package-with-extensions" requires the extension "json".
✔ The application requires the extension "phar". Enable it or install a
polyfill.
✔ The package "package-with-extensions" requires the extension "json". Enable
it or install a polyfill.
✘ The package "package-with-extensions" requires the extension "ldap". Enable
it or install a polyfill.
✘ The package "package-with-extensions" requires the extension "random".
Expand All @@ -23,8 +25,6 @@ Fix the following mandatory requirements:
=========================================

* The application requires a version matching "^10".
* The package "package-with-extensions" requires the extension "ldap". Enable
it or install a polyfill.
* The package "package-with-extensions" requires the extension "random". Enable
it or install a polyfill.
* The package "package-with-extensions" requires the extension "ldap".
* The package "package-with-extensions" requires the extension "random".

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Box Requirements Checker
WARNING: No configuration file (php.ini) used by PHP!

> Checking Box requirements:
✔ The application requires the extension "phar".
✔ The application requires the extension "phar". Enable it or install a
polyfill.
✘ The application conflicts with the extension "pdo".


Expand All @@ -17,5 +18,5 @@ Box Requirements Checker
Fix the following mandatory requirements:
=========================================

* The application conflicts with the extension "pdo".
* The application conflicts with the extension "pdo". Disable it.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Box Requirements Checker

> Checking Box requirements:
✔ The application requires a version matching ">=5.3".
✔ The application requires the extension "phar".
✔ The application requires the extension "phar". Enable it or install a
polyfill.


[OK] Your system is ready to run the application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Box Requirements Checker

> Checking Box requirements:
✔ The application requires a version matching ">=5.3".
✔ The application requires the extension "phar".
✔ The application requires the extension "phar". Enable it or install a
polyfill.


[OK] Your system is ready to run the application.
Expand Down
2 changes: 1 addition & 1 deletion requirement-checker/src/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function printCheck($checkPassed, Printer $printer, RequirementCol
}

if (IO::VERBOSITY_DEBUG === $printer->getVerbosity()) {
$printer->printvln('✔ '.$requirement->getHelpText(), IO::VERBOSITY_DEBUG, 'green');
$printer->printvln('✔ '.$requirement->getTestMessage(), IO::VERBOSITY_DEBUG, 'green');
$printer->printv(' ', IO::VERBOSITY_DEBUG);
} else {
$printer->printv('.', $verbosity, 'green');
Expand Down
2 changes: 1 addition & 1 deletion requirement-checker/src/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getRequirementErrorMessage(Requirement $requirement): ?string
return null;
}

return wordwrap($requirement->getTestMessage(), $this->width - 3, PHP_EOL.' ').PHP_EOL;
return wordwrap($requirement->getHelpText(), $this->width - 3, PHP_EOL.' ').PHP_EOL;
}

public function block(string $title, string $message, int $verbosity, ?string $style = null): void
Expand Down
44 changes: 22 additions & 22 deletions requirement-checker/tests/CheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public function test_it_can_check_requirements(
public function provideRequirements(): Generator
{
$phpVersion = PHP_VERSION;
$remainingVerbosities = ['verbosity=verbose' => IO::VERBOSITY_VERBOSE, 'verbosity=normal' => IO::VERBOSITY_NORMAL, 'verbosity=quiet' => IO::VERBOSITY_QUIET];

yield (static function () use ($phpVersion) {
yield 'no requirement; verbosity=debug' => (static function () use ($phpVersion) {
return [
new RequirementCollection(),
IO::VERBOSITY_DEBUG,
Expand All @@ -89,7 +90,7 @@ public function provideRequirements(): Generator
];
})();

yield (static function () use ($phpVersion) {
yield 'no requirement; verbosity=very verbose' => (static function () use ($phpVersion) {
return [
new RequirementCollection(),
IO::VERBOSITY_VERY_VERBOSE,
Expand All @@ -114,8 +115,8 @@ public function provideRequirements(): Generator
];
})();

foreach ([IO::VERBOSITY_VERBOSE, IO::VERBOSITY_NORMAL, IO::VERBOSITY_QUIET] as $verbosity) {
yield (static function () use ($verbosity) {
foreach ($remainingVerbosities as $label => $verbosity) {
yield 'no requirements; '.$label => (static function () use ($verbosity) {
return [
new RequirementCollection(),
$verbosity,
Expand All @@ -125,13 +126,13 @@ public function provideRequirements(): Generator
})();
}

yield (static function () use ($phpVersion) {
yield 'requirements; check passes; verbosity=debug' => (static function () use ($phpVersion) {
$requirements = new RequirementCollection();

$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"',
'The application requires the version "7.2.0" or greater.'
);
$requirements->addRequirement(
new class() implements IsFulfilled {
Expand All @@ -140,8 +141,8 @@ public function __invoke(): bool
return true;
}
},
'The package "acme/foo" requires the extension "random".',
'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.',
'The package "acme/foo" requires the extension "random".'
);

return [
Expand Down Expand Up @@ -170,7 +171,7 @@ public function __invoke(): bool
];
})();

yield (static function () use ($phpVersion) {
yield 'requirements; check passes; verbosity=very verbose' => (static function () use ($phpVersion) {
$requirements = new RequirementCollection();

$requirements->addRequirement(
Expand All @@ -180,8 +181,8 @@ public function __invoke(): bool
);
$requirements->addRequirement(
new ConditionIsFulfilled(),
'The package "acme/foo" requires the extension "random".',
'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.',
'The package "acme/foo" requires the extension "random".'
);

return [
Expand Down Expand Up @@ -209,8 +210,8 @@ public function __invoke(): bool
];
})();

foreach ([IO::VERBOSITY_VERBOSE, IO::VERBOSITY_NORMAL, IO::VERBOSITY_QUIET] as $verbosity) {
yield (static function () use ($verbosity) {
foreach ($remainingVerbosities as $label => $verbosity) {
yield 'requirements; check passes; '.$label => (static function () use ($verbosity) {
$requirements = new RequirementCollection();

$requirements->addRequirement(
Expand All @@ -220,8 +221,8 @@ public function __invoke(): bool
);
$requirements->addRequirement(
new ConditionIsFulfilled(),
'The package "acme/foo" requires the extension "random".',
'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.',
'The package "acme/foo" requires the extension "random".'
);

return [
Expand All @@ -233,7 +234,7 @@ public function __invoke(): bool
})();
}

yield (static function () use ($phpVersion) {
yield 'requirements; check do not pass; verbosity=debug' => (static function () use ($phpVersion) {
$requirements = new RequirementCollection();

$requirements->addRequirement(
Expand All @@ -243,8 +244,8 @@ public function __invoke(): bool
);
$requirements->addRequirement(
new ConditionIsNotFulfilled(),
'The package "acme/foo" requires the extension "random".',
'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.',
'The package "acme/foo" requires the extension "random".'
);

return [
Expand All @@ -261,9 +262,8 @@ public function __invoke(): bool
/path/to/php.ini

> Checking Box requirements:
✔ The application requires the version "7.2.0" or greater.
✘ The package "acme/foo" requires the extension "random". Enable it or install
a polyfill.
✔ The application requires the version "7.2.0" or greater. Got "7.2.2"
✘ The package "acme/foo" requires the extension "random".


[ERROR] Your system is not ready to run the application.
Expand All @@ -280,8 +280,8 @@ public function __invoke(): bool
];
})();

foreach ([IO::VERBOSITY_VERY_VERBOSE, IO::VERBOSITY_VERBOSE, IO::VERBOSITY_NORMAL] as $verbosity) {
yield (static function () use ($verbosity, $phpVersion) {
foreach (['verbosity=very verbose' => IO::VERBOSITY_VERY_VERBOSE, 'verbosity=verbose' => IO::VERBOSITY_VERBOSE, 'verbosity=normal' => IO::VERBOSITY_NORMAL] as $label => $verbosity) {
yield 'requirements; check do not pass; '.$label => (static function () use ($verbosity, $phpVersion) {
$requirements = new RequirementCollection();

$requirements->addRequirement(
Expand All @@ -291,8 +291,8 @@ public function __invoke(): bool
);
$requirements->addRequirement(
new ConditionIsNotFulfilled(),
'The package "acme/foo" requires the extension "random".',
'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.',
'The package "acme/foo" requires the extension "random".'
);

return [
Expand Down Expand Up @@ -327,7 +327,7 @@ public function __invoke(): bool
})();
}

yield (static function () use ($phpVersion) {
yield 'requirements; check do not pass; verbosity=quiet' => (static function () use ($phpVersion) {
$requirements = new RequirementCollection();

$requirements->addRequirement(
Expand All @@ -337,8 +337,8 @@ public function __invoke(): bool
);
$requirements->addRequirement(
new ConditionIsNotFulfilled(),
'The package "acme/foo" requires the extension "random".',
'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.',
'The package "acme/foo" requires the extension "random".'
);

return [
Expand Down
4 changes: 2 additions & 2 deletions requirement-checker/tests/PrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function provideErrorRequirements(): Generator
false,
50,
<<<'EOF'
Test message
Help message

EOF
];
Expand All @@ -210,7 +210,7 @@ public function provideErrorRequirements(): Generator
true,
50,
<<<'EOF'
Test message
Help message

EOF
];
Expand Down
2 changes: 1 addition & 1 deletion res/requirement-checker/src/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function printCheck($checkPassed, Printer $printer, RequirementCol
continue;
}
if (IO::VERBOSITY_DEBUG === $printer->getVerbosity()) {
$printer->printvln('✔ ' . $requirement->getHelpText(), IO::VERBOSITY_DEBUG, 'green');
$printer->printvln('✔ ' . $requirement->getTestMessage(), IO::VERBOSITY_DEBUG, 'green');
$printer->printv(' ', IO::VERBOSITY_DEBUG);
} else {
$printer->printv('.', $verbosity, 'green');
Expand Down
2 changes: 1 addition & 1 deletion res/requirement-checker/src/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getRequirementErrorMessage(Requirement $requirement) : ?string
if ($requirement->isFulfilled()) {
return null;
}
return wordwrap($requirement->getTestMessage(), $this->width - 3, PHP_EOL . ' ') . PHP_EOL;
return wordwrap($requirement->getHelpText(), $this->width - 3, PHP_EOL . ' ') . PHP_EOL;
}
public function block(string $title, string $message, int $verbosity, ?string $style = null) : void
{
Expand Down