// Create an entity reference field.
$handler_settings =
[ 'view' =>
[ 'view_name' => 'test_entity_reference',
'display_name' => 'entity_reference_1',
],
];
$this->
createEntityReferenceField('entity_test', 'test_bundle', 'test_field',
$this->
randomString(), 'node', 'views',
$handler_settings);
$field_config = FieldConfig::
loadByName('entity_test', 'test_bundle', 'test_field'
);
$this->selectionHandler =
$this->container->
get('plugin.manager.entity_reference_selection'
)->
getSelectionHandler($field_config);
} /**
* Tests the selection handler.
*/
public function testSelectionHandler() { // Tests the selection handler.
$this->
assertResults($this->selectionHandler->
getReferenceableEntities());
// Add a relationship to the view.
$view = Views::
getView('test_entity_reference'
);