l10n = $this->getMockBuilder(IL10N::class)->getMock(); $this->timeFactory = $this->getMockBuilder(ITimeFactory::class)->getMock(); $this->taskProcessingManager = $this->getMockBuilder(IManager::class)->getMock(); $this->check = new TaskProcessingPickupSpeed( $this->l10n, $this->taskProcessingManager, $this->timeFactory, ); } public function testPass(): void { $tasks = []; for ($i = 0; $i < 100; $i++) { $task = new Task('test', ['test' => 'test'], 'settings', 'user' . $i); $task->setStartedAt(0); if ($i < 15) { $task->setScheduledAt(60 * 5); // 15% get 5mins } else { $task->setScheduledAt(60); // the rest gets 1min } $tasks[] = $task; } $this->taskProcessingManager->method('getTasks')->willReturn($tasks); $this->assertEquals(SetupResult::SUCCESS, $this->check->run()->getSeverity()); } public function testFail(): void { $tasks = []; for ($i = 0; $i < 100; $i++) { $task = new Task('test', ['test' => 'test'], 'settings', 'user' . $i); $task->setStartedAt(0); if ($i < 30) { $task->setScheduledAt(60 * 5); // 30% get 5mins } else { $task->setScheduledAt(60); // the rest gets 1min } $tasks[] = $task; } $this->taskProcessingManager->method('getTasks')->willReturn($tasks); $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity()); } }