wiki.techinc.nl/tests/phpunit/includes/specials/SpecialUncategorizedCategoriesTest.php
Umherirrender d5c868386e Inject LanguageConverterFactory into special pages
The function SpecialPage::getLanguageConverter does not use service
injection and it seems not useful to inject the factory into every
special page when not used on each special page or used from code
directly in the SpecialPage class.

Bug: T259960
Depends-On: I550f2db0c652193755ad4ad04cececad00be72ea
Change-Id: I11e5d67b7051c159b8d32bf056a0e24aa3b526ae
2020-11-25 18:39:57 +01:00

71 lines
1.9 KiB
PHP

<?php
use MediaWiki\MediaWikiServices;
/**
* Tests for Special:UncategorizedCategories
*/
class SpecialUncategorizedCategoriesTest extends MediaWikiIntegrationTestCase {
/**
* @dataProvider provideTestGetQueryInfoData
* @covers SpecialUncategorizedCategories::getQueryInfo
*/
public function testGetQueryInfo( $msgContent, $expected ) {
$msg = new RawMessage( $msgContent );
$mockContext = $this->getMockBuilder( RequestContext::class )->getMock();
$mockContext->method( 'msg' )->willReturn( $msg );
$services = MediaWikiServices::getInstance();
$special = new SpecialUncategorizedCategories(
$services->getNamespaceInfo(),
$services->getDBLoadBalancer(),
$services->getLinkBatchFactory(),
$services->getLanguageConverterFactory()
);
$special->setContext( $mockContext );
$this->assertEquals( [
'tables' => [
0 => 'page',
1 => 'categorylinks',
],
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
],
'conds' => [
0 => 'cl_from IS NULL',
'page_namespace' => 14,
'page_is_redirect' => 0,
] + $expected,
'join_conds' => [
'categorylinks' => [
0 => 'LEFT JOIN',
1 => 'cl_from = page_id',
],
],
], $special->getQueryInfo() );
}
public function provideTestGetQueryInfoData() {
return [
[
"* Stubs\n* Test\n* *\n* * test123",
[ 1 => "page_title not in ( 'Stubs','Test','*','*_test123' )" ]
],
[
"Stubs\n* Test\n* *\n* * test123",
[ 1 => "page_title not in ( 'Test','*','*_test123' )" ]
],
[
"* StubsTest\n* *\n* * test123",
[ 1 => "page_title not in ( 'StubsTest','*','*_test123' )" ]
],
[ "", [] ],
[ "\n\n\n", [] ],
[ "\n", [] ],
[ "Test\n*Test2", [ 1 => "page_title not in ( 'Test2' )" ] ],
[ "Test", [] ],
[ "*Test\nTest2", [ 1 => "page_title not in ( 'Test' )" ] ],
[ "Test\nTest2", [] ],
];
}
}