protected function IntegrationTest::deleteServer in Search API 8
Tests deleting a search server via the UI.
1 call to IntegrationTest::deleteServer()
- 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 1573
Class
- IntegrationTest
- Tests the overall functionality of the Search API framework and admin UI.
Namespace
Drupal\Tests\search_api\FunctionalCode
protected function deleteServer() {
$server = Server::load($this->serverId);
// Load confirmation form.
$this
->drupalGet('admin/config/search/search-api/server/' . $this->serverId . '/delete');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains(new FormattableMarkup('Are you sure you want to delete the search server %name?', [
'%name' => $server
->label(),
]));
$this
->assertSession()
->pageTextContains('Deleting a server will disable all its indexes and their searches.');
// Confirm deletion.
$this
->submitForm([], 'Delete');
$this
->assertSession()
->responseContains(new FormattableMarkup('The search server %name has been deleted.', [
'%name' => $server
->label(),
]));
$this
->assertNull(Server::load($this->serverId), 'Server could not be found anymore.');
$this
->assertSession()
->addressEquals('admin/config/search/search-api');
// Confirm that the index hasn't been deleted.
$this->indexStorage
->resetCache([
$this->indexId,
]);
/** @var \Drupal\search_api\IndexInterface $index */
$index = $this->indexStorage
->load($this->indexId);
$this
->assertInstanceOf(IndexInterface::class, $index, 'The index associated with the server was not deleted.');
$this
->assertFalse($index
->status(), 'The index associated with the server was disabled.');
$this
->assertNull($index
->getServerId(), 'The index was removed from the server.');
}