MediaWiki  1.29.1
XmlTypeCheckTest.php
Go to the documentation of this file.
1 <?php
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
14 
19  public function testWellFormedXML() {
20  $testXML = XmlTypeCheck::newFromString( self::WELL_FORMED_XML );
21  $this->assertTrue( $testXML->wellFormed );
22  $this->assertEquals( 'root', $testXML->getRootElement() );
23  }
24 
28  public function testMalFormedXML() {
29  $testXML = XmlTypeCheck::newFromString( self::MAL_FORMED_XML );
30  $this->assertFalse( $testXML->wellFormed );
31  }
32 
38  public function testRecursiveEntity() {
39  $xml = <<<'XML'
40 <?xml version="1.0" encoding="utf-8"?>
41 <!DOCTYPE foo [
42  <!ENTITY test "&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;">
43  <!ENTITY a "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;">
44  <!ENTITY b "&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;">
45  <!ENTITY c "&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;">
46  <!ENTITY d "&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;">
47  <!ENTITY e "&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;">
48  <!ENTITY f "&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;">
49  <!ENTITY g "-00000000000000000000000000000000000000000000000000000000000000000000000-">
50 ]>
51 <foo>
52 <bar>&test;</bar>
53 </foo>
54 XML;
55  $check = XmlTypeCheck::newFromString( $xml );
56  $this->assertFalse( $check->wellFormed );
57  }
58 
62  public function testProcessingInstructionHandler() {
63  $called = false;
64  $testXML = new XmlTypeCheck(
65  self::XML_WITH_PIH,
66  null,
67  false,
68  [
69  'processing_instruction_handler' => function() use ( &$called ) {
70  $called = true;
71  }
72  ]
73  );
74  $this->assertTrue( $called );
75  }
76 
77 }
version
Prior to version
Definition: maintenance.txt:1
XmlTypeCheck\newFromString
static newFromString( $string, $filterCallback=null)
Alternative constructor: from string.
Definition: XmlTypeCheck.php:139
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
a
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
Definition: parserTests.txt:89
e
in this case you re responsible for computing and outputting the entire conflict i e
Definition: hooks.txt:1398
XmlTypeCheck
Definition: XmlTypeCheck.php:28
c
type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of the commands you use may be called something other than show w and show c
Definition: COPYING.txt:321