protected function IntegrationTest::checkIndexActions in Search API 8
Tests the various actions on the index status form.
2 calls to IntegrationTest::checkIndexActions()
- 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 1522
Class
- IntegrationTest
- Tests the overall functionality of the Search API framework and admin UI.
Namespace
Drupal\Tests\search_api\FunctionalCode
protected function checkIndexActions() {
$assert_session = $this
->assertSession();
$index = $this
->getIndex();
$tracker = $index
->getTrackerInstance();
$label = $index
->label();
$this
->indexItems();
// Manipulate the tracking information to make it slightly off (so
// rebuilding the tracker will be necessary).
$deleted = \Drupal::database()
->delete('search_api_item')
->condition('index_id', $index
->id())
->condition('item_id', Utility::createCombinedId('entity:node', '2:en'))
->execute();
$this
->assertEquals(1, $deleted);
$manipulated_items_count = \Drupal::entityQuery('node')
->accessCheck(FALSE)
->count()
->execute() - 1;
$this
->assertEquals($manipulated_items_count, $tracker
->getIndexedItemsCount());
$this
->assertEquals($manipulated_items_count, $tracker
->getTotalItemsCount());
$this
->assertEquals($manipulated_items_count + 1, $this
->countItemsOnServer());
$this
->drupalGet($this
->getIndexPath('reindex'));
$this
->submitForm([], 'Confirm');
$assert_session
->pageTextContains("The search index {$label} was successfully queued for reindexing.");
$this
->assertEquals(0, $tracker
->getIndexedItemsCount());
$this
->assertEquals($manipulated_items_count, $tracker
->getTotalItemsCount());
$this
->assertEquals($manipulated_items_count + 1, $this
->countItemsOnServer());
$this
->indexItems();
$this
->drupalGet($this
->getIndexPath('clear'));
$this
->submitForm([], 'Confirm');
$assert_session
->pageTextContains("All items were successfully deleted from search index {$label}.");
$this
->assertEquals(0, $tracker
->getIndexedItemsCount());
$this
->assertEquals($manipulated_items_count, $tracker
->getTotalItemsCount());
$this
->assertEquals(0, $this
->countItemsOnServer());
$this
->indexItems();
$this
->drupalGet($this
->getIndexPath('rebuild-tracker'));
$this
->submitForm([], 'Confirm');
$assert_session
->pageTextContains("The tracking information for search index {$label} will be rebuilt.");
$this
->assertEquals(0, $tracker
->getIndexedItemsCount());
$this
->assertEquals($manipulated_items_count + 1, $tracker
->getTotalItemsCount());
$this
->assertEquals($manipulated_items_count, $this
->countItemsOnServer());
$this
->indexItems();
}