Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / DeleteArchivedRevisionsTest.php
bloba8397b3e19ad4107529835441b523244cb9f6c19
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use DeleteArchivedRevisions;
6 use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
8 /**
9 * @covers \DeleteArchivedRevisions
10 * @group Database
11 * @author Dreamy Jazz
13 class DeleteArchivedRevisionsTest extends MaintenanceBaseTestCase {
14 use MockAuthorityTrait;
16 protected function getMaintenanceClass() {
17 return DeleteArchivedRevisions::class;
20 /** @dataProvider provideExecute */
21 public function testExecute( $options, $expectedRowCountAfterExecution, $expectedOutputRegex ) {
22 // Create a page and then delete it
23 $testPage = $this->getExistingTestPage();
24 $deleteStatus = $this->getServiceContainer()->getDeletePageFactory()
25 ->newDeletePage( $testPage, $this->mockRegisteredUltimateAuthority() )
26 ->deleteIfAllowed( 'test' );
27 $this->assertStatusGood( $deleteStatus );
28 // Check that this has caused a revision to be added to the archive table
29 $this->newSelectQueryBuilder()
30 ->select( 'COUNT(*)' )
31 ->from( 'archive' )
32 ->assertFieldValue( 1 );
33 // Call ::execute
34 foreach ( $options as $name => $value ) {
35 $this->maintenance->setOption( $name, $value );
37 $this->maintenance->execute();
38 // Verify that the archive table is now empty.
39 $this->newSelectQueryBuilder()
40 ->select( 'COUNT(*)' )
41 ->from( 'archive' )
42 ->assertFieldValue( $expectedRowCountAfterExecution );
43 $this->expectOutputRegex( $expectedOutputRegex );
46 public static function provideExecute() {
47 return [
48 'Dry-run' => [ [], 1, '/Found 1 revisions to delete/' ],
49 'Actual deletion' => [ [ 'delete' => 1 ], 0, '/Deleting archived revisions.*1 revisions deleted/' ],