protected function IntegrationTest::createServer in Search API 8
Tests creating a search server via the UI.
Parameters
string $server_id: The ID of the server to create.
2 calls to IntegrationTest::createServer()
- IntegrationTest::changeIndexServer in tests/
src/ Functional/ IntegrationTest.php - Changes the index's server and checks if it reacts correctly.
- IntegrationTest::testFramework in tests/
src/ Functional/ IntegrationTest.php - Tests various operations via the Search API's admin UI.
File
- tests/
src/ Functional/ IntegrationTest.php, line 200
Class
- IntegrationTest
- Tests the overall functionality of the Search API framework and admin UI.
Namespace
Drupal\Tests\search_api\FunctionalCode
protected function createServer($server_id = '_test_server') {
$this->serverId = $server_id;
$server_name = 'Search API &{}<>! Server';
$server_description = 'A >server< used for testing &.';
$settings_path = 'admin/config/search/search-api/add-server';
$this
->drupalGet($settings_path);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextNotContains('No UI backend');
$edit = [
'name' => '',
'status' => 1,
'description' => 'A server used for testing.',
'backend' => $this->serverBackend,
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains(new FormattableMarkup('@name field is required.', [
'@name' => 'Server name',
]));
$edit = [
'name' => $server_name,
'status' => 1,
'description' => $server_description,
'backend' => $this->serverBackend,
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains(new FormattableMarkup('@name field is required.', [
'@name' => 'Machine-readable name',
]));
$edit += [
'id' => $this->serverId,
];
$this
->configureBackendAndSave($edit);
$this
->assertSession()
->pageTextContains('The server was successfully saved.');
$this
->assertSession()
->addressEquals('admin/config/search/search-api/server/' . $this->serverId);
$this
->assertHtmlEscaped($server_name);
$this
->assertHtmlEscaped($server_description);
$this
->drupalGet('admin/config/search/search-api');
$this
->assertHtmlEscaped($server_name);
$this
->assertHtmlEscaped($server_description);
}