public function TaskTest::testTaskDuplicates in Search API 8
Tests that duplicate tasks won't be created.
File
- tests/
src/ Kernel/ System/ TaskTest.php, line 169
Class
- TaskTest
- Tests whether the Search API task system works correctly.
Namespace
Drupal\Tests\search_api\Kernel\SystemCode
public function testTaskDuplicates() {
// @todo Use named parameters here once we depend on PHP 8.0+.
$data = [
'foo' => 'bar',
1,
];
$task1 = $this
->addTask('success');
$task2 = $this
->addTask('success', NULL, NULL, NULL, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
$task1 = $this
->addTask('success', NULL, NULL, $data);
$task2 = $this
->addTask('success', NULL, NULL, $data, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
$task1 = $this
->addTask('success', $this->server);
$task2 = $this
->addTask('success', $this->server, NULL, NULL, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
$task1 = $this
->addTask('success', $this->server, NULL, $data);
$task2 = $this
->addTask('success', $this->server, NULL, $data, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
$task1 = $this
->addTask('success', NULL, $this->index);
$task2 = $this
->addTask('success', NULL, $this->index, NULL, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
$task1 = $this
->addTask('success', NULL, $this->index, $data);
$task2 = $this
->addTask('success', NULL, $this->index, $data, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
$task1 = $this
->addTask('success', $this->server, $this->index);
$task2 = $this
->addTask('success', $this->server, $this->index, NULL, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
$task1 = $this
->addTask('success', $this->server, $this->index, $data);
$task2 = $this
->addTask('success', $this->server, $this->index, $data, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
$data[] = 2;
$task1 = $this
->addTask('success', NULL, NULL, $data);
$task2 = $this
->addTask('success', NULL, NULL, $data, TRUE);
$this
->assertEquals($task1
->id(), $task2
->id());
}