Merge "Parser: Use 'Special:Badtitle/Parser' instead of 'NO TITLE'"
[lhc/web/wiklou.git] / tests / phpunit / includes / specials / SpecialUncategorizedCategoriesTest.php
1 <?php
2 /**
3 * Tests for Special:UncategorizedCategories
4 */
5 class SpecialUncategorizedCategoriesTest extends MediaWikiTestCase {
6 /**
7 * @dataProvider provideTestGetQueryInfoData
8 * @covers SpecialUncategorizedCategories::getQueryInfo
9 */
10 public function testGetQueryInfo( $msgContent, $expected ) {
11 $msg = new RawMessage( $msgContent );
12 $mockContext = $this->getMockBuilder( RequestContext::class )->getMock();
13 $mockContext->method( 'msg' )->willReturn( $msg );
14 $special = new SpecialUncategorizedCategories();
15 $special->setContext( $mockContext );
16 $this->assertEquals( [
17 'tables' => [
18 0 => 'page',
19 1 => 'categorylinks',
20 ],
21 'fields' => [
22 'namespace' => 'page_namespace',
23 'title' => 'page_title',
24 'value' => 'page_title',
25 ],
26 'conds' => [
27 0 => 'cl_from IS NULL',
28 'page_namespace' => 14,
29 'page_is_redirect' => 0,
30 ] + $expected,
31 'join_conds' => [
32 'categorylinks' => [
33 0 => 'LEFT JOIN',
34 1 => 'cl_from = page_id',
35 ],
36 ],
37 ], $special->getQueryInfo() );
38 }
39
40 public function provideTestGetQueryInfoData() {
41 return [
42 [
43 "* Stubs\n* Test\n* *\n* * test123",
44 [ 1 => "page_title not in ( 'Stubs','Test','*','*_test123' )" ]
45 ],
46 [
47 "Stubs\n* Test\n* *\n* * test123",
48 [ 1 => "page_title not in ( 'Test','*','*_test123' )" ]
49 ],
50 [
51 "* StubsTest\n* *\n* * test123",
52 [ 1 => "page_title not in ( 'StubsTest','*','*_test123' )" ]
53 ],
54 [ "", [] ],
55 [ "\n\n\n", [] ],
56 [ "\n", [] ],
57 [ "Test\n*Test2", [ 1 => "page_title not in ( 'Test2' )" ] ],
58 [ "Test", [] ],
59 [ "*Test\nTest2", [ 1 => "page_title not in ( 'Test' )" ] ],
60 [ "Test\nTest2", [] ],
61 ];
62 }
63 }