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 const XML_WITH_PIH
= '<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/w/index.php"?><svg><child /></svg>';
14 * @covers XMLTypeCheck::newFromString
15 * @covers XMLTypeCheck::getRootElement
17 public function testWellFormedXML() {
18 $testXML = XmlTypeCheck
::newFromString( self
::WELL_FORMED_XML
);
19 $this->assertTrue( $testXML->wellFormed
);
20 $this->assertEquals( 'root', $testXML->getRootElement() );
24 * @covers XMLTypeCheck::newFromString
26 public function testMalFormedXML() {
27 $testXML = XmlTypeCheck
::newFromString( self
::MAL_FORMED_XML
);
28 $this->assertFalse( $testXML->wellFormed
);
32 * @covers XMLTypeCheck::processingInstructionHandler
34 public function testProcessingInstructionHandler() {
36 $testXML = new XmlTypeCheck(
41 'processing_instruction_handler' => function() use ( &$called ) {
46 $this->assertTrue( $called );