Do not insert page titles into querycache.qc_value
[lhc/web/wiklou.git] / tests / phpunit / includes / ExportTest.php
1 <?php
2
3 use MediaWiki\MediaWikiServices;
4
5 /**
6 * Test class for Export methods.
7 *
8 * @group Database
9 *
10 * @author Isaac Hutt <mhutti1@gmail.com>
11 */
12 class ExportTest extends MediaWikiLangTestCase {
13
14 protected function setUp() {
15 parent::setUp();
16 $this->setMwGlobals( [
17 'wgCapitalLinks' => true,
18 ] );
19 }
20
21 /**
22 * @covers WikiExporter::pageByTitle
23 */
24 public function testPageByTitle() {
25 $pageTitle = 'UTPage';
26
27 $exporter = new WikiExporter(
28 $this->db,
29 WikiExporter::FULL
30 );
31
32 $title = Title::newFromText( $pageTitle );
33
34 $sink = new DumpStringOutput;
35 $exporter->setOutputSink( $sink );
36 $exporter->openStream();
37 $exporter->pageByTitle( $title );
38 $exporter->closeStream();
39
40 // This throws error if invalid xml output
41 $xmlObject = simplexml_load_string( $sink );
42
43 /**
44 * Check namespaces match xml
45 */
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 = '';
52 }
53 }
54
55 $actualNamespaces = (array)MediaWikiServices::getInstance()->getContentLanguage()->
56 getNamespaces();
57 $actualNamespaces = array_values( $actualNamespaces );
58 $this->assertEquals( $actualNamespaces, $xmlNamespaces );
59
60 // Check xml page title correct
61 $xmlTitle = (array)$xmlObject->page->title;
62 $this->assertEquals( $pageTitle, $xmlTitle[0] );
63
64 // Check xml page text is not empty
65 $text = (array)$xmlObject->page->revision->text;
66 $this->assertNotEquals( '', $text[0] );
67 }
68
69 }