diff -u b/core/modules/media/src/Plugin/media/Handler/Image.php b/core/modules/media/src/Plugin/media/Handler/Image.php --- b/core/modules/media/src/Plugin/media/Handler/Image.php +++ b/core/modules/media/src/Plugin/media/Handler/Image.php @@ -128,7 +128,7 @@ } // Get the file, image and EXIF data. - $file = $this->getSourceFieldValue($media); + $file = $this->getSourceFile($media); $uri = $file->getFileUri(); $image = $this->imageFactory->get($uri); @@ -196,7 +196,7 @@ * {@inheritdoc} */ public function getThumbnail(MediaInterface $media) { - return $this->getSourceFieldValue($media)->getFileUri(); + return $this->getSourceFile($media)->getFileUri(); } /** diff -u b/core/modules/media/tests/src/FunctionalJavascript/ImageTest.php b/core/modules/media/tests/src/FunctionalJavascript/ImageTest.php --- b/core/modules/media/tests/src/FunctionalJavascript/ImageTest.php +++ b/core/modules/media/tests/src/FunctionalJavascript/ImageTest.php @@ -2,12 +2,10 @@ namespace Drupal\Tests\media\FunctionalJavascript; -use Drupal\field\Entity\FieldConfig; -use Drupal\field\Entity\FieldStorageConfig; use Drupal\media\Entity\Media; /** - * Tests for Image Media type. + * Tests the image handler plugin. * * @package Drupal\Tests\media\FunctionalJavascript * @@ -16,54 +14,6 @@ class ImageTest extends MediaHandlerTestBase { /** - * Create storage and field instance, attached to a given media type. - * - * @param string $field_name - * The field name. - * @param string $field_type - * The field storage type. - * @param string $type_id - * The media type machine name. - */ - protected function createMediaField($field_name, $field_type, $type_id) { - $storage = FieldStorageConfig::create([ - 'field_name' => $field_name, - 'entity_type' => 'media', - 'type' => $field_type, - ]); - $storage->save(); - - $config = FieldConfig::create([ - 'field_storage' => $storage, - 'bundle' => $type_id, - ]); - $config->save(); - - // Make the field visible in the form display. - /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */ - $component = \Drupal::service('plugin.manager.field.widget') - ->prepareConfiguration($field_type, []); - - entity_get_form_display('media', $type_id, 'default') - ->setComponent($field_name, $component) - ->save(); - } - - /** - * Helper to create a set of fields in a media type. - * - * @param array $fields - * An associative array where keys are field names and values field types. - * @param string $type_id - * The type machine name. - */ - protected function createMediaFields(array $fields, $type_id) { - foreach ($fields as $field_name => $field_type) { - $this->createMediaField($field_name, $field_type, $type_id); - } - } - - /** * Just dummy test to check generic methods. */ public function testMediaImagePlugin() { reverted: --- b/core/modules/media/tests/src/FunctionalJavascript/MediaHandlerTestBase.php +++ a/core/modules/media/tests/src/FunctionalJavascript/MediaHandlerTestBase.php @@ -52,7 +52,7 @@ // Make sure the provided fields are visible on the form. if (!empty($provided_fields)) { foreach ($provided_fields as $provided_field) { + $assert_session->selectExists("field_mapping[$provided_field]"); - $assert_session->selectExists("field_map[$provided_field]"); } } @@ -70,4 +70,27 @@ return MediaType::load($type_name); } + /** + * Helper to assert presence/absence of select options. + * + * @param string $select + * One of id|name|label|value for the select field. + * @param array $expected_options + * An indexed array of expected option names. + * @param array $non_expected_options + * An indexed array of non-expected option names. + * + * @see \Drupal\Tests\WebAssert::optionExists() + * @see \Drupal\Tests\WebAssert::optionNotExists() + */ + protected function assertSelectOptions($select, $expected_options = [], $non_expected_options = []) { + $assert_session = $this->assertSession(); + foreach ($expected_options as $expected_option) { + $assert_session->optionExists($select, $expected_option); + } + foreach ($non_expected_options as $non_expected_option) { + $assert_session->optionNotExists($select, $non_expected_option); + } + } + }