You are here

public function ServerChangesTest::testAddRemoveIndex in Search API 8

Tests adding and removing of indexes.

File

tests/src/Kernel/Server/ServerChangesTest.php, line 107

Class

ServerChangesTest
Tests whether changes for the server are processed correctly.

Namespace

Drupal\Tests\search_api\Kernel\Server

Code

public function testAddRemoveIndex() {
  $this->index
    ->save();
  $this->index
    ->setServer(NULL)
    ->save();
  $this->index
    ->setServer($this->server)
    ->enable()
    ->save();
  $this->server
    ->disable()
    ->save();
  $this->index
    ->setServer(NULL)
    ->save();
  $this->server
    ->enable()
    ->save();
  $this->index
    ->setServer($this->server)
    ->enable()
    ->save();
  $this->index
    ->delete();
  $methods = $this
    ->getCalledMethods('backend');
  $methods = array_intersect($methods, [
    'addIndex',
    'removeIndex',
  ]);
  $expected = [
    'addIndex',
    'removeIndex',
    'addIndex',
    'removeIndex',
    'addIndex',
    'removeIndex',
  ];
  $this
    ->assertEquals($expected, array_values($methods));
}