public function CustomDataTypesTest::setUp in Search API 8
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ System/ CustomDataTypesTest.php, line 59
Class
- CustomDataTypesTest
- Tests custom data types integration.
Namespace
Drupal\Tests\search_api\Kernel\SystemCode
public function setUp() {
parent::setUp();
$this
->installSchema('search_api', [
'search_api_item',
]);
$this
->installSchema('user', [
'users_data',
]);
$this
->installEntitySchema('entity_test_mulrev_changed');
$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);
}
$this
->installConfig([
'search_api_test_db',
]);
// Create test entities.
$this->entities[1] = EntityTestMulRevChanged::create([
'name' => 'foo bar baz föö smile' . json_decode('"\\u1F601"'),
'body' => 'test test case Case casE',
'type' => 'entity_test_mulrev_changed',
'keywords' => [
'Orange',
'orange',
'örange',
'Orange',
],
'category' => 'item_category',
]);
$this->entities[2] = EntityTestMulRevChanged::create([
'name' => 'foo bar baz föö smile',
'body' => 'test test case Case casE',
'type' => 'entity_test_mulrev_changed',
'keywords' => [
'strawberry',
'llama',
],
'category' => 'item_category',
]);
$this->entities[1]
->save();
$this->entities[2]
->save();
// Create a test server.
$this->server = Server::create([
'name' => 'Server test ~',
'id' => 'test',
'status' => 1,
'backend' => 'search_api_test',
]);
$this->server
->save();
// Set the server (determines the supported data types) and remove all
// non-base fields from the index (since their config isn't installed).
$this->index = Index::load('database_search_index');
$this->index
->setServer($this->server)
->removeField('body')
->removeField('keywords')
->removeField('category')
->removeField('width');
}