/**
  * @test
  */
 public function itShouldWorksFine()
 {
     $configurationDataResponse = ConfigurationDataResponseStub::createCustom(false, false, true);
     $this->shouldHandleQuery(new ConfigurationDataFinderQuery(), $configurationDataResponse);
     $this->shouldWriteLnOutput(PrePushTool::PRE_PUSH_HOOK);
     $this->shouldExecutePrePushOriginal($this->remote, $this->url, '');
     $this->shouldHandleCommand(new PhpUnitToolCommand($configurationDataResponse->getPrePush()->getPhpUnit()->isPhpunitRandomMode(), $configurationDataResponse->getPrePush()->getPhpUnit()->getPhpunitOptions(), $configurationDataResponse->getPrePush()->getErrorMessage()));
     $this->shouldHandleCommand(new StrictCoverageCommand($configurationDataResponse->getPrePush()->getPhpUnitStrictCoverage()->getMinimum(), $configurationDataResponse->getPrePush()->getErrorMessage()));
     $this->shouldHandleCommand(new GuardCoverageCommand($configurationDataResponse->getPreCommit()->getPhpUnitGuardCoverage()->getWarningMessage()));
     $this->shouldWriteLnOutput(GoodJobLogoResponse::paint($configurationDataResponse->getPrePush()->getRightMessage()));
     $this->prePushToolCommandHandler->handle(new PrePushToolCommand($this->remote, $this->url));
 }
Пример #2
0
 public function execute()
 {
     $this->tittleOutputWriter->writeTitle(self::TITLE);
     $committedFiles = $this->filesCommittedExtractor->getFiles();
     if (1 === count($committedFiles)) {
         $this->output->writeln(static::NO_FILES_CHANGED_MESSAGE);
         return;
     }
     /** @var ConfigurationDataResponse $configurationData */
     $configurationData = $this->queryBus->handle(new ConfigurationDataFinderQuery());
     $preCommit = $configurationData->getPreCommit();
     if (true === $preCommit->isPreCommit()) {
         $this->executeTools($preCommit, $committedFiles);
     }
     $this->output->writeln(GoodJobLogoResponse::paint($preCommit->getRightMessage()));
 }
 /**
  * @test
  */
 public function itShouldExecuteAllTools()
 {
     $files = FilesCommittedStub::createAllFiles();
     $configurationDataResponse = ConfigurationDataResponseStub::createAllEnabled();
     $this->shouldWriteTitle(PreCommitTool::TITLE, 'title');
     $this->shouldGetFilesCommitted($files);
     $this->shouldHandleQuery(new ConfigurationDataFinderQuery(), $configurationDataResponse);
     $this->shouldHandleCommand(new ComposerToolCommand($files, $configurationDataResponse->getPreCommit()->getErrorMessage()));
     $this->shouldHandleCommand(new JsonLintToolCommand($files, $configurationDataResponse->getPreCommit()->getErrorMessage()));
     $this->shouldHandleQuery(new PhpFilesExtractorQuery($files), PhpFilesResponseStub::create(FilesCommittedStub::createWithoutPhpFiles()));
     $this->shouldHandleCommand(new PhpLintToolCommand($files, $configurationDataResponse->getPreCommit()->getErrorMessage()));
     $this->shouldHandleCommand(new PhpCsToolCommand($files, $configurationDataResponse->getPreCommit()->getPhpCs()->getPhpCsStandard(), HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT));
     $this->shouldHandleCommand(new PhpCsFixerToolCommand($files, $configurationDataResponse->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr0(), $configurationDataResponse->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr1(), $configurationDataResponse->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr2(), $configurationDataResponse->getPreCommit()->getPhpCsFixer()->isPhpCsFixerSymfony(), $configurationDataResponse->getPreCommit()->getPhpCsFixer()->getPhpCsFixerOptions(), $configurationDataResponse->getPreCommit()->getErrorMessage()));
     $this->shouldHandleCommand(new PhpMdToolCommand($files, $configurationDataResponse->getPreCommit()->getPhpMd()->getPhpMdOptions(), $configurationDataResponse->getPreCommit()->getErrorMessage()));
     $this->shouldHandleCommand(new PhpUnitToolCommand($configurationDataResponse->getPreCommit()->getPhpUnit()->isPhpunitRandomMode(), $configurationDataResponse->getPreCommit()->getPhpUnit()->getPhpunitOptions(), $configurationDataResponse->getPreCommit()->getErrorMessage()));
     $this->shouldHandleCommand(new StrictCoverageCommand($configurationDataResponse->getPreCommit()->getPhpUnitStrictCoverage()->getMinimum(), $configurationDataResponse->getPreCommit()->getErrorMessage()));
     $this->shouldHandleCommand(new GuardCoverageCommand($configurationDataResponse->getPreCommit()->getPhpUnitGuardCoverage()->getWarningMessage()));
     $this->shouldWriteLnOutput(GoodJobLogoResponse::paint($configurationDataResponse->getPreCommit()->getRightMessage()));
     $this->preCommitToolCommandHandler->handle(new PreCommitToolCommand());
 }
Пример #4
0
 /**
  * @param string $remote
  * @param string $url
  *
  * @throws InvalidPushException
  */
 public function execute($remote, $url)
 {
     /** @var ConfigurationDataResponse $configurationData */
     $configurationData = $this->queryBus->handle(new ConfigurationDataFinderQuery());
     $prePushResponse = $configurationData->getPrePush();
     if (true === $prePushResponse->isPrePush()) {
         $this->output->writeln(self::PRE_PUSH_HOOK);
         $this->executeOriginalHook($remote, $url, $prePushResponse->getErrorMessage());
         $phpunitResponse = $prePushResponse->getPhpUnit();
         if (true === $phpunitResponse->isPhpunit()) {
             $this->commandBus->handle(new PhpUnitToolCommand($phpunitResponse->isPhpunitRandomMode(), $phpunitResponse->getPhpunitOptions(), $prePushResponse->getErrorMessage()));
             $phpunitStrictCoverageResponse = $prePushResponse->getPhpUnitStrictCoverage();
             if (true === $phpunitStrictCoverageResponse->isPhpunitStrictCoverage()) {
                 $this->commandBus->handle(new StrictCoverageCommand($phpunitStrictCoverageResponse->getMinimum(), $prePushResponse->getErrorMessage()));
             }
             $phpunitGuardCoverageResponse = $prePushResponse->getPhpUnitGuardCoverage();
             if (true === $phpunitGuardCoverageResponse->isEnabled()) {
                 $this->commandBus->handle(new GuardCoverageCommand($phpunitGuardCoverageResponse->getWarningMessage()));
             }
         }
         $this->output->writeln(GoodJobLogoResponse::paint($prePushResponse->getRightMessage()));
     }
 }