3 namespace MediaWiki\Tests\Maintenance
;
6 use MediaWiki\MainConfigNames
;
10 * @covers \CheckUsernames
13 class CheckUsernamesTest
extends MaintenanceBaseTestCase
{
15 protected function getMaintenanceClass() {
16 return CheckUsernames
::class;
19 public function testExecute() {
20 $testUser1 = ( new TestUser( "TestUser 1234" ) )->getUserIdentity();
21 $testUser2 = ( new TestUser( "TestUser 4321" ) )->getUserIdentity();
22 // Set wgMaxNameChars to 2 so that both users fail to be valid.
23 $this->overrideConfigValue( MainConfigNames
::MaxNameChars
, 2 );
24 // Set the batch size to 1 to test multiple batches (as there are two users)
25 $this->maintenance
->setOption( 'batch-size', 1 );
26 $this->maintenance
->execute();
27 $this->expectOutputString(
28 sprintf( "Found: %6d: '%s'\n", $testUser1->getId(), $testUser1->getName() ) .
29 sprintf( "Found: %6d: '%s'\n", $testUser2->getId(), $testUser2->getName() )