Skip to content

Commit

Permalink
Do not allow using Infection with Codeception < 3.1.1 (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-rafalko committed Nov 28, 2019
1 parent e79eb9e commit 73bb17a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions devTools/phpstan-src.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ parameters:
path: '%currentWorkingDirectory%/src/Process/Runner/Parallel/ParallelProcessRunner.php'
message: '#Left side of [\&]{2} is always true#'
- '#Method Infection\Configuration\Schema\SchemaConfigurationFile::getDecodedContents() should return stdClass but returns stdClass|null.#'

-
path: '%currentWorkingDirectory%/src/TestFramework/Factory.php'
message: '#Access to constant VERSION on an unknown class Codeception\\Codecept#'
19 changes: 19 additions & 0 deletions src/TestFramework/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
use Infection\TestFramework\PhpUnit\Config\XmlConfigurationHelper;
use Infection\Utils\VersionParser;
use InvalidArgumentException;
use LogicException;
use function Safe\file_get_contents;
use function Safe\sprintf;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
Expand Down Expand Up @@ -168,6 +170,7 @@ public function create(string $adapterName, bool $skipCoverage): TestFrameworkAd
}

if ($adapterName === TestFrameworkTypes::CODECEPTION) {
$this->ensureCodeceptionVersionIsSupported();
$codeceptionConfigPath = $this->configLocator->locate(TestFrameworkTypes::CODECEPTION);
$codeceptionConfigContentParsed = $this->parseYaml($codeceptionConfigPath);

Expand Down Expand Up @@ -207,4 +210,20 @@ private function parseYaml(string $codeceptionConfigPath): array

return $codeceptionConfigContentParsed;
}

private function ensureCodeceptionVersionIsSupported(): void
{
if (!class_exists('\Codeception\Codecept')) {
return;
}

if (version_compare(\Codeception\Codecept::VERSION, '3.1.1', '<')) {
throw new LogicException(
sprintf(
'Current Codeception version "%s" is not supported by Infection. Please use >=3.1.1',
\Codeception\Codecept::VERSION
)
);
}
}
}

0 comments on commit 73bb17a

Please sign in to comment.