5use PHPUnit\Framework\Assert;
45 while ( $this->xml->read() ) {
46 if ( $this->xml->nodeType == XMLReader::END_ELEMENT &&
47 $this->xml->name ==
$name
68 "Skipping to end of $name" );
69 while ( $this->xml->read() ) {
70 if ( $this->xml->nodeType == XMLReader::ELEMENT ) {
86 $this->xml =
new XMLReader();
88 Assert::assertTrue( $this->xml->open(
$fname ),
89 "Opening temporary file $fname via XMLReader failed" );
90 if ( $skip_siteinfo ) {
92 "Skipping past end of siteinfo" );
105 if ( $this->xml->read() ) {
108 Assert::assertEquals( $this->xml->nodeType, XMLReader::NONE,
109 "No proper entity left to parse" );
118 while ( $cont && ( ( $this->xml->nodeType == XMLReader::WHITESPACE )
119 || ( $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE ) ) ) {
120 $cont = $this->xml->read();
133 Assert::assertEquals(
$name, $this->xml->name,
"Node name" );
134 Assert::assertEquals( XMLReader::ELEMENT, $this->xml->nodeType,
"Node type" );
136 Assert::assertTrue( $this->xml->read(),
"Skipping past start tag" );
149 Assert::assertEquals(
$name, $this->xml->name,
"Node name" );
150 Assert::assertEquals( XMLReader::END_ELEMENT, $this->xml->nodeType,
"Node type" );
152 Assert::assertTrue( $this->xml->read(),
"Skipping past end tag" );
170 if ( $text !==
false ) {
171 Assert::assertEquals( $text, $this->xml->value,
"Text of node " .
$name );
173 Assert::assertTrue( $this->xml->read(),
"Skipping past processed text of " .
$name );
227 $text_sha1, $text =
false, $parentid =
false,
234 if ( $parentid !==
false ) {
255 if ( $this->xml->name ==
"text" ) {
258 $this->
assertText( $id, $text_id, $text_bytes, $text );
265 if ( !$text_found ) {
266 $this->
assertText( $id, $text_id, $text_bytes, $text );
273 public function assertText( $id, $text_id, $text_bytes, $text ) {
275 if ( $text_bytes !==
false ) {
276 Assert::assertEquals( $this->xml->getAttribute(
"bytes" ), $text_bytes,
277 "Attribute 'bytes' of revision " . $id );
280 if ( $text ===
false ) {
282 Assert::assertEquals( $this->xml->getAttribute(
"id" ), $text_id,
283 "Text id of revision " . $id );
284 Assert::assertFalse( $this->xml->hasValue,
"Revision has text" );
285 Assert::assertTrue( $this->xml->read(),
"Skipping text start tag" );
286 if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
287 && ( $this->xml->name ==
"text" )
294 Assert::assertTrue( $this->xml->read(),
"Skipping text start tag" );
295 Assert::assertEquals( $text, $this->xml->value,
"Text of revision " . $id );
296 Assert::assertTrue( $this->xml->read(),
"Skipping past text" );
316 $subtype, $title, $parameters = []
331 if ( $comment !==
null ) {
339 $parameters_xml =
unserialize( $this->xml->value );
340 Assert::assertEquals( $parameters, $parameters_xml );
341 Assert::assertTrue( $this->xml->read(),
"Skipping past processed text of params" );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
unserialize( $serialized)
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Helper for asserting the structure of an XML dump stream.
assertLogItem( $id, $user_name, $user_id, $comment, $type, $subtype, $title, $parameters=[])
asserts that the xml reader is at the beginning of a log entry and skips over it while analyzing it.
assertNodeEnd( $name, $skip=true)
Asserts that the xml reader is at an closing element of given name, and optionally skips past it.
skipWhitespace()
Steps the xml reader over white space.
XMLReader null $xml
Holds the XMLReader used for analyzing an XML dump.
skipPastNodeEnd( $name)
Step the current XML reader to the first element start after the node end of a given name.
assertPageStart( $id, $ns, $name)
Asserts that the xml reader is at the start of a page element and skips over the first tags,...
assertDumpEnd( $name="mediawiki")
Asserts that the xml reader is at the final closing tag of an xml file and closes the reader.
assertText( $id, $text_id, $text_bytes, $text)
assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text=false, $parentid=false, $model=CONTENT_MODEL_WIKITEXT, $format=CONTENT_FORMAT_WIKITEXT)
Asserts that the xml reader is at a revision and checks its representation before skipping over it.
assertDumpStart( $fname, $skip_siteinfo=true)
Opens an XML file to analyze and optionally skips past siteinfo.
skipToNodeEnd( $name)
Step the current XML reader until node end of given name is found.
string $schemaVersion
XML dump schema version.
assertPageEnd()
Asserts that the xml reader is at the page's closing element and skips to the next element.
assertNodeStart( $name, $skip=true)
Asserts that the xml reader is at an element of given name, and optionally skips past it.
__construct( $schemaVersion)
DumpAsserts constructor.
assertTextNode( $name, $text, $skip_ws=true)
Asserts that the xml reader is at an element of given tag that contains a given text,...
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT
namespace and then decline to actually register it file or subcat img or subcat $title
Allows to change the fields on the form that will be generated $name
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