1 entityreference.field.test | protected EntityReferenceFieldTestCase::createEntityReferenceField($field_name, $label = 'Test label') |
Creates an entity reference field.
Parameters
string $field_name: The name of the field.
string $label: The label of the field.
File
- core/
modules/ entityreference/ tests/ entityreference.field.test, line 51
Class
- EntityReferenceFieldTestCase
- Tests for the Entity Reference field.
Code
protected function createEntityReferenceField($field_name, $label = 'Test label') {
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
// First step: 'Add new field' on the 'Manage fields' page.
$this->backdropPost($bundle_path . '/fields', array(
'fields[_add_new_field][label]' => $label,
'fields[_add_new_field][field_name]' => $field_name,
'fields[_add_new_field][type]' => 'entityreference',
'fields[_add_new_field][widget_type]' => 'entityreference_autocomplete',
), t('Save'));
// Second step: 'Instance settings' form.
$this->backdropPost(NULL, array(), t('Save field settings'));
// Third step: confirm.
$this->backdropPost(NULL, array(), t('Save settings'));
}