$this->
assertFalse($field_storage->
isLocked(), 'Field storage is not locked.'
);
$this->
assertSame('string',
$field_storage->
getType(), 'Field is not of correct type.'
);
$this->
assertSame('field_media_test_1',
$field_storage->
getName(), 'Incorrect field name is used.'
);
$this->
assertSame('media',
$field_storage->
getTargetEntityTypeId(), 'Field is not targeting media entities.'
);
// Test field.
$this->
assertTrue($field->
isNew(), 'Field is saved automatically.'
);
$this->
assertSame('field_media_test_1',
$field->
getName(), 'Incorrect field name is used.'
);
$this->
assertSame('string',
$field->
getType(), 'Field is of incorrect type.'
);
$this->
assertTrue($field->
isRequired(), 'Field is not required.'
);
$this->
assertEquals('Test source',
$field->
label(), 'Incorrect label is used.'
);
$this->
assertSame('test_type',
$field->
getTargetBundle(), 'Field is not targeting correct bundle.'
);
// Fields should be automatically saved only when creating the media type
// using the media type creation form. Make sure that they are not saved
// when creating a media type programmatically.
// Drupal\Tests\media\FunctionalJavascript\MediaTypeCreationTest is testing
// form part of the functionality.
$type->
save();
$storage = FieldStorageConfig::
load('media.field_media_test_1'
);
$this->
assertNull($storage, 'Field storage was not saved.'
);
$field = FieldConfig::
load('media.test_type.field_media_test_1'
);
$this->
assertNull($field, 'Field storage was not saved.'
);