3 use MediaWiki\MediaWikiServices
;
6 * Test class for Export methods.
10 * @author Isaac Hutt <mhutti1@gmail.com>
12 class ExportTest
extends MediaWikiLangTestCase
{
14 protected function setUp() {
16 $this->setMwGlobals( [
17 'wgCapitalLinks' => true,
22 * @covers WikiExporter::pageByTitle
24 public function testPageByTitle() {
25 $pageTitle = 'UTPage';
27 $exporter = new WikiExporter(
32 $title = Title
::newFromText( $pageTitle );
34 $sink = new DumpStringOutput
;
35 $exporter->setOutputSink( $sink );
36 $exporter->openStream();
37 $exporter->pageByTitle( $title );
38 $exporter->closeStream();
40 // This throws error if invalid xml output
41 $xmlObject = simplexml_load_string( $sink );
44 * Check namespaces match xml
46 foreach ( $xmlObject->siteinfo
->namespaces
->children() as $namespace ) {
47 // Get the text content of the SimpleXMLElement
48 $xmlNamespaces[] = (string)$namespace;
50 $xmlNamespaces = str_replace( ' ', '_', $xmlNamespaces );
52 $actualNamespaces = (array)MediaWikiServices
::getInstance()->getContentLanguage()->
54 $actualNamespaces = array_values( $actualNamespaces );
55 $this->assertEquals( $actualNamespaces, $xmlNamespaces );
57 // Check xml page title correct
58 $xmlTitle = (array)$xmlObject->page
->title
;
59 $this->assertEquals( $pageTitle, $xmlTitle[0] );
61 // Check xml page text is not empty
62 $text = (array)$xmlObject->page
->revision
->text
;
63 $this->assertNotEquals( '', $text[0] );