public function ServerStorageTest::serverCreate in Search API 8
Tests whether creating a server works correctly.
Return value
\Drupal\search_api\ServerInterface The newly created search server.
1 call to ServerStorageTest::serverCreate()
- ServerStorageTest::testServerCrud in tests/
src/ Kernel/ Server/ ServerStorageTest.php - Tests all CRUD operations as a queue of operations.
File
- tests/
src/ Kernel/ Server/ ServerStorageTest.php, line 68
Class
- ServerStorageTest
- Tests whether the storage of search servers works correctly.
Namespace
Drupal\Tests\search_api\Kernel\ServerCode
public function serverCreate() {
$server_data = [
'id' => 'test_server',
'name' => 'Test server',
'backend' => 'search_api_test',
];
$server = $this->storage
->create($server_data);
$this
->assertInstanceOf(ServerInterface::class, $server, 'The newly created entity is a Search API Server.');
$server
->save();
$key = 'search_api_test.methods_called.' . $server
->id();
$methods_called = \Drupal::state()
->get($key, []);
$this
->assertNotContains('preUpdate', $methods_called, 'Backend::preUpdate() not called for initial save.');
$this
->assertNotContains('postUpdate', $methods_called, 'Backend::postUpdate() not called for initial save.');
return $server;
}