diff --git a/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php b/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php index 1b4ce03..d18d9f3 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/Views/EntityReferenceRelationshipTest.php @@ -281,6 +281,9 @@ public function testDataTableRelationshipWithLongFieldName() { } } + /** + * Tests group by with optional and empty relationship. + */ public function testGroupByWithEmptyRelationships() { $entities = []; // Create 4 entities with name1 and 3 entities with name2. @@ -321,9 +324,12 @@ public function testGroupByWithEmptyRelationships() { $view = Views::getView('test_entity_reference_group_by_empty_relationships'); $this->executeView($view); $this->assertCount(4, $view->result); + // First three results should contain a reference from EntityTestMul. $this->assertNotEmpty($view->getStyle()->getField(0, 'name_2')); $this->assertNotEmpty($view->getStyle()->getField(1, 'name_2')); $this->assertNotEmpty($view->getStyle()->getField(2, 'name_2')); + // Fourth result has no reference from EntityTestMul hence the output for + // should be empty. $this->assertEqual('', $view->getStyle()->getField(3, 'name_2')); } diff --git a/core/modules/views/src/Plugin/views/field/Field.php b/core/modules/views/src/Plugin/views/field/Field.php index 8eb3b5c..eccaf48 100644 --- a/core/modules/views/src/Plugin/views/field/Field.php +++ b/core/modules/views/src/Plugin/views/field/Field.php @@ -820,7 +820,7 @@ public function getItems(ResultRow $values) { 'settings' => $this->options['settings'], 'label' => 'hidden', ]; - // optional relationships do not provide an entity at all. So we can't use + // Optional relationships may not provide an entity at all. So we can't use // createEntityForGroupBy() for those rows. if (($entity = $this->getEntity($values)) && ($entity = $this->createEntityForGroupBy($entity, $values))) { // Some bundles might not have a specific field, in which case the faked