public function EntityStringIdTest::setUp in Search API 8
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ Datasource/ EntityStringIdTest.php, line 64
Class
- EntityStringIdTest
- Tests indexing entities that use string IDs.
Namespace
Drupal\Tests\search_api\Kernel\DatasourceCode
public function setUp() {
parent::setUp();
$this
->installSchema('search_api', [
'search_api_item',
]);
$this
->installEntitySchema('entity_test_string_id');
$this
->installEntitySchema('search_api_task');
$this
->installConfig('search_api');
// 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);
}
// Create a test server.
$this->server = Server::create([
'name' => 'Test Server',
'id' => 'test_server',
'status' => 1,
'backend' => 'search_api_test',
]);
$this->server
->save();
// Create a test index.
$this->index = Index::create([
'name' => 'Test Index',
'id' => 'test_index',
'status' => 1,
'datasource_settings' => [
'entity:' . $this->testEntityTypeId => [],
],
'tracker_settings' => [
'default' => [],
],
'server' => $this->server
->id(),
'options' => [
'index_directly' => FALSE,
],
]);
$this->index
->save();
}