function ManageFieldsTest::testEntityReferenceToNonBundleableEntity
Same name in other branches
- 10 core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php \Drupal\Tests\field_ui\Functional\ManageFieldsTest::testEntityReferenceToNonBundleableEntity()
Tests creating entity reference field to non-bundleable entity type.
File
-
core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsTest.php, line 309
Class
- ManageFieldsTest
- Tests the Manage Display page of a fieldable entity type.
Namespace
Drupal\Tests\field_ui\FunctionalCode
public function testEntityReferenceToNonBundleableEntity() : void {
$type = $this->drupalCreateContentType([
'name' => 'kittens',
'type' => 'kittens',
]);
$bundle_path = 'admin/structure/types/manage/' . $type->id();
$field_name = 'field_user_reference';
$field_edit = [
'set_default_value' => '1',
"default_value_input[{$field_name}][0][target_id]" => $this->adminUser
->label() . ' (' . $this->adminUser
->id() . ')',
];
$this->fieldUIAddNewField($bundle_path, 'user_reference', NULL, 'field_ui:entity_reference:user', [], $field_edit);
$field = FieldConfig::loadByName('node', 'kittens', $field_name);
$this->assertEquals([
[
'target_id' => $this->adminUser
->id(),
],
], $field->getDefaultValue(User::create([
'name' => '1337',
])));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.