"; const MAL_FORMED_XML = ""; // @codingStandardsIgnoreStart Generic.Files.LineLength const XML_WITH_PIH = ''; // @codingStandardsIgnoreEnd /** * @covers XMLTypeCheck::newFromString * @covers XMLTypeCheck::getRootElement */ public function testWellFormedXML() { $testXML = XmlTypeCheck::newFromString( self::WELL_FORMED_XML ); $this->assertTrue( $testXML->wellFormed ); $this->assertEquals( 'root', $testXML->getRootElement() ); } /** * @covers XMLTypeCheck::newFromString */ public function testMalFormedXML() { $testXML = XmlTypeCheck::newFromString( self::MAL_FORMED_XML ); $this->assertFalse( $testXML->wellFormed ); } /** * Verify we check for recursive entity DOS * * (If the DOS isn't properly handled, the test runner will probably go OOM...) */ public function testRecursiveEntity() { $xml = <<<'XML' ]> &test; XML; $check = XmlTypeCheck::newFromString( $xml ); $this->assertFalse( $check->wellFormed ); } /** * @covers XMLTypeCheck::processingInstructionHandler */ public function testProcessingInstructionHandler() { $called = false; $testXML = new XmlTypeCheck( self::XML_WITH_PIH, null, false, [ 'processing_instruction_handler' => function () use ( &$called ) { $called = true; } ] ); $this->assertTrue( $called ); } }