*/ public const VERSION_OPERATORS = [ 'newer than' => '>', 'older than' => '<', ]; /** * @Given /I have PHPUnit (newer than|older than) "([0-9.]+)" \(because of "([^"]+)"\)/ * * @return void */ public function havePHPUnitOfACertainVersionRangeBecauseOf(string $operator, string $version, string $reason) { if (!isset(self::VERSION_OPERATORS[$operator])) { throw new TestRuntimeException("Unknown operator: $operator"); } $op = (string) self::VERSION_OPERATORS[$operator]; $currentVersion = (string) explode('@', Versions::getVersion('phpunit/phpunit'))[0]; $this->debug(sprintf("Current version: %s", $currentVersion)); $parser = new VersionParser(); $currentVersion = $parser->normalize($currentVersion); $version = $parser->normalize($version); $result = Comparator::compare($currentVersion, $op, $version); $this->debug("Comparing $currentVersion $op $version => $result"); if (!$result) { throw new Skip("This scenario requires PHPUnit $op $version because of $reason"); } } }