trait FieldUiTestTrait (View source)

deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Tests\field_ui\Traits\FieldUiTestTrait. See https://www.drupal.org/node/3001664

Provides common functionality for the Field UI test classes.

Methods

fieldUIAddNewField(string $bundle_path, string $field_name, string $label = NULL, string $field_type = 'test_field', array $storage_edit = [], array $field_edit = [])

Creates a new field through the Field UI.

fieldUIAddExistingField(string $bundle_path, string $existing_storage_name, string $label = NULL, array $field_edit = [])

Adds an existing field through the Field UI.

fieldUIDeleteField(string $bundle_path, string $field_name, string $label, string $bundle_label)

Deletes a field through the Field UI.

Details

fieldUIAddNewField(string $bundle_path, string $field_name, string $label = NULL, string $field_type = 'test_field', array $storage_edit = [], array $field_edit = [])

Creates a new field through the Field UI.

Parameters

string $bundle_path

Admin path of the bundle that the new field is to be attached to.

string $field_name

The field name of the new field storage.

string $label

(optional) The label of the new field. Defaults to a random string.

string $field_type

(optional) The field type of the new field storage. Defaults to 'test_field'.

array $storage_edit

(optional) $edit parameter for drupalPostForm() on the second step ('Storage settings' form).

array $field_edit

(optional) $edit parameter for drupalPostForm() on the third step ('Field settings' form).

fieldUIAddExistingField(string $bundle_path, string $existing_storage_name, string $label = NULL, array $field_edit = [])

Adds an existing field through the Field UI.

Parameters

string $bundle_path

Admin path of the bundle that the field is to be attached to.

string $existing_storage_name

The name of the existing field storage for which we want to add a new field.

string $label

(optional) The label of the new field. Defaults to a random string.

array $field_edit

(optional) $edit parameter for drupalPostForm() on the second step ('Field settings' form).

fieldUIDeleteField(string $bundle_path, string $field_name, string $label, string $bundle_label)

Deletes a field through the Field UI.

Parameters

string $bundle_path

Admin path of the bundle that the field is to be deleted from.

string $field_name

The name of the field.

string $label

The label of the field.

string $bundle_label

The label of the bundle.