3 use MediaWiki\Context\RequestContext
;
4 use MediaWiki\Language\RawMessage
;
5 use MediaWiki\Specials\SpecialUncategorizedCategories
;
6 use Wikimedia\Rdbms\Expression
;
9 * Tests for Special:UncategorizedCategories
13 class SpecialUncategorizedCategoriesTest
extends MediaWikiIntegrationTestCase
{
15 * @dataProvider provideTestGetQueryInfoData
16 * @covers \MediaWiki\Specials\SpecialUncategorizedCategories::getQueryInfo
18 public function testGetQueryInfo( $msgContent, $expected ) {
19 $msg = new RawMessage( $msgContent );
20 $mockContext = $this->createMock( RequestContext
::class );
21 $mockContext->method( 'msg' )->willReturn( $msg );
22 $services = $this->getServiceContainer();
23 $special = new SpecialUncategorizedCategories(
24 $services->getNamespaceInfo(),
25 $services->getConnectionProvider(),
26 $services->getLinkBatchFactory(),
27 $services->getLanguageConverterFactory()
29 $special->setContext( $mockContext );
30 $this->assertEquals( [
36 'namespace' => 'page_namespace',
37 'title' => 'page_title',
41 'page_namespace' => 14,
42 'page_is_redirect' => 0,
47 1 => 'cl_from = page_id',
50 ], $special->getQueryInfo() );
53 public static function provideTestGetQueryInfoData() {
56 "* Stubs\n* Test\n* *\n* * test123",
57 [ 0 => new Expression( 'page_title', '!=', [ 'Stubs', 'Test', '*', '*_test123' ] ) ]
60 "Stubs\n* Test\n* *\n* * test123",
61 [ 0 => new Expression( 'page_title', '!=', [ 'Test', '*', '*_test123' ] ) ],
64 "* StubsTest\n* *\n* * test123",
65 [ 0 => new Expression( 'page_title', '!=', [ 'StubsTest', '*', '*_test123' ] ) ],
70 [ "Test\n*Test2", [ 0 => new Expression( 'page_title', '!=', [ 'Test2' ] ) ] ],
72 [ "*Test\nTest2", [ 0 => new Expression( 'page_title', '!=', [ 'Test' ] ) ] ],
73 [ "Test\nTest2", [] ],