public function EntityReferenceAutocreateTestCase::testEditWithAutocomplete in Entityreference Autocreate 7
Enable and configure autocreate, then run the edit steps again.
File
- ./
entityreference_autocreate.test, line 109 - Tests for autocreation of entity references
Class
- EntityReferenceAutocreateTestCase
- Test for Entity Reference admin UI.
Code
public function testEditWithAutocomplete() {
$this
->drupalGet('admin/structure/types');
$this
->assertText('Content types');
$this
->drupalGet('admin/structure/types/manage/song/fields');
$this
->assertText('Manage fields');
// Go straight to the field edit properties.
$this
->drupalGet('admin/structure/types/manage/song/fields/field_artist');
$this
->assertText('Artist');
$this
->assertText('EntityReference Autocreate settings');
// Configure the field to use autocomplete rules.
$edit = array(
'instance[widget][settings][entityreference_autocreate][active]' => TRUE,
'instance[widget][settings][entityreference_autocreate][status]' => -1,
'field[settings][handler]' => 'base',
'field[settings][handler_settings][target_bundles][artist]' => 'artist',
);
$this
->drupalPost(NULL, $edit, t('Save settings'));
// Set the widget to display as a link while we are here.
// Add a node with a non-existing reference.
$edit = array(
'title' => 'I Miss You',
'field_artist[und][0][target_id]' => 'The Rolling Stones',
);
$this
->drupalPost('node/add/' . $this->testBundle, $edit, t('Save'));
$this
->assertText('Song I Miss You has been created.');
// We must assume that "The Rolling Stones" has also been auto-created now.
// Can't check the Artist display in a theme-agnostic way AFAIK.
// But if there is a LINK with the title as the text, that's a good sign.
$this
->clickLink('The Rolling Stones');
}