2017-07-27 23:29:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
2022-08-14 13:47:11 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
|
|
|
|
|
2017-07-27 23:29:21 +00:00
|
|
|
/**
|
2019-04-14 15:14:22 +00:00
|
|
|
* Test class for SpecialShortPages class
|
2017-07-27 23:29:21 +00:00
|
|
|
*
|
|
|
|
|
* @since 1.30
|
|
|
|
|
*
|
2018-05-23 23:23:42 +00:00
|
|
|
* @license GPL-2.0-or-later
|
2017-07-27 23:29:21 +00:00
|
|
|
*/
|
2020-06-30 15:09:24 +00:00
|
|
|
class SpecialShortPagesTest extends MediaWikiIntegrationTestCase {
|
2017-07-27 23:29:21 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideGetQueryInfoRespectsContentNs
|
2019-04-14 15:14:22 +00:00
|
|
|
* @covers SpecialShortPages::getQueryInfo()
|
2017-07-27 23:29:21 +00:00
|
|
|
*/
|
|
|
|
|
public function testGetQueryInfoRespectsContentNS( $contentNS, $blacklistNS, $expectedNS ) {
|
2022-08-14 13:47:11 +00:00
|
|
|
$this->overrideConfigValues( [
|
|
|
|
|
MainConfigNames::ShortPagesNamespaceExclusions => $blacklistNS,
|
|
|
|
|
MainConfigNames::ContentNamespaces => $contentNS
|
2017-07-27 23:29:21 +00:00
|
|
|
] );
|
2021-02-06 19:30:20 +00:00
|
|
|
$this->setTemporaryHook( 'ShortPagesQuery', static function () {
|
2017-07-27 23:29:21 +00:00
|
|
|
// empty hook handler
|
|
|
|
|
} );
|
|
|
|
|
|
2022-01-12 20:13:39 +00:00
|
|
|
$services = $this->getServiceContainer();
|
2020-10-21 19:33:52 +00:00
|
|
|
$page = new SpecialShortPages(
|
|
|
|
|
$services->getNamespaceInfo(),
|
2023-04-19 15:35:34 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2020-10-27 20:29:28 +00:00
|
|
|
$services->getLinkBatchFactory()
|
2020-10-21 19:33:52 +00:00
|
|
|
);
|
2017-07-27 23:29:21 +00:00
|
|
|
$queryInfo = $page->getQueryInfo();
|
|
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'conds', $queryInfo );
|
|
|
|
|
$this->assertArrayHasKey( 'page_namespace', $queryInfo[ 'conds' ] );
|
|
|
|
|
$this->assertEquals( $expectedNS, $queryInfo[ 'conds' ][ 'page_namespace' ] );
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 11:36:19 +00:00
|
|
|
public static function provideGetQueryInfoRespectsContentNs() {
|
2017-07-27 23:29:21 +00:00
|
|
|
return [
|
|
|
|
|
[ [ NS_MAIN, NS_FILE ], [], [ NS_MAIN, NS_FILE ] ],
|
|
|
|
|
[ [ NS_MAIN, NS_TALK ], [ NS_FILE ], [ NS_MAIN, NS_TALK ] ],
|
|
|
|
|
[ [ NS_MAIN, NS_FILE ], [ NS_FILE ], [ NS_MAIN ] ],
|
|
|
|
|
// NS_MAIN namespace is always forced
|
|
|
|
|
[ [], [ NS_FILE ], [ NS_MAIN ] ]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|