protected function JsBase::insertExampleContent in Facets 8
Setup and insert test content.
1 call to JsBase::insertExampleContent()
- JsBase::setUp in tests/
src/ FunctionalJavascript/ JsBase.php
File
- tests/
src/ FunctionalJavascript/ JsBase.php, line 51
Class
- JsBase
- Tests for the JS that transforms widgets into form elements.
Namespace
Drupal\Tests\facets\FunctionalJavascriptCode
protected function insertExampleContent() {
entity_test_create_bundle('item', NULL, 'entity_test_mulrev_changed');
entity_test_create_bundle('article', NULL, 'entity_test_mulrev_changed');
$entity_test_storage = \Drupal::entityTypeManager()
->getStorage('entity_test_mulrev_changed');
$entity_1 = $entity_test_storage
->create([
'name' => 'foo bar baz',
'body' => 'test test',
'type' => 'item',
'keywords' => [
'orange',
],
'category' => 'item_category',
]);
$entity_1
->save();
$entity_2 = $entity_test_storage
->create([
'name' => 'foo test',
'body' => 'bar test',
'type' => 'item',
'keywords' => [
'orange',
'apple',
'grape',
],
'category' => 'item_category',
]);
$entity_2
->save();
$entity_3 = $entity_test_storage
->create([
'name' => 'bar',
'body' => 'test foobar',
'type' => 'item',
]);
$entity_3
->save();
$entity_4 = $entity_test_storage
->create([
'name' => 'foo baz',
'body' => 'test test test',
'type' => 'article',
'keywords' => [
'apple',
'strawberry',
'grape',
],
'category' => 'article_category',
]);
$entity_4
->save();
$entity_5 = $entity_test_storage
->create([
'name' => 'bar baz',
'body' => 'foo',
'type' => 'article',
'keywords' => [
'orange',
'strawberry',
'grape',
'banana',
],
'category' => 'article_category',
]);
$entity_5
->save();
$inserted_entities = \Drupal::entityQuery('entity_test_mulrev_changed')
->count()
->execute();
$this
->assertEquals(5, $inserted_entities, "5 items inserted.");
/** @var \Drupal\search_api\IndexInterface $index */
$index = Index::load('database_search_index');
$indexed_items = $index
->indexItems();
$this
->assertEquals(5, $indexed_items, '5 items indexed.');
}