| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\MainConfigNames; |
| 4 |
use MediaWiki\Specials\SpecialShortPages; |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
class SpecialShortPagesTest extends MediaWikiIntegrationTestCase { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 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 |
|
| 26 |
} ); |
| 27 |
|
| 28 |
$services = $this->getServiceContainer(); |
| 29 |
$page = new SpecialShortPages( |
| 30 |
$services->getNamespaceInfo(), |
| 31 |
$services->getConnectionProvider(), |
| 32 |
$services->getLinkBatchFactory() |
| 33 |
); |
| 34 |
$queryInfo = $page->getQueryInfo(); |
| 35 |
|
| 36 |
$this->assertArrayHasKey( 'conds', $queryInfo ); |
| 37 |
$this->assertArrayHasKey( 'page_namespace', $queryInfo[ 'conds' ] ); |
| 38 |
$this->assertEquals( $expectedNS, $queryInfo[ 'conds' ][ 'page_namespace' ] ); |
| 39 |
} |
| 40 |
|
| 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 |
|
| 47 |
[ [], [ NS_FILE ], [ NS_MAIN ] ] |
| 48 |
]; |
| 49 |
} |
| 50 |
|
| 51 |
} |