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 rebuildmessages.php that mocks MessageCache::clear to just test the maintenance script. Bug: T371167 Change-Id: I3423821d5daab7a68737dd6831b057857811238c
23 lines
679 B
PHP
23 lines
679 B
PHP
<?php
|
|
|
|
use MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase;
|
|
|
|
/**
|
|
* @covers \RebuildMessages
|
|
* @author Dreamy Jazz
|
|
*/
|
|
class RebuildMessagesTest extends MaintenanceBaseTestCase {
|
|
public function getMaintenanceClass() {
|
|
return RebuildMessages::class;
|
|
}
|
|
|
|
public function testExecute() {
|
|
// Mock the MessageCache to expect that ::clear is called once by the maintenance script
|
|
$mockMessageCache = $this->createMock( MessageCache::class );
|
|
$mockMessageCache->expects( $this->once() )
|
|
->method( 'clear' );
|
|
$this->setService( 'MessageCache', $mockMessageCache );
|
|
$this->maintenance->execute();
|
|
$this->expectOutputRegex( '/Purging message cache.*Done/' );
|
|
}
|
|
}
|