/**
  * @covers W3C\Formatter\Checkstyle::addViolation
  */
 public function testAddsViolation()
 {
     $xml = new SimpleXMLElement('<root />');
     $violation = new Violation();
     $violation->setLine(5)->setColumn(9)->setMessage('My message')->setSource('My Source')->setExplanation('My Explanation');
     $method = new ReflectionMethod('W3C\\Formatter\\Checkstyle', 'addViolation');
     $method->setAccessible(true);
     $method->invoke($this->formatter, $xml, $violation, 'my-severity');
     $this->assertXmlStringEqualsXmlString('<root><error severity="my-severity" line="5" column="9" message="My message" source="HTMLValidation"/></root>', $xml->asXML());
 }
    /**
     * @covers W3C\HtmlValidator::getEntry
     */
    public function testGetEntry()
    {
        $method = new ReflectionMethod('W3C\\HtmlValidator', 'getEntry');
        $method->setAccessible(true);
        $xmlString = <<<'XML'
<warning>
    <line>3</line>
    <col>9</col>
    <message>My Message</message>
    <messageid>my-id</messageid>
    <explanation>Some info</explanation>
    <source>Unknown</source>
</warning>
XML;
        $xml = new SimpleXMLElement($xmlString);
        $violation = new Violation();
        $violation->setLine(3)->setColumn(9)->setMessage('My Message')->setExplanation('Some info')->setSource('Unknown');
        $this->assertEquals($violation, $method->invoke($this->validator, $xml));
    }
 /**
  * Create a violation object from the provided xml.
  *
  * @param SimpleXMLElement $xml XML element which contains the violation details
  * @return Violation
  */
 protected function getEntry(SimpleXMLElement $xml)
 {
     $entry = new Violation();
     $entry->setLine($xml->line)->setColumn($xml->col)->setMessage($xml->message)->setExplanation($xml->explanation)->setSource($xml->source);
     return $entry;
 }