Merge "Move section ID fallbacks into headers themselves"
[lhc/web/wiklou.git] / tests / phpunit / includes / specials / SpecialShortpagesTest.php
1 <?php
2
3 /**
4 * Test class for SpecialShortpages class
5 *
6 * @since 1.30
7 *
8 * @licence GNU GPL v2+
9 */
10 class SpecialShortpagesTest extends MediaWikiTestCase {
11
12 /**
13 * @dataProvider provideGetQueryInfoRespectsContentNs
14 * @covers ShortPagesPage::getQueryInfo()
15 */
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
33 public function provideGetQueryInfoRespectsContentNs() {
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 }