From e3b8e8339112ebea42c112b64ce97613a6da94b7 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Sat, 23 Mar 2019 06:00:09 +0900 Subject: [PATCH] Use TestFrameworkTypes::PHPUNIT where a default value needed --- src/Command/InfectionCommand.php | 3 +-- src/Config/InfectionConfig.php | 3 ++- src/Console/InfectionContainer.php | 9 +-------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Command/InfectionCommand.php b/src/Command/InfectionCommand.php index 63392d400d..2ac1cf8aed 100644 --- a/src/Command/InfectionCommand.php +++ b/src/Command/InfectionCommand.php @@ -362,10 +362,9 @@ private function runConfigurationCommand(Locator $locator): void $locator->locateOneOf(InfectionConfig::POSSIBLE_CONFIG_FILE_NAMES); } catch (\Exception $e) { $configureCommand = $this->getApplication()->find('configure'); - $config = $this->getContainer()->get('infection.config.initial'); $args = [ - '--test-framework' => $this->input->getOption('test-framework') ?: $config->getTestFramework(), + '--test-framework' => $this->input->getOption('test-framework') ?: TestFrameworkTypes::PHPUNIT, ]; $newInput = new ArrayInput($args); diff --git a/src/Config/InfectionConfig.php b/src/Config/InfectionConfig.php index 91843a6b73..0d85194136 100644 --- a/src/Config/InfectionConfig.php +++ b/src/Config/InfectionConfig.php @@ -35,6 +35,7 @@ namespace Infection\Config; +use Infection\TestFramework\TestFrameworkTypes; use Symfony\Component\Filesystem\Filesystem; /** @@ -152,7 +153,7 @@ public function getBootstrap(): string public function getTestFramework(): string { - return $this->config->testFramework ?? 'phpunit'; + return $this->config->testFramework ?? TestFrameworkTypes::PHPUNIT; } public function getInitialTestsPhpOptions(): string diff --git a/src/Console/InfectionContainer.php b/src/Console/InfectionContainer.php index 4ae5c514fa..47fd9896a9 100644 --- a/src/Console/InfectionContainer.php +++ b/src/Console/InfectionContainer.php @@ -232,19 +232,12 @@ public function __construct(array $values = []) public function buildDynamicDependencies(InputInterface $input): void { - $infectionConfigMaker = function () use ($input): InfectionConfig { + $this['infection.config'] = function () use ($input): InfectionConfig { $facade = new ConfigCreatorFacade($this['locator'], $this['filesystem']); return $facade->createConfig($input->getOption('configuration')); }; - /* - * Configuration step needs a distinct instance of a configuration as it may be inexistent. - * Therefore we can avoid using this stale and invalid configuration later on. - */ - $this['infection.config.initial'] = $infectionConfigMaker; - $this['infection.config'] = $infectionConfigMaker; - $this['coverage.path'] = function () use ($input): string { $existingCoveragePath = '';