/** * @test */ public function itShouldReturnJsonFilesResponse() { $files = FilesCommittedStub::createAllFiles(); $jsonFilesExtractorQueryHandler = new JsonFilesExtractorQueryHandler(new JsonFilesExtractor()); $jsonFilesResponse = $jsonFilesExtractorQueryHandler->handle(new JsonFilesExtractorQuery($files)); $this->assertInstanceOf(JsonFilesResponse::class, $jsonFilesResponse); $this->assertSame(1, count($jsonFilesResponse->getFiles())); }
/** * @test */ public function itShouldReturnArrayComposerFilesResponse() { $files = FilesCommittedStub::createAllFiles(); $composerFilesExtractorQueryHandler = new ComposerFilesExtractorQueryHandler(new ComposerFilesExtractor()); $composerFilesResponse = $composerFilesExtractorQueryHandler->handle(new ComposerFilesExtractorQuery($files)); $this->assertTrue($composerFilesResponse->isJsonFile()); $this->assertTrue($composerFilesResponse->isLockFile()); }
/** * @test */ public function itShouldWorksFine() { $files = FilesCommittedStub::createAllFiles(); $output = new PreCommitOutputWriter(ComposerTool::CHECKING_MESSAGE); $this->shouldWriteOutput($output->getMessage()); $this->shouldHandleQuery(new ComposerFilesExtractorQuery($files), ComposerFilesResponseStub::createValidData()); $this->shouldWriteLnOutput($output->getSuccessfulMessage()); $this->composerToolCommandHandler->handle(new ComposerToolCommand($files, $this->errorMessage)); }
/** * @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()); }
/** * @test */ public function itShouldReturnArrayPhpFilesResponse() { $files = $this->phpFilesExtractorQueryHandler->handle(new PhpFilesExtractorQuery(FilesCommittedStub::createAllFiles())); $this->assertInstanceOf(PhpFilesResponse::class, $files); $this->assertSame(5, count($files->getFiles())); }