protected function WebTestBase::insertExampleContent in Core Views Facets 8
Creates several test entities.
1 call to WebTestBase::insertExampleContent()
- CoreViewsIntegrationTest::setUp in tests/
src/ Functional/ CoreViewsIntegrationTest.php
File
- tests/
src/ Functional/ WebTestBase.php, line 127
Class
- WebTestBase
- Provides the base class for web tests for Search API.
Namespace
Drupal\Tests\core_views_facets\FunctionalCode
protected function insertExampleContent() {
$count = \Drupal::entityQuery('entity_test')
->count()
->execute();
$entity_test_storage = \Drupal::entityTypeManager()
->getStorage('entity_test');
$this->entities[1] = $entity_test_storage
->create([
'name' => 'foo bar baz',
'body' => 'test test',
'type' => 'item',
'keywords' => [
'orange',
],
'category' => 'item_category',
]);
$this->entities[1]
->save();
$this->entities[2] = $entity_test_storage
->create([
'name' => 'foo test',
'body' => 'bar test',
'type' => 'item',
'keywords' => [
'orange',
'apple',
'grape',
],
'category' => 'item_category',
]);
$this->entities[2]
->save();
$this->entities[3] = $entity_test_storage
->create([
'name' => 'bar',
'body' => 'test foobar',
'type' => 'item',
]);
$this->entities[3]
->save();
$this->entities[4] = $entity_test_storage
->create([
'name' => 'foo baz',
'body' => 'test test test',
'type' => 'article',
'keywords' => [
'apple',
'strawberry',
'grape',
],
'category' => 'article_category',
]);
$this->entities[4]
->save();
$this->entities[5] = $entity_test_storage
->create([
'name' => 'bar baz',
'body' => 'foo',
'type' => 'article',
'keywords' => [
'orange',
'strawberry',
'grape',
'banana',
],
'category' => 'article_category',
]);
$this->entities[5]
->save();
$count = \Drupal::entityQuery('entity_test')
->count()
->execute() - $count;
$this
->assertEquals($count, 5, "{$count} items inserted.");
}