Merge "Drop cache interwiki"
[mediawiki.git] / tests / phpunit / includes / specials / SpecialUncategorizedCategoriesTest.php
blobbe4cf3772e2ab21d823b3a84650c9e76f57fabc9
1 <?php
3 use MediaWiki\Context\RequestContext;
4 use MediaWiki\Language\RawMessage;
5 use MediaWiki\Specials\SpecialUncategorizedCategories;
6 use Wikimedia\Rdbms\Expression;
8 /**
9 * Tests for Special:UncategorizedCategories
11 * @group Database
13 class SpecialUncategorizedCategoriesTest extends MediaWikiIntegrationTestCase {
14 /**
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( [
31 'tables' => [
32 0 => 'page',
33 1 => 'categorylinks',
35 'fields' => [
36 'namespace' => 'page_namespace',
37 'title' => 'page_title',
39 'conds' => [
40 'cl_from' => null,
41 'page_namespace' => 14,
42 'page_is_redirect' => 0,
43 ] + $expected,
44 'join_conds' => [
45 'categorylinks' => [
46 0 => 'LEFT JOIN',
47 1 => 'cl_from = page_id',
50 ], $special->getQueryInfo() );
53 public static function provideTestGetQueryInfoData() {
54 return [
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' ] ) ],
67 [ "", [] ],
68 [ "\n\n\n", [] ],
69 [ "\n", [] ],
70 [ "Test\n*Test2", [ 0 => new Expression( 'page_title', '!=', [ 'Test2' ] ) ] ],
71 [ "Test", [] ],
72 [ "*Test\nTest2", [ 0 => new Expression( 'page_title', '!=', [ 'Test' ] ) ] ],
73 [ "Test\nTest2", [] ],