3 namespace MediaWiki\Tests\Maintenance
;
13 class ManageJobsTest
extends MaintenanceBaseTestCase
{
15 protected function getMaintenanceClass() {
16 return ManageJobs
::class;
19 private function testCommonExecute( string $action ) {
20 $this->maintenance
->setOption( 'type', 'null' );
21 $this->maintenance
->setOption( 'action', $action );
22 $this->maintenance
->execute();
25 public function testExecuteForUnknownAction() {
26 $this->expectCallToFatalError();
27 $this->expectOutputRegex( '/Invalid action.*invalidaction/' );
28 $this->testCommonExecute( 'invalidaction' );
31 /** @dataProvider provideJobCounts */
32 public function testExecuteForDeleteAction( $numberOfJobs ) {
34 $jobQueueGroup = $this->getServiceContainer()->getJobQueueGroup();
35 for ( $i = 0; $i < $numberOfJobs; $i++
) {
36 $jobQueueGroup->push( new NullJob( [] ) );
38 $this->testCommonExecute( 'delete' );
39 // Expect that two jobs are deleted
40 $this->expectOutputRegex(
41 "/Queue has $numberOfJobs job\(s\).*deleting[\s\S]*Done; current size is 0 job\(s\)/"
43 $this->assertSame( 0, $jobQueueGroup->getQueueSizes()['null'] );
46 public static function provideJobCounts() {