diff --git a/src/Command/BaseCommand.php b/src/Command/BaseCommand.php index e5020b5bf..bbeb21722 100644 --- a/src/Command/BaseCommand.php +++ b/src/Command/BaseCommand.php @@ -74,8 +74,6 @@ public function getContainer(): Container protected function initialize(InputInterface $input, OutputInterface $output): void { - parent::initialize($input, $output); - $this->input = $input; $this->output = $output; } diff --git a/src/Command/InfectionCommand.php b/src/Command/InfectionCommand.php index eac0d67de..4cc70984d 100644 --- a/src/Command/InfectionCommand.php +++ b/src/Command/InfectionCommand.php @@ -352,10 +352,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'); $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 cb4daaede..05f35317f 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/tests/Fixtures/e2e/Initial_Configuration/composer.json b/tests/Fixtures/e2e/Initial_Configuration/composer.json new file mode 100644 index 000000000..d829e45ca --- /dev/null +++ b/tests/Fixtures/e2e/Initial_Configuration/composer.json @@ -0,0 +1,15 @@ +{ + "require-dev": { + "phpunit/phpunit": "^6.5" + }, + "autoload": { + "psr-4": { + "Initial_Configuration\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Initial_Configuration\\Test\\": "tests/" + } + } +} diff --git a/tests/Fixtures/e2e/Initial_Configuration/do_configure.expect b/tests/Fixtures/e2e/Initial_Configuration/do_configure.expect new file mode 100755 index 000000000..7d9333c37 --- /dev/null +++ b/tests/Fixtures/e2e/Initial_Configuration/do_configure.expect @@ -0,0 +1,22 @@ +#!/usr/bin/env expect +set timeout 20 +eval spawn $env(INFECTION) + +proc configure { input value } { + expect $input { + send $value + } timeout { + send_user "Test failed\n" + exit 1 + } +} + +configure "directories do you want to include" "2\r" +configure "Any directories to exclude from" "\r" +configure "timeout in seconds" "\r" +configure "text log file?" "\r" + +expect "Please note that some mutants will inevitably be harmless" + +send_user "Test succeeded!\n" +exit 0 diff --git a/tests/Fixtures/e2e/Initial_Configuration/expected.log b/tests/Fixtures/e2e/Initial_Configuration/expected.log new file mode 100644 index 000000000..6b0cea681 --- /dev/null +++ b/tests/Fixtures/e2e/Initial_Configuration/expected.log @@ -0,0 +1,8 @@ +Escaped mutants: +================ + +Timed Out mutants: +================== + +Not Covered mutants: +==================== diff --git a/tests/Fixtures/e2e/Initial_Configuration/phpunit.xml b/tests/Fixtures/e2e/Initial_Configuration/phpunit.xml new file mode 100644 index 000000000..9a836774d --- /dev/null +++ b/tests/Fixtures/e2e/Initial_Configuration/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./tests/ + + + + + + ./src/ + + + diff --git a/tests/Fixtures/e2e/Initial_Configuration/run_tests.bash b/tests/Fixtures/e2e/Initial_Configuration/run_tests.bash new file mode 100755 index 000000000..2eb99c408 --- /dev/null +++ b/tests/Fixtures/e2e/Initial_Configuration/run_tests.bash @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +if test ! -f "$(which expect)"; then + test -x $(which tput) && tput setaf 1 # red + echo "Please install expect; it is readily available from apt and brew" + exit 1; +fi + +cd $(dirname $0) +rm -f infection.json.dist infection.log + +set -e + +if [[ "$PHPDBG" = "1" ]] +then + INFECTION="phpdbg -qrr ../../../../bin/infection" +else + INFECTION="php ../../../../bin/infection" +fi +export INFECTION + +./do_configure.expect + +diff -u expected.log infection.log diff --git a/tests/Fixtures/e2e/Initial_Configuration/skipped_src/IgnoredSourceClass.php b/tests/Fixtures/e2e/Initial_Configuration/skipped_src/IgnoredSourceClass.php new file mode 100644 index 000000000..adbdd9230 --- /dev/null +++ b/tests/Fixtures/e2e/Initial_Configuration/skipped_src/IgnoredSourceClass.php @@ -0,0 +1,13 @@ +assertSame('hello', $sourceClass->hello()); + } +}