3 namespace MediaWiki\Tests\Maintenance
;
8 * @covers \MakeTestEdits
12 class MakeTestEditsTest
extends MaintenanceBaseTestCase
{
14 protected function getMaintenanceClass() {
15 return MakeTestEdits
::class;
18 public function testExecuteForUnregisteredUser() {
19 $this->maintenance
->setOption( 'user', 'NonExistingTestUser1' );
20 $this->expectCallToFatalError();
21 $this->expectOutputRegex( '/No such user exists/' );
22 $this->maintenance
->execute();
25 public function testExecute() {
26 // Run the maintenance script to create 5 edits.
27 $testUser = $this->getTestUser()->getUserIdentity();
28 $this->maintenance
->setOption( 'user', $testUser->getName() );
29 $this->maintenance
->setOption( 'count', 5 );
30 $this->maintenance
->setBatchSize( 2 );
31 $this->maintenance
->execute();
32 // Assert that the revision table now has 5 revisions in the mainspace for the test user we used
33 $this->newSelectQueryBuilder()
34 ->select( 'COUNT(*)' )
36 ->join( 'actor', null, 'actor_id=rev_actor' )
37 ->join( 'page', null, 'page_id=rev_page' )
39 'actor_name' => $testUser->getName(),
40 'page_namespace' => NS_MAIN
,
42 ->assertFieldValue( 5 );
43 // Assert that no other unexpected revisions were created
44 $this->newSelectQueryBuilder()
45 ->select( 'COUNT(*)' )
47 ->assertFieldValue( 5 );