protected function IntegrationTest::changeIndexServer in Search API 8
Changes the index's server and checks if it reacts correctly.
The expected behavior is that, when an index's server is changed, all of the index's items should be removed from the previous server and marked as "unindexed" in the tracker.
2 calls to IntegrationTest::changeIndexServer()
- IntegrationTest::testFramework in tests/
src/ Functional/ IntegrationTest.php - Tests various operations via the Search API's admin UI.
- IntegrationTest::testIntegerIndex in tests/
src/ Functional/ IntegrationTest.php - Tests what happens when an index has an integer as id/label.
File
- tests/
src/ Functional/ IntegrationTest.php, line 1433
Class
- IntegrationTest
- Tests the overall functionality of the Search API framework and admin UI.
Namespace
Drupal\Tests\search_api\FunctionalCode
protected function changeIndexServer() {
$node_count = \Drupal::entityQuery('node')
->accessCheck(FALSE)
->count()
->execute();
$this
->assertEquals($node_count, $this
->countTrackedItems(), 'All nodes are correctly tracked by the index.');
// Index all remaining items on the index.
$this
->indexItems();
$remaining_items = $this
->countRemainingItems();
$this
->assertEquals(0, $remaining_items, 'All items have been successfully indexed.');
// Create a second search server.
$this
->createServer('test_server_2');
// Change the index's server to the new one.
$settings_path = $this
->getIndexPath('edit');
$edit = [
'server' => $this->serverId,
];
$this
->drupalGet($settings_path);
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('The index was successfully saved.');
// After saving the new index, we should have called reindex.
$remaining_items = $this
->countRemainingItems();
$this
->assertEquals($node_count, $remaining_items, 'All items still need to be indexed.');
}