public function QueryGroupByTest::testGroupByWithFieldsNotExistingOnBundle in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/QueryGroupByTest.php \Drupal\Tests\views\Kernel\QueryGroupByTest::testGroupByWithFieldsNotExistingOnBundle()
- 10 core/modules/views/tests/src/Kernel/QueryGroupByTest.php \Drupal\Tests\views\Kernel\QueryGroupByTest::testGroupByWithFieldsNotExistingOnBundle()
Tests groupby with a non-existent field on some bundle.
File
- core/
modules/ views/ tests/ src/ Kernel/ QueryGroupByTest.php, line 299
Class
- QueryGroupByTest
- Tests aggregate functionality of views, for example count.
Namespace
Drupal\Tests\views\KernelCode
public function testGroupByWithFieldsNotExistingOnBundle() {
$field_storage = FieldStorageConfig::create([
'type' => 'integer',
'field_name' => 'field_test',
'cardinality' => 4,
'entity_type' => 'entity_test_mul',
]);
$field_storage
->save();
$field = FieldConfig::create([
'field_name' => 'field_test',
'entity_type' => 'entity_test_mul',
'bundle' => 'entity_test_mul',
]);
$field
->save();
$entities = [];
$entity = EntityTestMul::create([
'field_test' => [
1,
],
'type' => 'entity_test_mul',
]);
$entity
->save();
$entities[] = $entity;
$entity = EntityTestMul::create([
'type' => 'entity_test_mul2',
]);
$entity
->save();
$entities[] = $entity;
$view = Views::getView('test_group_by_field_not_within_bundle');
$this
->executeView($view);
$this
->assertCount(2, $view->result);
// The first result is coming from entity_test_mul2, so no field could be
// rendered.
$this
->assertEquals('', $view
->getStyle()
->getField(0, 'field_test'));
// The second result is coming from entity_test_mul, so its field value
// could be rendered.
$this
->assertEquals('1', $view
->getStyle()
->getField(1, 'field_test'));
}