public function testParseWarningMessage()
 {
     $outputDom = new \DOMDocument();
     $outputDom->loadXML($this->getFixture('warning-message.xml'));
     $messageElement = $outputDom->getElementsByTagName('message')->item(0);
     $parser = new Parser();
     $parser->setMessageElement($messageElement);
     /* @var $message \webignition\CssValidatorOutput\Message\Warning */
     $message = $parser->getMessage();
     $this->assertInstanceOf('webignition\\CssValidatorOutput\\Message\\Warning', $message);
     $this->assertEquals("You should add a 'type' attribute with a value of 'text/css' to the 'link' element", $message->getMessage());
     $this->assertEquals('', $message->getContext());
     $this->assertEquals(5, $message->getLineNumber());
     $this->assertTrue($message->isWarning());
     $this->assertEquals(0, $message->getLevel());
     $this->assertEquals('http://example.com/', $message->getRef());
 }
 private function parse()
 {
     $headerBodyParts = explode("\n", $this->getConfiguration()->getRawOutput(), 2);
     $header = trim($headerBodyParts[0]);
     $body = trim($headerBodyParts[1]);
     if (ExceptionOutputParser::is($body)) {
         $exceptionOutputParser = new ExceptionOutputParser();
         $exceptionOutputParser->setRawOutput($body);
         $this->output->setException($exceptionOutputParser->getOutput());
         return;
     }
     if ($this->isIncorrectUsageOutput($header)) {
         $this->output->setIsIncorrectUsageOutput(true);
         return;
     }
     $this->rawHeader = $header;
     $this->rawBody = $body;
     $optionsParser = new OptionsParser();
     $optionsParser->setOptionsOutput($header);
     $messageParser = new MessageParser();
     $this->output->setOptions($optionsParser->getOptions());
     $bodyDom = new \DOMDocument();
     $bodyDom->loadXML($this->extractXmlContentFromBody($body));
     $container = $bodyDom->getElementsByTagName('observationresponse')->item(0);
     if ($this->isPassedNoMessagesOutput($container)) {
         return;
     }
     $this->output->setSourceUrl($container->getAttribute('ref'));
     $this->output->setDateTime(new \DateTime($container->getAttribute('date')));
     $messageElements = $container->getElementsByTagName('message');
     foreach ($messageElements as $messageElement) {
         /* @var $messageElement \DomElement */
         $messageParser->setMessageElement($messageElement);
         /* @var $message \webignition\CssValidatorOutput\Message\Message */
         $message = $messageParser->getMessage();
         if ($this->getConfiguration()->getReportVendorExtensionIssuesAsWarnings() && $message->isError() && $this->isVendorExtensionMessage($message)) {
             $message = \webignition\CssValidatorOutput\Message\Warning::fromError($message);
         }
         if ($message->isWarning() && $this->getConfiguration()->getIgnoreWarnings() === true) {
             continue;
         }
         if ($this->hasRefDomainToIgnore($message)) {
             continue;
         }
         if ($this->getConfiguration()->getIgnoreVendorExtensionIssues() === true && $this->isVendorExtensionMessage($message)) {
             continue;
         }
         if ($this->getConfiguration()->getIgnoreFalseImageDataUrlMessages() && $this->isFalseImageDataUrlMessage($message)) {
             continue;
         }
         $this->output->addMessage($message);
     }
 }