diff options
Diffstat (limited to 'www/wiki/tests/phpunit/includes/specials/SpecialUncategorizedcategoriesTest.php')
-rw-r--r-- | www/wiki/tests/phpunit/includes/specials/SpecialUncategorizedcategoriesTest.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/specials/SpecialUncategorizedcategoriesTest.php b/www/wiki/tests/phpunit/includes/specials/SpecialUncategorizedcategoriesTest.php new file mode 100644 index 00000000..80bd365f --- /dev/null +++ b/www/wiki/tests/phpunit/includes/specials/SpecialUncategorizedcategoriesTest.php @@ -0,0 +1,63 @@ +<?php +/** + * Tests for Special:Uncategorizedcategories + */ +class UncategorizedCategoriesPageTest extends MediaWikiTestCase { + /** + * @dataProvider provideTestGetQueryInfoData + * @covers UncategorizedCategoriesPage::getQueryInfo + */ + public function testGetQueryInfo( $msgContent, $expected ) { + $msg = new RawMessage( $msgContent ); + $mockContext = $this->getMockBuilder( RequestContext::class )->getMock(); + $mockContext->method( 'msg' )->willReturn( $msg ); + $special = new UncategorizedCategoriesPage(); + $special->setContext( $mockContext ); + $this->assertEquals( [ + 'tables' => [ + 0 => 'page', + 1 => 'categorylinks', + ], + 'fields' => [ + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => '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", [] ], + ]; + } +} |