Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / tests / phpunit / includes / ExportTest.php
bloba5d357066b3e9d1ebc7beb080ba234b5af125e27
1 <?php
3 /**
4 * Test class for Export methods.
6 * @group Database
8 * @author Isaac Hutt <mhutti1@gmail.com>
9 */
10 class ExportTest extends MediaWikiLangTestCase {
12 protected function setUp() {
13 parent::setUp();
14 $this->setMwGlobals( [
15 'wgCapitalLinks' => true,
16 ] );
19 /**
20 * @covers WikiExporter::pageByTitle
22 public function testPageByTitle() {
23 global $wgContLang;
24 $pageTitle = 'UTPage';
26 $exporter = new WikiExporter(
27 $this->db,
28 WikiExporter::FULL
31 $title = Title::newFromText( $pageTitle );
33 $sink = new DumpStringOutput;
34 $exporter->setOutputSink( $sink );
35 $exporter->openStream();
36 $exporter->pageByTitle( $title );
37 $exporter->closeStream();
39 // This throws error if invalid xml output
40 $xmlObject = simplexml_load_string( $sink );
42 /**
43 * Check namespaces match xml
45 $xmlNamespaces = (array)$xmlObject->siteinfo->namespaces->namespace;
46 $xmlNamespaces = str_replace( ' ', '_', $xmlNamespaces );
47 unset( $xmlNamespaces[ '@attributes' ] );
48 foreach ( $xmlNamespaces as &$namespaceObject ) {
49 if ( is_object( $namespaceObject ) ) {
50 $namespaceObject = '';
54 $actualNamespaces = (array)$wgContLang->getNamespaces();
55 $actualNamespaces = array_values( $actualNamespaces );
56 $this->assertEquals( $actualNamespaces, $xmlNamespaces );
58 // Check xml page title correct
59 $xmlTitle = (array)$xmlObject->page->title;
60 $this->assertEquals( $pageTitle, $xmlTitle[0] );
62 // Check xml page text is not empty
63 $text = (array)$xmlObject->page->revision->text;
64 $this->assertNotEquals( '', $text[0] );