You are here

public function TaskTest::testTaskFail in Search API 8

Tests failed task execution.

File

tests/src/Kernel/System/TaskTest.php, line 109

Class

TaskTest
Tests whether the Search API task system works correctly.

Namespace

Drupal\Tests\search_api\Kernel\System

Code

public function testTaskFail() {
  $task = $this
    ->addTask('fail', $this->server);
  $this
    ->assertEquals(1, $this->taskManager
    ->getTasksCount());
  try {
    $this->taskManager
      ->executeAllTasks([
      'server_id' => $this->server
        ->id(),
    ]);
    $this
      ->fail('Exception expected');
  } catch (SearchApiException $e) {
    $this
      ->assertEquals('fail', $e
      ->getMessage());
  }
  $this
    ->assertEquals(1, $this->taskManager
    ->getTasksCount());
  $this
    ->assertEquals($task
    ->toArray(), $this->taskWorker
    ->getEventLog()[0]);
}