3 use MediaWiki\MainConfigNames
;
4 use MediaWiki\Specials\SpecialShortPages
;
7 * Test class for SpecialShortPages class
11 * @license GPL-2.0-or-later
13 class SpecialShortPagesTest
extends MediaWikiIntegrationTestCase
{
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
24 $this->setTemporaryHook( 'ShortPagesQuery', static function () {
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() {
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
] ]