public function EntityStringIdTest::testUriStringId in Search API 8
Tests indexing of entities with string IDs.
@dataProvider entityStringIdList
Parameters
string $entity_id: An entity ID for which to check indexing.
File
- tests/
src/ Kernel/ Datasource/ EntityStringIdTest.php, line 115
Class
- EntityStringIdTest
- Tests indexing entities that use string IDs.
Namespace
Drupal\Tests\search_api\Kernel\DatasourceCode
public function testUriStringId($entity_id) {
$entity = EntityTestStringId::create([
'id' => $entity_id,
'name' => 'String Test',
'user_id' => $this->container
->get('current_user')
->id(),
]);
$entity
->save();
// Test that the datasource returns the correct item IDs.
$datasource = $this->index
->getDatasource('entity:' . $this->testEntityTypeId);
$datasource_item_ids = $datasource
->getItemIds();
$expected = [
$entity_id . ':und',
];
$this
->assertEquals($expected, $datasource_item_ids, 'Datasource returns correct item ids.');
// Test indexing the new entity.
$this
->assertEquals(0, $this->index
->getTrackerInstance()
->getIndexedItemsCount(), 'The index is empty.');
$this
->assertEquals(1, $this->index
->getTrackerInstance()
->getTotalItemsCount(), 'There is one item to be indexed.');
$this->index
->indexItems();
$this
->assertEquals(1, $this->index
->getTrackerInstance()
->getIndexedItemsCount(), 'One item has been indexed.');
}