protected $exceptionFromAddDBData = null;
/**
- * Holds the xmlreader used for analyzing an xml dump
+ * Holds the XMLReader used for analyzing an XML dump
*
* @var XMLReader|null
*/
protected $xml = null;
+ /** @var bool|null Whether the 'gzip' utility is available */
+ protected static $hasGzip = null;
+
+ /**
+ * Skip the test if 'gzip' is not in $PATH.
+ *
+ * @return bool
+ */
+ protected function checkHasGzip() {
+ if ( self::$hasGzip === null ) {
+ self::$hasGzip = ( Installer::locateExecutableInDefaultPaths( 'gzip' ) !== false );
+ }
+
+ if ( !self::$hasGzip ) {
+ $this->markTestSkipped( "Skip test, requires the gzip utility in PATH" );
+ }
+
+ return self::$hasGzip;
+ }
+
/**
* Adds a revision to a page, while returning the resuting revision's id
*
* @param Page $page Page to add the revision to
* @param string $text Revisions text
- * @param string $summary Revisions summare
- * @return array
+ * @param string $summary Revisions summary
+ * @param string $model The model ID (defaults to wikitext)
+ *
* @throws MWException
+ * @return array
*/
- protected function addRevision( Page $page, $text, $summary ) {
+ protected function addRevision( Page $page, $text, $summary, $model = CONTENT_MODEL_WIKITEXT ) {
$status = $page->doEditContent(
- ContentHandler::makeContent( $text, $page->getTitle() ),
+ ContentHandler::makeContent( $text, $page->getTitle(), $model ),
$summary
);
$text_id = $revision->getTextId();
if ( ( $revision_id > 0 ) && ( $text_id > 0 ) ) {
- return array( $revision_id, $text_id );
+ return [ $revision_id, $text_id ];
}
}
- throw new MWException( "Could not determine revision id (" . $status->getWikiText() . ")" );
+ throw new MWException( "Could not determine revision id ("
+ . $status->getWikiText( false, false, 'en' ) . ")" );
}
/**
// expectOutput[...] functions. However, the PHPUnit shipped prediactes
// do not allow to check /each/ line of the output using /readable/ REs.
// So we ...
- //
+
// 1. ... add a dummy output checking to make PHPUnit not complain
// about unchecked test output
$this->expectOutputRegex( '//' );
* @param string $name Title of the current page
*/
protected function assertPageStart( $id, $ns, $name ) {
-
$this->assertNodeStart( "page" );
$this->skipWhitespace();
if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
&& ( $this->xml->name == "text" )
) {
-
$this->xml->read();
}
$this->skipWhitespace();