Skip to content

Commit

Permalink
README: version check - minor tweak
Browse files Browse the repository at this point in the history
Improve the code sample.
  • Loading branch information
jrfnl committed Sep 21, 2021
1 parent 03eb1bb commit 2b1e80e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,17 +698,19 @@ As of version 1.0.1, the PHPUnit Polyfills `Autoload` class contains a version n

Typically such a check would be done in the test suite bootstrap file and could look something like this:
```php
$versionRequirement = '1.0.1';
if ( class_exists( '\Yoast\PHPUnitPolyfills\Autoload' ) === false ) {
require_once `vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php`;
} elseif ( defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) === false
}

$versionRequirement = '1.0.1';
if ( defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) === false
|| version_compare( \Yoast\PHPUnitPolyfills\Autoload::VERSION, $versionRequirement, '<' )
) {
echo 'Error: Version mismatch detected for the PHPUnit Polyfills. Please ensure that PHPUnit Polyfills ',
$versionRequirement, ' or higher is loaded.', PHP_EOL;
exit(1);
} else {
echo 'Error: Please run `composer update` before running the tests.' . PHP_EOL;
echo 'Error: Please run `composer update -W` before running the tests.' . PHP_EOL;
echo 'You can still use a PHPUnit phar to run them, but the dependencies do need to be installed.', PHP_EOL;
exit(1);
}
Expand Down

0 comments on commit 2b1e80e

Please sign in to comment.