You are here

protected function QueryGroupByTest::setupTestEntities in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/QueryGroupByTest.php \Drupal\Tests\views\Kernel\QueryGroupByTest::setupTestEntities()
  2. 9 core/modules/views/tests/src/Kernel/QueryGroupByTest.php \Drupal\Tests\views\Kernel\QueryGroupByTest::setupTestEntities()

Helper method that creates some test entities.

File

core/modules/views/tests/src/Kernel/QueryGroupByTest.php, line 121

Class

QueryGroupByTest
Tests aggregate functionality of views, for example count.

Namespace

Drupal\Tests\views\Kernel

Code

protected function setupTestEntities() {

  // Create 4 entities with name1 and 3 entities with name2.
  $entity_1 = [
    'name' => 'name1',
  ];
  $this->storage
    ->create($entity_1)
    ->save();
  $this->storage
    ->create($entity_1)
    ->save();
  $this->storage
    ->create($entity_1)
    ->save();
  $this->storage
    ->create($entity_1)
    ->save();
  $entity_2 = [
    'name' => 'name2',
  ];
  $this->storage
    ->create($entity_2)
    ->save();
  $this->storage
    ->create($entity_2)
    ->save();
  $this->storage
    ->create($entity_2)
    ->save();
}