Merge "Drop cache interwiki"
[mediawiki.git] / tests / phpunit / includes / specials / SpecialShortPagesTest.php
blob2dfa0ee5eacf1402f1fe210e20c556576d0e8e14
1 <?php
3 use MediaWiki\MainConfigNames;
4 use MediaWiki\Specials\SpecialShortPages;
6 /**
7 * Test class for SpecialShortPages class
9 * @since 1.30
11 * @license GPL-2.0-or-later
13 class SpecialShortPagesTest extends MediaWikiIntegrationTestCase {
15 /**
16 * @dataProvider provideGetQueryInfoRespectsContentNs
17 * @covers \MediaWiki\Specials\SpecialShortPages::getQueryInfo
19 public function testGetQueryInfoRespectsContentNS( $contentNS, $blacklistNS, $expectedNS ) {
20 $this->overrideConfigValues( [
21 MainConfigNames::ShortPagesNamespaceExclusions => $blacklistNS,
22 MainConfigNames::ContentNamespaces => $contentNS
23 ] );
24 $this->setTemporaryHook( 'ShortPagesQuery', static function () {
25 // empty hook handler
26 } );
28 $services = $this->getServiceContainer();
29 $page = new SpecialShortPages(
30 $services->getNamespaceInfo(),
31 $services->getConnectionProvider(),
32 $services->getLinkBatchFactory()
34 $queryInfo = $page->getQueryInfo();
36 $this->assertArrayHasKey( 'conds', $queryInfo );
37 $this->assertArrayHasKey( 'page_namespace', $queryInfo[ 'conds' ] );
38 $this->assertEquals( $expectedNS, $queryInfo[ 'conds' ][ 'page_namespace' ] );
41 public static function provideGetQueryInfoRespectsContentNs() {
42 return [
43 [ [ NS_MAIN, NS_FILE ], [], [ NS_MAIN, NS_FILE ] ],
44 [ [ NS_MAIN, NS_TALK ], [ NS_FILE ], [ NS_MAIN, NS_TALK ] ],
45 [ [ NS_MAIN, NS_FILE ], [ NS_FILE ], [ NS_MAIN ] ],
46 // NS_MAIN namespace is always forced
47 [ [], [ NS_FILE ], [ NS_MAIN ] ]