protected function MultipleValuesWidgetTest::setupNestedMultipleForm in Inline Entity Form 7
Set up the ief_test_nested1 node add form.
Sets the nested fields' required settings. Gets the form. Opens the inline entity forms if they are not required.
Parameters
boolean $required: Whether the fields are required.
array $permissions: (optional) Permissions to sign testing user in with. You may pass in an empty array (default) to use the all the permissions necessary create and edit nodes on the form.
3 calls to MultipleValuesWidgetTest::setupNestedMultipleForm()
- MultipleValuesWidgetTest::testNestedEntityCreateAccess in tests/
multiple_values_widget.test - Tests entity create access is correct on nested IEF forms.
- MultipleValuesWidgetTest::testNestedEntityCreationWithDifferentBundlesAjaxSubmit in tests/
multiple_values_widget.test - Tests the entity creation with different bundles nested in each other.
- MultipleValuesWidgetTest::testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit in tests/
multiple_values_widget.test - Tests the entity creation with different bundles nested in each other.
File
- tests/
multiple_values_widget.test, line 592
Class
- MultipleValuesWidgetTest
- IEF multiple values field widget tests.
Code
protected function setupNestedMultipleForm($required, $permissions = array()) {
$this
->drupalLogin($this->administrator_user);
$edit = array(
'instance[required]' => $required,
);
$this
->drupalPost('admin/structure/types/manage/ief-test-nested1/fields/field_test_ref_nested1', $edit, t('Save settings'));
$this
->drupalPost('admin/structure/types/manage/ief-test-nested2/fields/field_test_ref_nested2', $edit, t('Save settings'));
if (!$permissions) {
$permissions = array(
'create ief_test_nested1 content',
'create ief_test_nested2 content',
'create ief_test_nested3 content',
'edit any ief_test_nested1 content',
'edit any ief_test_nested2 content',
'edit any ief_test_nested3 content',
);
}
$this->user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->user);
$this
->drupalGet('node/add/ief-test-nested1');
if (!$required) {
// Open inline forms if not required.
if (in_array('create ief_test_nested2 content', $permissions)) {
$this
->drupalPostAjax(NULL, array(), $this
->getButtonName('//input[@type="submit" and @value="Add new node 2"]'));
}
if (in_array('create ief_test_nested3 content', $permissions)) {
$this
->drupalPostAjax(NULL, array(), $this
->getButtonName('//input[@type="submit" and @value="Add new node 3"]'));
}
}
}