MediaWiki REL1_31
SpecialShortpagesTest.php
Go to the documentation of this file.
1<?php
2
11
16 public function testGetQueryInfoRespectsContentNS( $contentNS, $blacklistNS, $expectedNS ) {
17 $this->setMwGlobals( [
18 'wgShortPagesNamespaceBlacklist' => $blacklistNS,
19 'wgContentNamespaces' => $contentNS
20 ] );
21 $this->setTemporaryHook( 'ShortPagesQuery', function () {
22 // empty hook handler
23 } );
24
25 $page = new ShortPagesPage();
26 $queryInfo = $page->getQueryInfo();
27
28 $this->assertArrayHasKey( 'conds', $queryInfo );
29 $this->assertArrayHasKey( 'page_namespace', $queryInfo[ 'conds' ] );
30 $this->assertEquals( $expectedNS, $queryInfo[ 'conds' ][ 'page_namespace' ] );
31 }
32
34 return [
35 [ [ NS_MAIN, NS_FILE ], [], [ NS_MAIN, NS_FILE ] ],
36 [ [ NS_MAIN, NS_TALK ], [ NS_FILE ], [ NS_MAIN, NS_TALK ] ],
37 [ [ NS_MAIN, NS_FILE ], [ NS_FILE ], [ NS_MAIN ] ],
38 // NS_MAIN namespace is always forced
39 [ [], [ NS_FILE ], [ NS_MAIN ] ]
40 ];
41 }
42
43}
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
setTemporaryHook( $hookName, $handler)
Create a temporary hook handler which will be reset by tearDown.
SpecialShortpages extends QueryPage.
Test class for SpecialShortpages class.
testGetQueryInfoRespectsContentNS( $contentNS, $blacklistNS, $expectedNS)
provideGetQueryInfoRespectsContentNs ShortPagesPage::getQueryInfo()
const NS_FILE
Definition Defines.php:80
const NS_MAIN
Definition Defines.php:74
const NS_TALK
Definition Defines.php:75