protected function EntityQueryAggregateTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::setUp()
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::setUp()
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityQueryAggregateTest.php, line 37
Class
- EntityQueryAggregateTest
- Tests the Entity Query Aggregation API.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function setUp() : void {
parent::setUp();
$this->entityStorage = $this->entityTypeManager
->getStorage('entity_test');
// Add some fieldapi fields to be used in the test.
for ($i = 1; $i <= 2; $i++) {
$field_name = 'field_test_' . $i;
FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'integer',
'cardinality' => 2,
])
->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
])
->save();
}
$entity = $this->entityStorage
->create([
'id' => 1,
'user_id' => 1,
'field_test_1' => 1,
'field_test_2' => 2,
]);
$entity
->enforceIsNew();
$entity
->save();
$entity = $this->entityStorage
->create([
'id' => 2,
'user_id' => 2,
'field_test_1' => 1,
'field_test_2' => 7,
]);
$entity
->enforceIsNew();
$entity
->save();
$entity = $this->entityStorage
->create([
'id' => 3,
'user_id' => 2,
'field_test_1' => 2,
'field_test_2' => 1,
]);
$entity
->enforceIsNew();
$entity
->save();
$entity = $this->entityStorage
->create([
'id' => 4,
'user_id' => 2,
'field_test_1' => 2,
'field_test_2' => 8,
]);
$entity
->enforceIsNew();
$entity
->save();
$entity = $this->entityStorage
->create([
'id' => 5,
'user_id' => 3,
'field_test_1' => 2,
'field_test_2' => 2,
]);
$entity
->enforceIsNew();
$entity
->save();
$entity = $this->entityStorage
->create([
'id' => 6,
'user_id' => 3,
'field_test_1' => 3,
'field_test_2' => 8,
]);
$entity
->enforceIsNew();
$entity
->save();
}