Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not allow using Infection with Codeception < 3.1.1 #867

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
)
);
}
}
}