protected function EckTestHelper::addReferenceFieldToNode in Entity Construction Kit (ECK) 7.2
Add a reference field to a content type that points to an ECK entity type.
Parameters
string $entity_type: The entity type to add the reference field to; defaults to "test_entity".
1 call to EckTestHelper::addReferenceFieldToNode()
- EckEntityTranslationTest::testTranslations in tests/
EckEntityTranslationTest.test - Test translating an entity type.
File
- tests/
EckTestHelper.test, line 313 - The EckTestHelper class.
Class
- EckTestHelper
- Helper logic for the other ECK tests.
Code
protected function addReferenceFieldToNode($entity_type = 'test_entity') {
$this
->drupalGet('admin/structure/types/manage/page/fields');
$this
->assertResponse(200);
$edit = array(
'fields[_add_new_field][label]' => 'Reference',
'fields[_add_new_field][weight]' => 1,
'fields[_add_new_field][field_name]' => 'reference',
'fields[_add_new_field][type]' => 'entityreference',
'fields[_add_new_field][widget_type]' => 'entityreference_autocomplete',
);
foreach ($edit as $field_name => $value) {
$this
->assertFieldByName($field_name);
}
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertResponse(200);
$this
->assertText('The entity type that can be referenced through this field.');
$edit = array(
'field[settings][target_type]' => $entity_type,
);
$this
->drupalPost(NULL, $edit, t('Save field settings'));
$this
->assertResponse(200);
$this
->assertText('Updated field Reference field settings.');
$edit = array(
'field[cardinality]' => -1,
);
$this
->drupalPost(NULL, $edit, t('Save settings'));
$this
->assertResponse(200);
$this
->assertText('Saved Reference configuration.');
// Configure the display settings to output a rendered entity.
$this
->drupalGet('admin/structure/types/manage/page/display');
$this
->assertResponse(200);
$this
->assertText(t('Here, you can define which fields are shown and hidden when Basic page content is displayed in each view mode, and define how the fields are displayed in each view mode.'));
$edit = array(
'fields[field_reference][type]' => 'entityreference_entity_view',
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertResponse(200);
$this
->assertText(t('Your settings have been saved.'));
}