$entity = EntityTestMul::
create([ 'name' => 'name3',
]);
$entity->field_data_test_unlimited->target_id =
$entities[0
]->
id();
$entity->
save();
$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->
assertEquals('',
$view->
getStyle()->
getField(3, 'name_2'
));
$fields =
$view->field;
// Check getValue for reference with a value. The first 3 rows reference
// EntityTestMul, so have value 'name1'.
$this->
assertEquals('name1',
$fields['name_2'
]->
getValue($view->result
[0
]));
$this->
assertEquals('name1',
$fields['name_2'
]->
getValue($view->result
[1
]));