Example #1
0
 /**
  * Ensure population of warnings
  *
  * @covers HtmlValidator\Response::__construct
  * @covers HtmlValidator\Response::validateResponse
  * @covers HtmlValidator\Response::parse
  * @covers HtmlValidator\Response::getWarnings
  * @covers HtmlValidator\Response::hasWarnings
  */
 public function testWillPopulateWarnings()
 {
     $data = array('messages' => array(array('type' => 'warning', 'firstLine' => 1, 'lastLine' => 2, 'firstColumn' => 3, 'lastColumn' => 4, 'hiliteStart' => 5, 'hiliteLength' => 6, 'message' => 'Foobar', 'extract' => '<strong>Foo</strong>'), array('type' => 'warning', '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);
     $warnings = $response->getWarnings();
     $this->assertTrue($response->hasWarnings());
     $this->assertSame(2, count($warnings));
     $this->assertSame($data['messages'][0]['message'], $warnings[0]->getText());
     $this->assertSame($data['messages'][1]['message'], $warnings[1]->getText());
 }