Skip to content
Snippets Groups Projects
Commit bcdb2a7c authored by catch's avatar catch
Browse files

Issue #3376942 by fromme, Kingdutch, smustgrave: Replace usage of...

Issue #3376942 by fromme, Kingdutch, smustgrave: Replace usage of generateString with generate in Media module

(cherry picked from commit 01b55ef5)
parent 253180fa
No related branches found
No related tags found
2 merge requests!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!9944Issue #3483353: Consider making the createCopy config action optionally fail...
Pipeline #223329 passed
......@@ -115,7 +115,7 @@ public function testMediaDisplay(): void {
// visually hidden, and there is no link to the image file.
/** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
$file_url_generator = \Drupal::service('file_url_generator');
$expected_image_src = $file_url_generator->generateString(\Drupal::token()->replace('public://styles/large/public/[date:custom:Y]-[date:custom:m]/example_1.jpeg'));
$expected_image_src = $file_url_generator->generate(\Drupal::token()->replace('public://styles/large/public/[date:custom:Y]-[date:custom:m]/example_1.jpeg'))->toString();
$this->assertStringContainsString($expected_image_src, $media_image->getAttribute('src'));
$field = $assert_session->elementExists('xpath', '/div[1]', $media_item);
$assert_session->elementExists('xpath', '/div[@class="visually-hidden"]', $field);
......
......@@ -79,7 +79,7 @@ public function testMediaImageSource(): void {
$image_element = $field->find('css', 'img');
/** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
$file_url_generator = \Drupal::service('file_url_generator');
$expected_image_src = $file_url_generator->generateString(\Drupal::token()->replace('public://styles/large/public/[date:custom:Y]-[date:custom:m]/example_1.jpeg'));
$expected_image_src = $file_url_generator->generate(\Drupal::token()->replace('public://styles/large/public/[date:custom:Y]-[date:custom:m]/example_1.jpeg'))->toString();
$this->assertStringContainsString($expected_image_src, $image_element->getAttribute('src'));
$assert_session->elementNotExists('css', 'a', $field);
......
......@@ -162,7 +162,7 @@ protected function audioTest() {
$audio_element = $assert_session->elementExists('css', 'div.media--type-audio .field--name-field-media-audio-file audio > source');
/** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
$file_url_generator = \Drupal::service('file_url_generator');
$expected_audio_src = $file_url_generator->generateString(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/' . $test_filename));
$expected_audio_src = $file_url_generator->generate(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/' . $test_filename))->toString();
$this->assertSame($expected_audio_src, $audio_element->getAttribute('src'));
// Assert the media name is updated through the field mapping when changing
......@@ -189,7 +189,7 @@ protected function audioTest() {
// Assert the audio file is present inside the media element and that its
// src attribute matches the updated audio file.
$audio_element = $assert_session->elementExists('css', 'div.media--type-audio .field--name-field-media-audio-file audio > source');
$expected_audio_src = $file_url_generator->generateString(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/' . $test_filename_updated));
$expected_audio_src = $file_url_generator->generate(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/' . $test_filename_updated))->toString();
$this->assertSame($expected_audio_src, $audio_element->getAttribute('src'));
}
......@@ -251,7 +251,7 @@ protected function imageTest() {
$image_element = $assert_session->elementExists('css', 'div.media--type-image img');
/** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
$file_url_generator = \Drupal::service('file_url_generator');
$expected_image_src = $file_url_generator->generateString(\Drupal::token()->replace('public://styles/large/public/[date:custom:Y]-[date:custom:m]/' . $image_media_name));
$expected_image_src = $file_url_generator->generate(\Drupal::token()->replace('public://styles/large/public/[date:custom:Y]-[date:custom:m]/' . $image_media_name))->toString();
$this->assertStringContainsString($expected_image_src, $image_element->getAttribute('src'));
$assert_session->elementExists('css', '.field--name-field-media-image .field__label.visually-hidden');
......@@ -284,7 +284,7 @@ protected function imageTest() {
// src attribute uses the large image style, the label is visually hidden,
// and there is no link to the image file.
$image_element = $assert_session->elementExists('css', 'div.media--type-image img');
$expected_image_src = $file_url_generator->generateString(\Drupal::token()->replace('public://styles/large/public/[date:custom:Y]-[date:custom:m]/' . $image_media_name_updated));
$expected_image_src = $file_url_generator->generate(\Drupal::token()->replace('public://styles/large/public/[date:custom:Y]-[date:custom:m]/' . $image_media_name_updated))->toString();
$this->assertStringContainsString($expected_image_src, $image_element->getAttribute('src'));
$assert_session->elementExists('css', '.field--name-field-media-image .field__label.visually-hidden');
$assert_session->elementNotExists('css', '.field--name-field-media-image a');
......@@ -538,7 +538,7 @@ protected function videoTest() {
$video_element = $assert_session->elementExists('css', 'div.media--type-video .field--name-field-media-video-file video > source');
/** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
$file_url_generator = \Drupal::service('file_url_generator');
$expected_video_src = $file_url_generator->generateString(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/' . $test_filename));
$expected_video_src = $file_url_generator->generate(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/' . $test_filename))->toString();
$this->assertSame($expected_video_src, $video_element->getAttribute('src'));
// Assert the media name is updated through the field mapping when changing
......@@ -565,7 +565,7 @@ protected function videoTest() {
// Assert the video element is present inside the media element and that its
// src attribute matches the updated video file.
$video_element = $assert_session->elementExists('css', 'div.media--type-video .field--name-field-media-video-file video > source');
$expected_video_src = $file_url_generator->generateString(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/' . $test_filename_updated));
$expected_video_src = $file_url_generator->generate(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/' . $test_filename_updated))->toString();
$this->assertSame($expected_video_src, $video_element->getAttribute('src'));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment