コード例 #1
0
 /**
  * @depends testAddWarnings
  * @covers W3C\Validation\Result::getWarningCount
  */
 public function testAddErrorsSetsWarningCount()
 {
     $this->assertEquals(0, $this->result->getWarningCount());
     $this->result->addWarning(new Violation());
     $this->assertEquals(1, $this->result->getWarningCount());
     $this->result->addWarning(new Violation());
     $this->assertEquals(2, $this->result->getWarningCount());
 }
コード例 #2
0
 /**
  * Validates the given markup
  *
  * @param  string $markup
  *
  * @return Result
  */
 public function validate($markup)
 {
     $result = new Result();
     $messages = $this->processor->execute($markup);
     foreach ($messages as $message) {
         if (Validator::MESSAGE_TYPE_ERROR === $message['type']) {
             $result->addError(new Error($message['line'], $message['column'], $message['message']));
         } else {
             if (Validator::MESSAGE_TYPE_WARNING === $message['type']) {
                 $result->addWarning(new Warning($message['line'], $message['column'], $message['message']));
             }
         }
     }
     return $result;
 }