Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / MakeTestEditsTest.php
blob986c461f3110e97caca9978d78b9d907b51a6519
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use MakeTestEdits;
7 /**
8 * @covers \MakeTestEdits
9 * @group Database
10 * @author Dreamy Jazz
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(*)' )
35 ->from( 'revision' )
36 ->join( 'actor', null, 'actor_id=rev_actor' )
37 ->join( 'page', null, 'page_id=rev_page' )
38 ->where( [
39 'actor_name' => $testUser->getName(),
40 'page_namespace' => NS_MAIN,
41 ] )
42 ->assertFieldValue( 5 );
43 // Assert that no other unexpected revisions were created
44 $this->newSelectQueryBuilder()
45 ->select( 'COUNT(*)' )
46 ->from( 'revision' )
47 ->assertFieldValue( 5 );