public function ReferencedEntitiesReindexingTest::setUp in Search API 8
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ Datasource/ ReferencedEntitiesReindexingTest.php, line 44
Class
- ReferencedEntitiesReindexingTest
- Tests that changes in related entities are correctly tracked.
Namespace
Drupal\Tests\search_api\Kernel\DatasourceCode
public function setUp() {
parent::setUp();
$this
->installSchema('search_api', [
'search_api_item',
]);
$this
->installSchema('node', [
'node_access',
]);
$this
->installEntitySchema('user');
$this
->installEntitySchema('node');
$this
->installEntitySchema('search_api_task');
$this
->installConfig([
'search_api',
'search_api_test_example_content_references',
]);
// Do not use a batch for tracking the initial items after creating an
// index when running the tests via the GUI. Otherwise, it seems Drupal's
// Batch API gets confused and the test fails.
if (!Utility::isRunningInCli()) {
\Drupal::state()
->set('search_api_use_tracking_batch', FALSE);
}
Server::create([
'id' => 'server',
'backend' => 'search_api_test',
])
->save();
$this->index = Index::create([
'id' => 'index',
'tracker_settings' => [
'default' => [],
],
'datasource_settings' => [
'entity:node' => [
'bundles' => [
'default' => FALSE,
'selected' => [
'grandparent',
'parent',
],
],
],
'entity:user' => [],
],
'server' => 'server',
'field_settings' => [
'child_indexed' => [
'label' => 'Child > Indexed',
'datasource_id' => 'entity:node',
'property_path' => 'entity_reference:entity:indexed',
'type' => 'text',
],
'grandchild_indexed' => [
'label' => 'Parent > Child > Indexed',
'datasource_id' => 'entity:node',
'property_path' => 'parent_reference:entity:entity_reference:entity:indexed',
'type' => 'text',
],
],
]);
$this->index
->save();
}