/** * @test */ public function itShouldReturnEnabledConfig() { $data = ConfigArrayDataStub::hooksEnabledWithEnabledTools(); $config = ConfigFactory::fromArray($data); $this->assertFalse($config->getPreCommit()->isUndefined()); $this->assertTrue($config->getPreCommit()->isEnabled()); $this->assertFalse($config->getCommitMsg()->isUndefined()); $this->assertTrue($config->getCommitMsg()->isEnabled()); }
/** * @test */ public function itShouldMakeAllQuestions() { $yes = 'y'; $gitIgnoreDataResponse = GitIgnoreDataResponseStub::random(); $this->shouldReadConfigurationData(ConfigStub::createUndefined()); $this->shouldAsk(HookQuestions::PRE_COMMIT_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PRE_COMMIT_RIGHT_MESSAGE, HookQuestions::PRE_COMMIT_RIGHT_MESSAGE_DEFAULT, ConfigArrayDataStub::RIGHT_MESSAGE); $this->shouldAsk(HookQuestions::PRE_COMMIT_ERROR_MESSAGE, HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT, ConfigArrayDataStub::ERROR_MESSAGE); $this->shouldAsk(HookQuestions::COMPOSER_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::JSONLINT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPLINT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPMD_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPMD_OPTIONS, null, ConfigArrayDataStub::PHPMD_OPTIONS); $this->shouldAsk(HookQuestions::PHPCS_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPCS_STANDARD, null, ConfigArrayDataStub::PHPCS_STANDARD); $this->shouldAsk(HookQuestions::PHPCSFIXER_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPCSFIXER_PSR0_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPCSFIXER_PSR1_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPCSFIXER_PSR2_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPCSFIXER_SYMFONY_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPCSFIXER_OPTIONS, null, ConfigArrayDataStub::PHPCSFIXER_OPTIONS); $this->shouldAsk(HookQuestions::PHPUNIT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPUNIT_RANDOM_MODE, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPUNIT_OPTIONS, null, ConfigArrayDataStub::PHPUNIT_OPTIONS); $this->shouldAsk(HookQuestions::PHPUNIT_STRICT_COVERAGE, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPUNIT_STRICT_COVERAGE_MINIMUM, 0.0, ConfigArrayDataStub::MINIMUM_COVERAGE); $this->shouldAsk(HookQuestions::PHPUNIT_GUARD_COVERAGE, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPUNIT_GUARD_COVERAGE_MESSAGE, HookQuestions::PHPUNIT_GUARD_COVERAGE_MESSAGE_DEFAULT, ConfigArrayDataStub::ERROR_MESSAGE); $this->shouldHandleQuery(new GitIgnoreExtractorQuery(), $gitIgnoreDataResponse); $this->shouldHandleCommand(new GitIgnoreWriterCommand($gitIgnoreDataResponse->getContent())); $this->shouldAsk(HookQuestions::COMMIT_MSG_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldCopyPreCommitHook(); $this->shouldAsk(HookQuestions::COMMIT_MSG_REGULAR_EXPRESSION, HookQuestions::COMMIT_MSG_REGULAR_EXPRESSION_ANSWER, ConfigArrayDataStub::REGULAR_EXPRESSION); $this->shouldCopyCommitMsgHook(); $this->shouldAsk(HookQuestions::PRE_PUSH_HOOK_QUESTION, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PRE_PUSH_RIGHT_MESSAGE, HookQuestions::PRE_PUSH_RIGHT_MESSAGE_DEFAULT, HookQuestions::PRE_PUSH_RIGHT_MESSAGE_DEFAULT); $this->shouldAsk(HookQuestions::PRE_PUSH_ERROR_MESSAGE, HookQuestions::PRE_PUSH_ERROR_MESSAGE_DEFAULT, HookQuestions::PRE_PUSH_ERROR_MESSAGE_DEFAULT); $this->shouldAsk(HookQuestions::PHPUNIT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPUNIT_RANDOM_MODE, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPUNIT_OPTIONS, null, ConfigArrayDataStub::PHPUNIT_OPTIONS); $this->shouldAsk(HookQuestions::PHPUNIT_STRICT_COVERAGE, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPUNIT_STRICT_COVERAGE_MINIMUM, 0.0, ConfigArrayDataStub::MINIMUM_COVERAGE); $this->shouldAsk(HookQuestions::PHPUNIT_GUARD_COVERAGE, HookQuestions::DEFAULT_TOOL_ANSWER, $yes); $this->shouldAsk(HookQuestions::PHPUNIT_GUARD_COVERAGE_MESSAGE, HookQuestions::PHPUNIT_GUARD_COVERAGE_MESSAGE_DEFAULT, ConfigArrayDataStub::ERROR_MESSAGE); $this->shouldHandleQuery(new GitIgnoreExtractorQuery(), GitIgnoreDataResponseStub::randomWithGuardCoverage()); $this->shouldCopyPrePushHook(); $this->shouldWriteConfigurationData(ConfigArrayDataStub::hooksEnabledWithEnabledTools()); $command = new ConfigurationProcessorCommand($this->getIOInterface()); $this->configurationProcessorCommandHandler->handle($command); }