| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Context\RequestContext; |
| 4 |
use MediaWiki\Language\RawMessage; |
| 5 |
use MediaWiki\Specials\SpecialUncategorizedCategories; |
| 6 |
use Wikimedia\Rdbms\Expression; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
class SpecialUncategorizedCategoriesTest extends MediaWikiIntegrationTestCase { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 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() |
| 28 |
); |
| 29 |
$special->setContext( $mockContext ); |
| 30 |
$this->assertEquals( [ |
| 31 |
'tables' => [ |
| 32 |
0 => 'page', |
| 33 |
1 => 'categorylinks', |
| 34 |
], |
| 35 |
'fields' => [ |
| 36 |
'namespace' => 'page_namespace', |
| 37 |
'title' => 'page_title', |
| 38 |
], |
| 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', |
| 48 |
], |
| 49 |
], |
| 50 |
], $special->getQueryInfo() ); |
| 51 |
} |
| 52 |
|
| 53 |
public static function provideTestGetQueryInfoData() { |
| 54 |
return [ |
| 55 |
[ |
| 56 |
"* Stubs\n* Test\n* *\n* * test123", |
| 57 |
[ 0 => new Expression( 'page_title', '!=', [ 'Stubs', 'Test', '*', '*_test123' ] ) ] |
| 58 |
], |
| 59 |
[ |
| 60 |
"Stubs\n* Test\n* *\n* * test123", |
| 61 |
[ 0 => new Expression( 'page_title', '!=', [ 'Test', '*', '*_test123' ] ) ], |
| 62 |
], |
| 63 |
[ |
| 64 |
"* StubsTest\n* *\n* * test123", |
| 65 |
[ 0 => new Expression( 'page_title', '!=', [ 'StubsTest', '*', '*_test123' ] ) ], |
| 66 |
], |
| 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", [] ], |
| 74 |
]; |
| 75 |
} |
| 76 |
} |