public function CommandHelperTest::testServerListCommand in Search API 8
Tests the server list command.
@covers ::serverListCommand
File
- tests/
src/ Kernel/ System/ CommandHelperTest.php, line 279
Class
- CommandHelperTest
- Tests Search API functionality that gets executed by console utilities.
Namespace
Drupal\Tests\search_api\Kernel\SystemCode
public function testServerListCommand() {
$result = $this->systemUnderTest
->serverListCommand();
$this
->assertIsArray($result);
$this
->assertCount(1, $result);
$this
->assertArrayHasKey('test_server', $result);
$this
->assertSame('test_server', $result['test_server']['id']);
$this
->assertSame('Pink pony server', $result['test_server']['name']);
$this
->assertSame('enabled', (string) $result['test_server']['status']);
/** @var \Drupal\search_api\ServerInterface $server */
$server = Server::load('test_server');
$server
->setStatus(FALSE);
$server
->save();
$result = $this->systemUnderTest
->serverListCommand();
$this
->assertIsArray($result);
$this
->assertCount(1, $result);
$this
->assertArrayHasKey('test_server', $result);
$this
->assertSame('test_server', $result['test_server']['id']);
$this
->assertSame('Pink pony server', $result['test_server']['name']);
$this
->assertSame('disabled', (string) $result['test_server']['status']);
$server
->delete();
$this
->expectException(ConsoleException::class);
$this->systemUnderTest
->serverListCommand();
}