You are here

public function CommandHelperTest::testListCommand in Search API 8

Tests the "List indexes" command.

@covers ::indexListCommand

File

tests/src/Kernel/System/CommandHelperTest.php, line 120

Class

CommandHelperTest
Tests Search API functionality that gets executed by console utilities.

Namespace

Drupal\Tests\search_api\Kernel\System

Code

public function testListCommand() {
  $results = $this->systemUnderTest
    ->indexListCommand();
  $this
    ->assertIsArray($results);
  $this
    ->assertCount(2, $results);
  $this
    ->assertArrayHasKey('test_index', $results);
  $this
    ->assertArrayHasKey('second_index', $results);
  $this
    ->assertArrayHasKey('id', $results['test_index']);
  $this
    ->assertArrayHasKey('server', $results['test_index']);
  $this
    ->assertArrayHasKey('status', $results['test_index']);
  $this
    ->assertSame('test_index', $results['test_index']['id']);
  $this
    ->assertSame('test_server', $results['test_index']['server']);
  $this
    ->assertSame('enabled', (string) $results['test_index']['status']);
  $this
    ->assertSame('second_index', $results['second_index']['id']);
  $this
    ->assertSame('test_server', $results['second_index']['server']);
  $this
    ->assertSame('disabled', (string) $results['second_index']['status']);
  $index = Index::load('test_index');
  $index
    ->delete();
  $results = $this->systemUnderTest
    ->indexListCommand();
  $this
    ->assertIsArray($results);
  $this
    ->assertArrayNotHasKey('test_index', $results);
  $this
    ->assertArrayHasKey('second_index', $results);
}