3 namespace MediaWiki\Tests\Maintenance
;
5 use MediaWiki\Maintenance\Maintenance
;
6 use PHPUnit\Framework\MockObject\MockObject
;
8 use Wikimedia\TestingAccessWrapper
;
11 * @covers \PurgeOldText
14 class PurgeOldTextTest
extends MaintenanceBaseTestCase
{
16 /** @var Maintenance|MockObject */
17 protected $maintenance;
19 public function getMaintenanceClass() {
20 return PurgeOldText
::class;
23 protected function createMaintenance() {
24 // Mock ::purgeRedundantText as this should be separately tested
25 $obj = $this->getMockBuilder( $this->getMaintenanceClass() )
26 ->onlyMethods( [ 'purgeRedundantText' ] )
28 return TestingAccessWrapper
::newFromObject( $obj );
31 /** @dataProvider providePurgeOptionValues */
32 public function testExecute( $purgeOptionProvided ) {
33 $this->maintenance
->expects( $this->once() )
34 ->method( 'purgeRedundantText' )
35 ->with( $purgeOptionProvided );
36 if ( $purgeOptionProvided ) {
37 $this->maintenance
->setOption( 'purge', 1 );
39 $this->maintenance
->execute();
42 public static function providePurgeOptionValues() {
44 '--purge not provided' => [ false ],
45 '--purge provided' => [ true ],