/** * @test */ public function itShouldWorksFine() { $phpCsFixerOptions = PhpCsFixerOptionsStub::random(); $configurationData = ConfigurationDataResponseStub::createAllEnabled(); $phpFiles = FilesCommittedStub::createOnlyPhpFiles(); $outputMessagePsr0 = new PreCommitOutputWriter('Checking psr0 code style with PHP-CS-FIXER'); $this->shouldWriteOutput($outputMessagePsr0->getMessage()); foreach ($phpFiles as $file) { $this->shouldProcessPhpCsFixerTool($file, 'psr0', $phpCsFixerOptions->value(), null); } $this->shouldWriteLnOutput($outputMessagePsr0->getSuccessfulMessage()); $outputMessagePsr1 = new PreCommitOutputWriter('Checking psr1 code style with PHP-CS-FIXER'); $this->shouldWriteOutput($outputMessagePsr1->getMessage()); foreach ($phpFiles as $file) { $this->shouldProcessPhpCsFixerTool($file, 'psr1', $phpCsFixerOptions->value(), null); } $this->shouldWriteLnOutput($outputMessagePsr1->getSuccessfulMessage()); $outputMessagePsr2 = new PreCommitOutputWriter('Checking psr2 code style with PHP-CS-FIXER'); $this->shouldWriteOutput($outputMessagePsr2->getMessage()); foreach ($phpFiles as $file) { $this->shouldProcessPhpCsFixerTool($file, 'psr2', $phpCsFixerOptions->value(), null); } $this->shouldWriteLnOutput($outputMessagePsr2->getSuccessfulMessage()); $outputMessageSymfony = new PreCommitOutputWriter('Checking symfony code style with PHP-CS-FIXER'); $this->shouldWriteOutput($outputMessageSymfony->getMessage()); foreach ($phpFiles as $file) { $this->shouldProcessPhpCsFixerTool($file, 'symfony', $phpCsFixerOptions->value(), null); } $this->shouldWriteLnOutput($outputMessageSymfony->getSuccessfulMessage()); $this->phpCsFixerToolCommandHandler->handle(new PhpCsFixerToolCommand($phpFiles, $configurationData->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr0(), $configurationData->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr1(), $configurationData->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr2(), $configurationData->getPreCommit()->getPhpCsFixer()->isPhpCsFixerSymfony(), $phpCsFixerOptions->value(), $configurationData->getPreCommit()->getErrorMessage())); }
/** * @test */ public function itShouldWorksFine() { $output = new PreCommitOutputWriter(PhpCsTool::EXECUTE_MESSAGE); $files = FilesCommittedStub::createOnlyPhpFiles(); $this->shouldWriteOutput($output->getMessage()); foreach ($files as $file) { $this->shouldProcessPhpCsTool($file, 'PSR2', null); } $this->shouldWriteLnOutput($output->getSuccessfulMessage()); $this->phpCsToolCommandHandler->handle(new PhpCsToolCommand($files, 'PSR2', HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT)); }
/** * @test */ public function itShouldWorksFine() { $phpFiles = FilesCommittedStub::createOnlyPhpFiles(); $outputMessage = new PreCommitOutputWriter(PhpLintTool::RUNNING_PHPLINT); $this->shouldWriteOutput($outputMessage->getMessage()); foreach ($phpFiles as $file) { $this->shouldProcessPhpLintTool($file, null); } $this->shouldWriteLnOutput($outputMessage->getSuccessfulMessage()); $this->phpLintToolCommandHandler->handle(new PhpLintToolCommand($phpFiles, HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT)); }
/** * @test */ public function itShouldWorksFine() { $phpMdOptions = PhpMdOptionsStub::random(); $errorMessage = HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT; $phpFiles = FilesCommittedStub::createOnlyPhpFiles(); $outputMessage = new PreCommitOutputWriter(PhpMdTool::CHECKING_MESSAGE); $this->shouldWriteOutput($outputMessage->getMessage()); foreach ($phpFiles as $phpFile) { $this->shouldProcessPhpMdTool($phpFile, $phpMdOptions->value(), null); } $this->shouldWriteLnOutput($outputMessage->getSuccessfulMessage()); $command = new PhpMdToolCommand($phpFiles, $phpMdOptions->value(), $errorMessage); $this->phpMdToolCommandHandler->handle($command); }