wiki.techinc.nl/tests/phpunit/includes/specials/SpecialShortPagesTest.php
Reedy dd71a77512 Make most special pages class names match filename
Change-Id: I3a9f932acb7d9cf44a984b5d97f9fbc6b8670f7d
2019-09-10 02:47:08 +01:00

43 lines
1.2 KiB
PHP

<?php
/**
* Test class for SpecialShortPages class
*
* @since 1.30
*
* @license GPL-2.0-or-later
*/
class SpecialShortPagesTest extends MediaWikiTestCase {
/**
* @dataProvider provideGetQueryInfoRespectsContentNs
* @covers SpecialShortPages::getQueryInfo()
*/
public function testGetQueryInfoRespectsContentNS( $contentNS, $blacklistNS, $expectedNS ) {
$this->setMwGlobals( [
'wgShortPagesNamespaceBlacklist' => $blacklistNS,
'wgContentNamespaces' => $contentNS
] );
$this->setTemporaryHook( 'ShortPagesQuery', function () {
// empty hook handler
} );
$page = new SpecialShortPages();
$queryInfo = $page->getQueryInfo();
$this->assertArrayHasKey( 'conds', $queryInfo );
$this->assertArrayHasKey( 'page_namespace', $queryInfo[ 'conds' ] );
$this->assertEquals( $expectedNS, $queryInfo[ 'conds' ][ 'page_namespace' ] );
}
public function provideGetQueryInfoRespectsContentNs() {
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 ] ]
];
}
}