37 if ( self::$hasGzip === null ) {
41 if ( !self::$hasGzip ) {
42 $this->markTestSkipped(
"Skip test, requires the gzip utility in PATH" );
45 return self::$hasGzip;
67 $revision =
$value[
'revision'];
68 $revision_id = $revision->getId();
69 $text_id = $revision->getTextId();
71 if ( ( $revision_id > 0 ) && ( $text_id > 0 ) ) {
72 return [ $revision_id, $text_id ];
76 throw new MWException(
"Could not determine revision id ("
77 .
$status->getWikiText(
false,
false,
'en' ) .
")" );
87 $gzipped_contents = file_get_contents(
$fname );
88 if ( $gzipped_contents ===
false ) {
89 $this->fail(
"Could not get contents of $fname" );
92 $contents = gzdecode( $gzipped_contents );
96 file_put_contents(
$fname, $contents ),
111 if ( $this->exceptionFromAddDBData !== null ) {
129 $this->expectOutputRegex(
'//' );
132 $lines = explode(
"\n", $this->getActualOutput() );
133 $this->assertGreaterThan( 1, count(
$lines ),
"Minimal lines of produced output" );
134 $this->assertEquals(
'', array_pop(
$lines ),
"Output ends in LF" );
135 $timestamp_re =
"[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-6][0-9]";
138 "/$timestamp_re: .* \(ID [0-9]+\) [0-9]* pages .*, [0-9]* revs .*, ETA/",
153 while ( $this->xml->read() ) {
154 if ( $this->xml->nodeType == XMLReader::END_ELEMENT &&
155 $this->xml->name ==
$name
176 "Skipping to end of $name" );
177 while ( $this->xml->read() ) {
178 if ( $this->xml->nodeType == XMLReader::ELEMENT ) {
194 $this->xml =
new XMLReader();
195 $this->assertTrue( $this->xml->open(
$fname ),
196 "Opening temporary file $fname via XMLReader failed" );
197 if ( $skip_siteinfo ) {
199 "Skipping past end of siteinfo" );
212 if ( $this->xml->read() ) {
215 $this->assertEquals( $this->xml->nodeType, XMLReader::NONE,
216 "No proper entity left to parse" );
225 while ( $cont && ( ( $this->xml->nodeType == XMLReader::WHITESPACE )
226 || ( $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE ) ) ) {
227 $cont = $this->xml->read();
240 $this->assertEquals(
$name, $this->xml->name,
"Node name" );
241 $this->assertEquals( XMLReader::ELEMENT, $this->xml->nodeType,
"Node type" );
243 $this->assertTrue( $this->xml->read(),
"Skipping past start tag" );
256 $this->assertEquals(
$name, $this->xml->name,
"Node name" );
257 $this->assertEquals( XMLReader::END_ELEMENT, $this->xml->nodeType,
"Node type" );
259 $this->assertTrue( $this->xml->read(),
"Skipping past end tag" );
277 if ( $text !==
false ) {
278 $this->assertEquals( $text, $this->xml->value,
"Text of node " .
$name );
280 $this->assertTrue( $this->xml->read(),
"Skipping past processed text of " .
$name );
335 $text_sha1, $text =
false, $parentid =
false,
342 if ( $parentid !==
false ) {
362 if ( $this->xml->name ==
"text" ) {
365 $this->
assertText( $id, $text_id, $text_bytes, $text );
372 if ( !$text_found ) {
373 $this->
assertText( $id, $text_id, $text_bytes, $text );
380 protected function assertText( $id, $text_id, $text_bytes, $text ) {
382 if ( $text_bytes !==
false ) {
383 $this->assertEquals( $this->xml->getAttribute(
"bytes" ), $text_bytes,
384 "Attribute 'bytes' of revision " . $id );
387 if ( $text ===
false ) {
389 $this->assertEquals( $this->xml->getAttribute(
"id" ), $text_id,
390 "Text id of revision " . $id );
391 $this->assertFalse( $this->xml->hasValue,
"Revision has text" );
392 $this->assertTrue( $this->xml->read(),
"Skipping text start tag" );
393 if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
394 && ( $this->xml->name ==
"text" )
402 $this->assertTrue( $this->xml->read(),
"Skipping text start tag" );
403 $this->assertEquals( $text, $this->xml->value,
"Text of revision " . $id );
404 $this->assertTrue( $this->xml->read(),
"Skipping past text" );
const CONTENT_MODEL_WIKITEXT
assertText($id, $text_id, $text_bytes, $text)
processing should stop and the error should be shown to the user * false
assertDumpEnd($name="mediawiki")
Asserts that the xml reader is at the final closing tag of an xml file and closes the reader...
skipPastNodeEnd($name)
Step the current XML reader to the first element start after the node end of a given name...
static locateExecutableInDefaultPaths($names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
assertPageStart($id, $ns, $name)
Asserts that the xml reader is at the start of a page element and skips over the first tags...
XMLReader null $xml
Holds the XMLReader used for analyzing an XML dump.
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
addRevision(Page $page, $text, $summary, $model=CONTENT_MODEL_WIKITEXT)
Adds a revision to a page, while returning the resuting revision's id.
assertTextNode($name, $text, $skip_ws=true)
Asserts that the xml reader is at an element of given tag that contains a given text, and skips over the element.
setUp()
Default set up function.
Exception null $exceptionFromAddDBData
exception to be rethrown once in sound PHPUnit surrounding
gunzip($fname)
gunzips the given file and stores the result in the original file name
assertNodeEnd($name, $skip=true)
Asserts that the xml reader is at an closing element of given name, and optionally skips past it...
assertDumpStart($fname, $skip_siteinfo=true)
Opens an XML file to analyze and optionally skips past siteinfo.
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
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...
static bool null $hasGzip
Whether the 'gzip' utility is available.
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
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
assertNodeStart($name, $skip=true)
Asserts that the xml reader is at an element of given name, and optionally skips past it...
checkHasGzip()
Skip the test if 'gzip' is not in $PATH.
skipToNodeEnd($name)
Step the current XML reader until node end of given name is found.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
skipWhitespace()
Steps the xml reader over white space.
const CONTENT_FORMAT_WIKITEXT
expectETAOutput()
Checks for test output consisting only of lines containing ETA announcements.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
assertPageEnd()
Asserts that the xml reader is at the page's closing element and skips to the next element...
Allows to change the fields on the form that will be generated $name