public function itShouldThrowsException()
{
$this->expectException(PhpMdViolationsException::class);
$phpMdOptions = PhpMdOptionsStub::random();
$errorMessage = HookQuestions::PRE_COMMIT_ERROR_MESSAGE_DEFAULT;
$phpFiles = FilesCommittedStub::createOnlyPhpFiles();
$outputMessage = new PreCommitOutputWriter(PhpMdTool::CHECKING_MESSAGE);
$this->shouldWriteOutput($outputMessage->getMessage());
$errorsText = null;
foreach ($phpFiles as $phpFile) {
$error = 'ERROR';
$this->shouldProcessPhpMdTool($phpFile, $phpMdOptions->value(), $error);
$errorsText .= $error;
}
$this->shouldWriteLnOutput($outputMessage->getFailMessage());
$this->shouldWriteLnOutput($outputMessage->setError($errorsText));
$this->shouldWriteLnOutput(BadJobLogoResponse::paint($errorMessage));
$command = new PhpMdToolCommand($phpFiles, $phpMdOptions->value(), $errorMessage);
$this->phpMdToolCommandHandler->handle($command);
}