1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
<?php
use MediaWiki\Context\RequestContext;
use MediaWiki\Language\RawMessage;
use MediaWiki\Specials\SpecialUncategorizedCategories;
use Wikimedia\Rdbms\Expression;
/**
* Tests for Special:UncategorizedCategories
*
* @group Database
*/
class SpecialUncategorizedCategoriesTest extends MediaWikiIntegrationTestCase {
/**
* @dataProvider provideTestGetQueryInfoData
* @covers \MediaWiki\Specials\SpecialUncategorizedCategories::getQueryInfo
*/
public function testGetQueryInfo( $msgContent, $expected ) {
$msg = new RawMessage( $msgContent );
$mockContext = $this->createMock( RequestContext::class );
$mockContext->method( 'msg' )->willReturn( $msg );
$services = $this->getServiceContainer();
$special = new SpecialUncategorizedCategories(
$services->getNamespaceInfo(),
$services->getConnectionProvider(),
$services->getLinkBatchFactory(),
$services->getLanguageConverterFactory()
);
$special->setContext( $mockContext );
$this->assertEquals( [
'tables' => [
0 => 'page',
1 => 'categorylinks',
],
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
],
'conds' => [
'cl_from' => null,
'page_namespace' => 14,
'page_is_redirect' => 0,
] + $expected,
'join_conds' => [
'categorylinks' => [
0 => 'LEFT JOIN',
1 => 'cl_from = page_id',
],
],
], $special->getQueryInfo() );
}
public static function provideTestGetQueryInfoData() {
return [
[
"* Stubs\n* Test\n* *\n* * test123",
[ 0 => new Expression( 'page_title', '!=', [ 'Stubs', 'Test', '*', '*_test123' ] ) ]
],
[
"Stubs\n* Test\n* *\n* * test123",
[ 0 => new Expression( 'page_title', '!=', [ 'Test', '*', '*_test123' ] ) ],
],
[
"* StubsTest\n* *\n* * test123",
[ 0 => new Expression( 'page_title', '!=', [ 'StubsTest', '*', '*_test123' ] ) ],
],
[ "", [] ],
[ "\n\n\n", [] ],
[ "\n", [] ],
[ "Test\n*Test2", [ 0 => new Expression( 'page_title', '!=', [ 'Test2' ] ) ] ],
[ "Test", [] ],
[ "*Test\nTest2", [ 0 => new Expression( 'page_title', '!=', [ 'Test' ] ) ] ],
[ "Test\nTest2", [] ],
];
}
}
|