Skip to content

Commit

Permalink
fix(requirement-checker): update the message to avoid confusing the u…
Browse files Browse the repository at this point in the history
…sers (#906)
  • Loading branch information
theofidry authored Oct 16, 2023
1 parent b1bf58d commit 9a3856c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
5 changes: 2 additions & 3 deletions requirement-checker/src/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ public static function printCheck($checkPassed, Printer $printer, RequirementCol
$printer->printv('> Using PHP ', $verbosity);
$printer->printvln(PHP_VERSION, $verbosity, 'green');

$printer->printvln('> PHP is using the following php.ini file:', $verbosity);

if ($iniPath) {
$printer->printvln('> PHP is using the following php.ini file:', $verbosity);
$printer->printvln(' '.$iniPath, $verbosity, 'green');
} else {
$printer->printvln(' WARNING: No configuration file (php.ini) used by PHP!', $verbosity, 'yellow');
$printer->printvln('> PHP is not using any php.ini file.', $verbosity, 'yellow');
}

$printer->printvln('', $verbosity);
Expand Down
17 changes: 16 additions & 1 deletion requirement-checker/src/RequirementCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ final class RequirementCollection implements IteratorAggregate, Countable
*/
private $requirements = [];

/**
* @var string|false
*/
private $phpIniPath;

/**
* @param string|false|null $phpIniPath
*/
public function __construct($phpIniPath = null)
{
$this->phpIniPath = null === $phpIniPath
? get_cfg_var('cfg_file_path')
: $phpIniPath;
}

/**
* @return Traversable<Requirement>
*/
Expand Down Expand Up @@ -83,7 +98,7 @@ public function getRequirements(): array
*/
public function getPhpIniPath()
{
return get_cfg_var('cfg_file_path');
return $this->phpIniPath;
}

/**
Expand Down
24 changes: 24 additions & 0 deletions requirement-checker/tests/CheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,30 @@ public function provideRequirements(): iterable
EOF
];
})();

yield 'no requirement + no ini path; verbosity=debug' => (static function () use ($phpVersion) {
return [
new RequirementCollection(false),
IO::VERBOSITY_DEBUG,
true,
<<<EOF
Box Requirements Checker
========================
> Using PHP {$phpVersion}
> PHP is not using any php.ini file.
> No requirements found.
[OK] Your system is ready to run the application.
EOF
];
})();
Expand Down

0 comments on commit 9a3856c

Please sign in to comment.