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