function MediaMappingUpdateTest::testMediaMappingUpdate
Tests updating Media types using source field in meta mappings.
See also
media_post_update_remove_mappings_targeting_source_field()
File
-
core/
modules/ media/ tests/ src/ Functional/ Update/ MediaMappingUpdateTest.php, line 52
Class
- MediaMappingUpdateTest
- Tests update functions for the Media module.
Namespace
Drupal\Tests\media\Functional\UpdateCode
public function testMediaMappingUpdate() : void {
$media_type = $this->createMediaType('image', [
'id' => 'invalid_mapping',
]);
$source_field_name = $media_type->getSource()
->getSourceFieldDefinition($media_type)
->getName();
$field_map = $media_type->getFieldMap();
$field_map[File::METADATA_ATTRIBUTE_MIME] = $source_field_name;
$this->config($media_type->getConfigDependencyName())
->set('field_map', $field_map)
->save();
$this->runUpdates();
$this->container
->get('entity_type.manager')
->getStorage('media_type')
->resetCache([
'invalid_mapping',
]);
$field_map = MediaType::load('invalid_mapping')?->getFieldMap();
$this->assertIsArray($field_map);
$this->assertNotContains($source_field_name, $field_map);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.