Merge "PostgreSQL: Fix text search on moved pages"
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / XmlTypeCheckTest.php
1 <?php
2 /**
3 * PHPUnit tests for XMLTypeCheck.
4 * @author physikerwelt
5 * @group Xml
6 * @covers XMLTypeCheck
7 */
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>';
12
13 /**
14 * @covers XMLTypeCheck::newFromString
15 * @covers XMLTypeCheck::getRootElement
16 */
17 public function testWellFormedXML() {
18 $testXML = XmlTypeCheck::newFromString( self::WELL_FORMED_XML );
19 $this->assertTrue( $testXML->wellFormed );
20 $this->assertEquals( 'root', $testXML->getRootElement() );
21 }
22
23 /**
24 * @covers XMLTypeCheck::newFromString
25 */
26 public function testMalFormedXML() {
27 $testXML = XmlTypeCheck::newFromString( self::MAL_FORMED_XML );
28 $this->assertFalse( $testXML->wellFormed );
29 }
30
31 /**
32 * @covers XMLTypeCheck::processingInstructionHandler
33 */
34 public function testProcessingInstructionHandler() {
35 $called = false;
36 $testXML = new XmlTypeCheck(
37 self::XML_WITH_PIH,
38 null,
39 false,
40 array(
41 'processing_instruction_handler' => function() use ( &$called ) {
42 $called = true;
43 }
44 )
45 );
46 $this->assertTrue( $called );
47 }
48
49 }