wiki.techinc.nl/tests/phpunit/maintenance/PurgeExpiredBlocksTest.php
Dreamy Jazz a01e5da686 Test purgeExpiredBlocks.php
Why:
* The maintenance scripts in core are mostly untested and testing
  the less complex scripts will improve the test coverage in core.

What:
* Add a non-database integration test for purgeExpiredBlocks.php
  that mocks DatabaseBlockStore::purgeExpiredBlocks to just
  test the maintenance script (as that method is tested elsewhere).

Bug: T371167
Change-Id: Ifa1f506c43380cf5f39f6342bc57dd13255b35f5
2024-08-03 21:33:32 +01:00

24 lines
760 B
PHP

<?php
use MediaWiki\Block\DatabaseBlockStore;
use MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase;
/**
* @covers \PurgeExpiredBlocks
* @author Dreamy Jazz
*/
class PurgeExpiredBlocksTest extends MaintenanceBaseTestCase {
public function getMaintenanceClass() {
return PurgeExpiredBlocks::class;
}
public function testExecute() {
// Mock the DatabaseBlockStore to expect that ::purgeExpiredBlocks is called once.
$mockDatabaseBlockStore = $this->createMock( DatabaseBlockStore::class );
$mockDatabaseBlockStore->expects( $this->once() )
->method( 'purgeExpiredBlocks' );
$this->setService( 'DatabaseBlockStore', $mockDatabaseBlockStore );
$this->maintenance->execute();
$this->expectOutputRegex( '/Purging expired blocks/' );
}
}