| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Maintenance; |
| 4 |
|
| 5 |
use MediaWiki\Maintenance\Maintenance; |
| 6 |
use PHPUnit\Framework\MockObject\MockObject; |
| 7 |
use PurgeOldText; |
| 8 |
use Wikimedia\TestingAccessWrapper; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
class PurgeOldTextTest extends MaintenanceBaseTestCase { |
| 15 |
|
| 16 |
|
| 17 |
protected $maintenance; |
| 18 |
|
| 19 |
public function getMaintenanceClass() { |
| 20 |
return PurgeOldText::class; |
| 21 |
} |
| 22 |
|
| 23 |
protected function createMaintenance() { |
| 24 |
|
| 25 |
$obj = $this->getMockBuilder( $this->getMaintenanceClass() ) |
| 26 |
->onlyMethods( [ 'purgeRedundantText' ] ) |
| 27 |
->getMock(); |
| 28 |
return TestingAccessWrapper::newFromObject( $obj ); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 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 ); |
| 38 |
} |
| 39 |
$this->maintenance->execute(); |
| 40 |
} |
| 41 |
|
| 42 |
public static function providePurgeOptionValues() { |
| 43 |
return [ |
| 44 |
'--purge not provided' => [ false ], |
| 45 |
'--purge provided' => [ true ], |
| 46 |
]; |
| 47 |
} |
| 48 |
} |