protected function EntityReferenceFieldTestCase::createEntityReferenceField in Entity reference 7
Creates an entity reference field.
Parameters
string $field_name: The name of the field.
string $label: The label of the field.
1 call to EntityReferenceFieldTestCase::createEntityReferenceField()
- EntityReferenceFieldTestCase::testShowLinksSetting in tests/
entityreference.field.test - Tests the "Show links" setting for the field formatter "Rendered entity".
File
- tests/
entityreference.field.test, line 56
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
->drupalPost($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
->drupalPost(NULL, array(), t('Save field settings'));
// Third step: confirm.
$this
->drupalPost(NULL, array(), t('Save settings'));
}