3 * PHPUnit tests for XMLTypeCheck.
8 class XmlTypeCheckTest
extends PHPUnit_Framework_TestCase
{
9 const WELL_FORMED_XML
= "<root><child /></root>";
10 const MAL_FORMED_XML
= "<root><child /></error>";
11 // @codingStandardsIgnoreStart Generic.Files.LineLength
12 const XML_WITH_PIH
= '<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/w/index.php"?><svg><child /></svg>';
13 // @codingStandardsIgnoreEnd
16 * @covers XMLTypeCheck::newFromString
17 * @covers XMLTypeCheck::getRootElement
19 public function testWellFormedXML() {
20 $testXML = XmlTypeCheck
::newFromString( self
::WELL_FORMED_XML
);
21 $this->assertTrue( $testXML->wellFormed
);
22 $this->assertEquals( 'root', $testXML->getRootElement() );
26 * @covers XMLTypeCheck::newFromString
28 public function testMalFormedXML() {
29 $testXML = XmlTypeCheck
::newFromString( self
::MAL_FORMED_XML
);
30 $this->assertFalse( $testXML->wellFormed
);
34 * @covers XMLTypeCheck::processingInstructionHandler
36 public function testProcessingInstructionHandler() {
38 $testXML = new XmlTypeCheck(
43 'processing_instruction_handler' => function() use ( &$called ) {
48 $this->assertTrue( $called );