/** * Test CODE_PHP_DOC_MISSED */ public function testSimplePhpDocBlockMissed() { $errorCollector = new Processor\ErrorCollector(); $validator = new PhpDoc(['errorCollector' => $errorCollector]); $this->assertFalse($validator->validate($this->getTestFileContent(), static::$fileTest)); $errors = $this->getSpecificErrorsList(static::$fileTest, PhpDoc::CODE_PHP_DOC_MISSED, $errorCollector->getErrors()); $expected = ['const WRONG = 0; //PhpDoc is missed', 'protected $_paramB; //PhpDoc is missed', 'protected $_paramBB; //PhpDoc is missed', 'public function test1() //PhpDoc is missed', 'class Some_testClassPhpDoc extends stdClass //PhpDoc is missed']; $this->assertEquals($expected, $errors); }
/** * Test CODE_BAD_COMMIT_MESSAGE. Negative test */ public function testMessageFailure() { $message = new Message(); $message->body = 'My message.'; $message->head = 'My message.'; $errorCollector = new ErrorCollector(); $validator = new CommitMsg(['errorCollector' => $errorCollector]); $this->assertFalse($validator->validate($message, null)); $errors = $errorCollector->getErrors(); $this->assertCount(1, $errors); $errors = array_shift($errors); $this->assertArrayHasKey(CommitMsg::CODE_BAD_COMMIT_MESSAGE, $errors); $errors = array_shift($errors); $this->assertCount(1, $errors); }
/** * Add error * * @param string $file * @param string $code * @param string $value * @param int $line * @return $this */ protected function addError($file, $code, $value = null, $line = null) { $this->errorCollector->addError($file, $code, $this->errorMessages[$code], $value, $line); return $this; }
/** * Get errors * * @return array */ public function getErrors() { return $this->errorCollector->getErrors(); }