Skip to content

Commit 0b06d36

Browse files
Merge branch '8.5' into 9.6
2 parents 040e6b9 + 6b0162e commit 0b06d36

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

src/TextUI/Command.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,31 @@ protected function handleVersionCheck(): void
598598
{
599599
$this->printVersionString();
600600

601-
$latestVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
602-
$isOutdated = version_compare($latestVersion, Version::id(), '>');
601+
$latestVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
602+
$latestCompatibleVersion = file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit-' . explode('.', Version::series())[0]);
603603

604-
if ($isOutdated) {
604+
$notLatest = version_compare($latestVersion, Version::id(), '>');
605+
$notLatestCompatible = version_compare($latestCompatibleVersion, Version::id(), '>');
606+
607+
if ($notLatest || $notLatestCompatible) {
608+
print 'You are not using the latest version of PHPUnit.' . PHP_EOL;
609+
} else {
610+
print 'You are using the latest version of PHPUnit.' . PHP_EOL;
611+
}
612+
613+
if ($notLatestCompatible) {
614+
printf(
615+
'The latest version compatible with PHPUnit %s is PHPUnit %s.' . PHP_EOL,
616+
Version::id(),
617+
$latestCompatibleVersion
618+
);
619+
}
620+
621+
if ($notLatest) {
605622
printf(
606-
'You are not using the latest version of PHPUnit.' . PHP_EOL .
607623
'The latest version is PHPUnit %s.' . PHP_EOL,
608624
$latestVersion,
609625
);
610-
} else {
611-
print 'You are using the latest version of PHPUnit.' . PHP_EOL;
612626
}
613627

614628
exit(TestRunner::SUCCESS_EXIT);

src/TextUI/Help.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private function elements(): array
273273
['arg' => '-h|--help', 'desc' => 'Prints this usage information'],
274274
['arg' => '--version', 'desc' => 'Prints the version and exits'],
275275
['arg' => '--atleast-version <min>', 'desc' => 'Checks that version is greater than min and exits'],
276-
['arg' => '--check-version', 'desc' => 'Check whether PHPUnit is the latest version'],
276+
['arg' => '--check-version', 'desc' => 'Checks whether PHPUnit is the latest version and exits'],
277277
];
278278

279279
return $elements;

tests/end-to-end/_files/output-cli-help-color.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@
139139
--version  Prints the version and exits
140140
--atleast-version <min>  Checks that version is greater than min
141141
and exits
142-
--check-version  Check whether PHPUnit is the latest
143-
version
142+
--check-version  Checks whether PHPUnit is the latest
143+
version and exits
144144

tests/end-to-end/_files/output-cli-usage.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ Miscellaneous Options:
109109
-h|--help Prints this usage information
110110
--version Prints the version and exits
111111
--atleast-version <min> Checks that version is greater than min and exits
112-
--check-version Check whether PHPUnit is the latest version
112+
--check-version Checks whether PHPUnit is the latest version and exits

0 commit comments

Comments
 (0)