4 * Test class for Export methods.
8 * @author Isaac Hutt <mhutti1@gmail.com>
10 class ExportTest
extends MediaWikiLangTestCase
{
12 protected function setUp() {
14 $this->setMwGlobals( [
15 'wgCapitalLinks' => true,
20 * @covers WikiExporter::pageByTitle
22 public function testPageByTitle() {
24 $pageTitle = 'UTPage';
26 $exporter = new WikiExporter(
31 $title = Title
::newFromText( $pageTitle );
33 $sink = new DumpStringOutput
;
34 $exporter->setOutputSink( $sink );
35 $exporter->openStream();
36 $exporter->pageByTitle( $title );
37 $exporter->closeStream();
38 $xmlString = $sink->getOutput();
40 // This throws error if invalid xml output
41 $xmlObject = simplexml_load_string( $xmlString );
44 * Check namespaces match xml
46 $xmlNamespaces = (array)$xmlObject->siteinfo
->namespaces
->namespace;
47 $xmlNamespaces = str_replace( ' ', '_', $xmlNamespaces );
48 unset( $xmlNamespaces[ '@attributes' ] );
49 foreach ( $xmlNamespaces as &$namespaceObject ) {
50 if ( is_object( $namespaceObject ) ) {
51 $namespaceObject = '';
55 $actualNamespaces = (array)$wgContLang->getNamespaces();
56 $actualNamespaces = array_values( $actualNamespaces );
57 $this->assertEquals( $actualNamespaces, $xmlNamespaces );
59 // Check xml page title correct
60 $xmlTitle = (array)$xmlObject->page
->title
;
61 $this->assertEquals( $pageTitle, $xmlTitle[0] );
63 // Check xml page text is not empty
64 $text = (array)$xmlObject->page
->revision
->text
;
65 $this->assertNotEquals( '', $text[0] );