diff --git a/core/modules/file/tests/src/Functional/Formatter/FileAudioFormatterTest.php b/core/modules/file/tests/src/Functional/Formatter/FileAudioFormatterTest.php index ce7c4059b2..94342d6a83 100644 --- a/core/modules/file/tests/src/Functional/Formatter/FileAudioFormatterTest.php +++ b/core/modules/file/tests/src/Functional/Formatter/FileAudioFormatterTest.php @@ -35,9 +35,9 @@ public function testRender() { $this->drupalGet($entity->url()); - $file_url = file_create_url($file->getFileUri()); + $file_url = file_url_transform_relative(file_create_url($file->getFileUri())); $this->assertSession()->elementExists('css', 'audio[controls="controls"]'); - $this->assertSession()->elementExists('css', "audio > source[src='$file_url'][type='audio/mpeg']"); + $this->assertSession()->elementExists('css', "audio > source[src*='$file_url'][type='audio/mpeg']"); } } diff --git a/core/modules/file/tests/src/Functional/Formatter/FileMediaFormatterTestBase.php b/core/modules/file/tests/src/Functional/Formatter/FileMediaFormatterTestBase.php index 2fbce8475d..8e82a754fd 100644 --- a/core/modules/file/tests/src/Functional/Formatter/FileMediaFormatterTestBase.php +++ b/core/modules/file/tests/src/Functional/Formatter/FileMediaFormatterTestBase.php @@ -9,10 +9,11 @@ use Drupal\Tests\BrowserTestBase; /** - * @coversDefaultClass \Drupal\file\Plugin\Field\FieldFormatter\FileAudioFormatter + * Provides methods specifically for testing File module's media formatter's. + * * @group file */ -class FileMediaFormatterTestBase extends BrowserTestBase { +abstract class FileMediaFormatterTestBase extends BrowserTestBase { /** * The field name. @@ -47,17 +48,25 @@ protected function setUp() { $this->drupalLogin($this->drupalCreateUser(['view test entity'])); } + /** + * Creates a file field and set's the correct formatter. + * + * @param string $formatter + * The formatter ID. + * @param string $file_extionsions + * The file extensions of the new field. + */ protected function createMediaField($formatter, $file_extionsions) { $entityType = $bundle = 'entity_test'; $this->fieldName = Unicode::strtolower($this->randomMachineName()); - FieldStorageConfig::create(array( + FieldStorageConfig::create([ 'entity_type' => $entityType, 'field_name' => $this->fieldName, 'type' => 'file', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, - ))->save(); + ])->save(); FieldConfig::create([ 'entity_type' => $entityType, 'field_name' => $this->fieldName, diff --git a/core/modules/file/tests/src/Functional/Formatter/FileVideoFormatterTest.php b/core/modules/file/tests/src/Functional/Formatter/FileVideoFormatterTest.php index cb55890019..da67c78f1a 100644 --- a/core/modules/file/tests/src/Functional/Formatter/FileVideoFormatterTest.php +++ b/core/modules/file/tests/src/Functional/Formatter/FileVideoFormatterTest.php @@ -35,9 +35,9 @@ public function testRender() { $this->drupalGet($entity->url()); - $file_url = file_create_url($file->getFileUri()); + $file_url = file_url_transform_relative(file_create_url($file->getFileUri())); $this->assertSession()->elementExists('css', 'video[controls="controls"]'); - $this->assertSession()->elementExists('css', "video > source[src='$file_url'][type='video/mp4']"); + $this->assertSession()->elementExists('css', "video > source[src*='$file_url'][type='video/mp4']"); } }