public function ServerTaskTest::testTaskCountLimit in Search API 8
Verifies that no more than 100 items will be executed at once.
File
- tests/
src/ Kernel/ Server/ ServerTaskTest.php, line 336
Class
- ServerTaskTest
- Tests whether the server task system works correctly.
Namespace
Drupal\Tests\search_api\Kernel\ServerCode
public function testTaskCountLimit() {
// Create 101 tasks.
for ($i = 0; $i < 101; ++$i) {
$this->taskManager
->addTask('deleteItems', $this->server, $this->index, [
$i,
]);
}
// Verify that a new operation cannot be executed.
$this->server
->updateIndex($this->index);
$methods = $this
->getCalledMethods('backend');
$this
->assertCount(100, $methods, '100 pending tasks were executed upon new operation.');
$filter = function ($method) {
return $method != 'deleteItems';
};
$this
->assertEmpty(array_filter($methods, $filter), 'The new operation was not executed.');
$this
->assertEquals(2, $this->serverTaskManager
->getCount($this->server), 'A task was created for the new operation.');
}