Example #1
0
 public function testAddError()
 {
     $Response = new Response();
     foreach ($this->_any_errors as $eachField => $eachErrors) {
         $Response->addError($eachField, $eachErrors);
     }
     $this->assertSame($this->_any_errors, $Response->getErrors());
 }
Example #2
0
 /**
  * Ensure population of errors
  *
  * @covers HtmlValidator\Response::__construct
  * @covers HtmlValidator\Response::validateResponse
  * @covers HtmlValidator\Response::parse
  * @covers HtmlValidator\Response::getErrors
  * @covers HtmlValidator\Response::hasErrors
  */
 public function testWillPopulateErrors()
 {
     $data = ['messages' => [['type' => 'error', 'firstLine' => 1, 'lastLine' => 2, 'firstColumn' => 3, 'lastColumn' => 4, 'hiliteStart' => 5, 'hiliteLength' => 6, 'message' => 'Foobar', 'extract' => '<strong>Foo</strong>'], ['type' => 'error', 'firstLine' => 9, 'lastLine' => 8, 'firstColumn' => 7, 'lastColumn' => 6, 'hiliteStart' => 5, 'hiliteLength' => 4, 'message' => 'Pimp Pelican', 'extract' => '<em>Pelican</em>']]];
     $responseMock = $this->getGuzzleResponseMock(true);
     $responseMock->expects($this->any())->method('getBody')->will($this->returnValue(json_encode($data)));
     $response = new Response($responseMock);
     $errors = $response->getErrors();
     $this->assertTrue($response->hasErrors());
     $this->assertSame(2, count($errors));
     $this->assertSame($data['messages'][0]['message'], $errors[0]->getText());
     $this->assertSame($data['messages'][1]['message'], $errors[1]->getText());
 }