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 purgeMessageBlobStore.php that mocks MessageBlobStore::clear to just test the maintenance script. ** Testing that the message cache was actually cleared is not as simple, and the code being called is already tested elsewhere. Therefore, mocking the method avoids indirectly testing already tested code. Bug: T371167 Change-Id: Ibb16448d2779d34ee8348368f413d821637ecd82
28 lines
969 B
PHP
28 lines
969 B
PHP
<?php
|
|
|
|
use MediaWiki\ResourceLoader\MessageBlobStore;
|
|
use MediaWiki\ResourceLoader\ResourceLoader;
|
|
use MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase;
|
|
|
|
/**
|
|
* @covers \PurgeMessageBlobStore
|
|
* @author Dreamy Jazz
|
|
*/
|
|
class PurgeMessageBlobStoreTest extends MaintenanceBaseTestCase {
|
|
public function getMaintenanceClass() {
|
|
return PurgeMessageBlobStore::class;
|
|
}
|
|
|
|
public function testExecute() {
|
|
// Mock MessageBlobStore::clear, expecting that it be called once.
|
|
// Testing that calling the method actually clears the cache is done by MessageBlobStoreTest.
|
|
$mockMessageBlobStore = $this->createMock( MessageBlobStore::class );
|
|
$mockMessageBlobStore->expects( $this->once() )
|
|
->method( 'clear' );
|
|
$resourceLoader = $this->createMock( ResourceLoader::class );
|
|
$resourceLoader->method( 'getMessageBlobStore' )
|
|
->willReturn( $mockMessageBlobStore );
|
|
$this->setService( 'ResourceLoader', $resourceLoader );
|
|
$this->maintenance->execute();
|
|
}
|
|
}
|