You are here

protected function ExampleContentTrait::insertExampleContent in Facets 8

Creates several test entities.

11 calls to ExampleContentTrait::insertExampleContent()
AggregatedFieldTest::setUp in tests/src/Functional/AggregatedFieldTest.php
BreadcrumbIntegrationTest::setUp in tests/src/Functional/BreadcrumbIntegrationTest.php
FacetsUrlGeneratorTest::setUp in tests/src/Functional/FacetsUrlGeneratorTest.php
IntegrationTest::setUp in tests/src/Functional/IntegrationTest.php
IntegrationTest::setUp in modules/facets_summary/tests/src/Functional/IntegrationTest.php

... See full list

2 methods override ExampleContentTrait::insertExampleContent()
HierarchicalFacetIntegrationTest::insertExampleContent in tests/src/Functional/HierarchicalFacetIntegrationTest.php
Creates several test entities with the term-reference field.
HierarchicalFacetIntegrationTest::insertExampleContent in modules/facets_summary/tests/src/Functional/HierarchicalFacetIntegrationTest.php
Creates several test entities with the term-reference field.

File

tests/src/Functional/ExampleContentTrait.php, line 30

Class

ExampleContentTrait
Contains helpers to create data that can be used by tests.

Namespace

Drupal\Tests\facets\Functional

Code

protected function insertExampleContent() {
  $count = \Drupal::entityQuery('entity_test_mulrev_changed')
    ->count()
    ->execute();
  $entity_test_storage = \Drupal::entityTypeManager()
    ->getStorage('entity_test_mulrev_changed');
  $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_mulrev_changed')
    ->count()
    ->execute() - $count;
  $this
    ->assertEquals($count, 5, "{$count} items inserted.");
}