3 * Tests for Special:Uncategorizedcategories
5 class UncategorizedCategoriesPageTest
extends \MediaWikiUnitTestCase
{
7 protected function setUp() {
10 $loadBalancerMock = $this->createMock( LoadBalancer
::class );
12 $loadBalancerMock->expects( $this->any() )
13 ->method( 'getConnection' )
14 ->willReturn( new DatabaseTestHelper( __CLASS__
) );
16 $loadBalancerMockFactory = function () use ( $loadBalancerMock ): LoadBalancer
{
17 return $loadBalancerMock;
20 $this->overrideMwServices( [ 'DBLoadBalancer' => $loadBalancerMockFactory ] );
24 * @dataProvider provideTestGetQueryInfoData
25 * @covers UncategorizedCategoriesPage::getQueryInfo
27 public function testGetQueryInfo( $msgContent, $expected ) {
28 $msg = new RawMessage( $msgContent );
29 $mockContext = $this->getMockBuilder( RequestContext
::class )->getMock();
30 $mockContext->method( 'msg' )->willReturn( $msg );
31 $special = new UncategorizedCategoriesPage();
32 $special->setContext( $mockContext );
33 $this->assertEquals( [
39 'namespace' => 'page_namespace',
40 'title' => 'page_title',
41 'value' => 'page_title',
44 0 => 'cl_from IS NULL',
45 'page_namespace' => 14,
46 'page_is_redirect' => 0,
51 1 => 'cl_from = page_id',
54 ], $special->getQueryInfo() );
57 public function provideTestGetQueryInfoData() {
60 "* Stubs\n* Test\n* *\n* * test123",
61 [ 1 => "page_title not in ( 'Stubs','Test','*','*_test123' )" ]
64 "Stubs\n* Test\n* *\n* * test123",
65 [ 1 => "page_title not in ( 'Test','*','*_test123' )" ]
68 "* StubsTest\n* *\n* * test123",
69 [ 1 => "page_title not in ( 'StubsTest','*','*_test123' )" ]
74 [ "Test\n*Test2", [ 1 => "page_title not in ( 'Test2' )" ] ],
76 [ "*Test\nTest2", [ 1 => "page_title not in ( 'Test' )" ] ],
77 [ "Test\nTest2", [] ],