$this->
assertEquals($field_name,
$instance->
getName(),
new FormattableMarkup('Instance name is @name',
['@name' =>
$field_name]));
$this->
assertEquals('Jenny',
$instance->
getFieldDefinition()->
getLabel(), 'Instance label is Jenny'
);
$this->
assertEquals([['value' => 8675309
]],
$instance->
getFieldDefinition()->
getDefaultValue($entity), 'Instance default_value is 8675309'
);
} /**
* Tests all field items provide an existing main property.
*/
public function testMainProperty() { // Let's enable all Drupal modules in Drupal core, so we test any field
// type plugin.
$this->
enableAllCoreModules();
/** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager */
$field_type_manager = \Drupal::
service('plugin.manager.field.field_type'
);
foreach ($field_type_manager->
getDefinitions() as $plugin_id =>
$definition) { $class =
$definition['class'
];
$property =
$class::
mainPropertyName();
if ($property === NULL
) { continue;
} $storage_definition = BaseFieldDefinition::
create($plugin_id);
$property_definitions =
$class::
propertyDefinitions($storage_definition);