/** * @test */ public function itShouldReturnEnabledTools() { $this->shouldReadConfigurationData(ConfigStub::create(PreCommitStub::createAllEnabled(), CommitMsgStub::createEnabled(), PrePushStub::createAllEnabled())); /** @var ConfigurationDataResponse $data */ $data = $this->configurationDataFinderQueryHandler->handle(new ConfigurationDataFinderQuery()); $this->assertTrue($data->getPreCommit()->isPreCommit()); $this->assertNotNull($data->getPreCommit()->getRightMessage()); $this->assertNotNull($data->getPreCommit()->getErrorMessage()); $this->assertTrue($data->getPreCommit()->isComposer()); $this->assertTrue($data->getPreCommit()->isJsonLint()); $this->assertTrue($data->getPreCommit()->isPhpLint()); $this->assertTrue($data->getPreCommit()->getPhpMd()->isPhpMd()); $this->assertTrue($data->getPreCommit()->getPhpCs()->isPhpCs()); $this->assertNotNull($data->getPreCommit()->getPhpCs()->getPhpCsStandard()); $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixer()); $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr0()); $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr1()); $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr2()); $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerSymfony()); $this->assertTrue($data->getPreCommit()->getPhpUnit()->isPhpunit()); $this->assertTrue($data->getPreCommit()->getPhpUnit()->isPhpunitRandomMode()); $this->assertTrue($data->getPreCommit()->getPhpUnitGuardCoverage()->isEnabled()); $this->assertNotNull($data->getPreCommit()->getPhpUnitGuardCoverage()->getWarningMessage()); $this->assertNotNull($data->getPreCommit()->getPhpUnit()->getPhpunitOptions()); $this->assertTrue($data->getCommitMsg()->isCommitMsg()); $this->assertNotNull($data->getPrePush()->getPhpUnitGuardCoverage()->getWarningMessage()); }
/** * @test */ public function itShouldDisablePreCommitHook() { $this->shouldAsk(HookQuestions::PRE_COMMIT_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER, 'n'); $preCommitData = $this->preCommitProcessor->process(PreCommitStub::createUndefined(), $this->io); $this->assertFalse($preCommitData->isEnabled()); $this->assertFalse($preCommitData->isUndefined()); $this->assertNull($preCommitData->getMessages()->getRightMessage()->value()); $this->assertNull($preCommitData->getMessages()->getErrorMessage()->value()); /** @var Execute $execute */ $execute = $preCommitData->getExecute(); $tools = $execute->execute(); $composer = $tools[0]; $jsonLint = $tools[1]; $phpLint = $tools[2]; /** @var PhpUnitStrictCoverage $phpunitStrictCoverage */ $phpunitStrictCoverage = $tools[7]; $this->assertFalse($composer->isEnabled()); $this->assertFalse($composer->isUndefined()); $this->assertFalse($jsonLint->isEnabled()); $this->assertFalse($jsonLint->isUndefined()); $this->assertFalse($phpLint->isEnabled()); $this->assertFalse($phpLint->isUndefined()); $this->assertFalse($phpunitStrictCoverage->isUndefined()); }
/** * @return Config */ public static function createEnabled() { return self::create(PreCommitStub::createAllEnabled(), CommitMsgStub::createEnabled(), PrePushStub::createAllEnabled()); }
/** * @test */ public function itShouldNotMakeAnyQuestions() { $data = ConfigurationArrayTransformer::transform(PreCommitStub::createAllEnabled(), CommitMsgStub::createEnabled(), PrePushStub::createAllEnabled()); $this->shouldReadConfigurationData(ConfigStub::createEnabled()); $this->shouldCopyPreCommitHook(); $this->shouldCopyCommitMsgHook(); $this->shouldCopyPrePushHook(); $this->shouldWriteConfigurationData($data); $command = new ConfigurationProcessorCommand($this->getIOInterface()); $this->configurationProcessorCommandHandler->handle($command); }