Debian Codegraph @

tests/phpunit/maintenance/PurgeOldTextTest.php

raw symbols SCIP
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 * @covers PurgeOldText
12 * @author Dreamy Jazz
13 */
14 class PurgeOldTextTest extends MaintenanceBaseTestCase {
15
16 /** @var Maintenance|MockObject */
17 protected $maintenance;
18
19 public function getMaintenanceClass() {
20 return PurgeOldText::class;
21 }
22
23 protected function createMaintenance() {
24 // Mock ::purgeRedundantText as this should be separately tested
25 $obj = $this->getMockBuilder( $this->getMaintenanceClass() )
26 ->onlyMethods( [ 'purgeRedundantText' ] )
27 ->getMock();
28 return TestingAccessWrapper::newFromObject( $obj );
29 }
30
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 );
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 }