Skip to content

Commit

Permalink
OEL-2070: Order of attributes is different in Drupal 9.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
brummbar committed Oct 27, 2022
1 parent 13f18b6 commit f60e475
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ content:
settings:
image_link: ''
image_style: ''
image_loading:
attribute: lazy
third_party_settings:
oe_whitelabel_helper:
pattern_mapping: thumbnail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ content:
settings:
image_link: ''
image_style: ''
image_loading:
attribute: lazy
third_party_settings:
oe_whitelabel_helper:
pattern_mapping: thumbnail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ content:
settings:
image_link: ''
image_style: ''
image_loading:
attribute: lazy
third_party_settings:
oe_whitelabel_helper:
pattern_mapping: media
Expand All @@ -42,8 +40,6 @@ content:
settings:
image_link: ''
image_style: ''
image_loading:
attribute: lazy
third_party_settings:
oe_whitelabel_helper:
pattern_mapping: thumbnail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ content:
settings:
image_link: ''
image_style: ''
image_loading:
attribute: lazy
third_party_settings:
oe_whitelabel_helper:
pattern_mapping: thumbnail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,38 @@ public function testRendering(): void {
$paragraph->save();

$file_url_generator = \Drupal::service('file_url_generator');
// The attribute order is different from 9.4.0 onwards.
$attribute_pre_940 = version_compare(\Drupal::VERSION, '9.4.0', '<') ? '' : 'loading="lazy" ';
$attribute_940 = version_compare(\Drupal::VERSION, '9.4.0', '>=') ? '' : 'loading="lazy" ';
$expected_items = [
[
'thumbnail' => [
'caption_title' => 'Image title',
'rendered' => sprintf(
'<img loading="lazy" src="%s" width="200" height="89" alt="Alt text" class="img-fluid">',
$file_url_generator->generate($image->get('oe_media_image')->entity->getFileUri())->toString()
'<img %ssrc="%s" width="200" height="89" alt="Alt text" %sclass="img-fluid">',
$attribute_pre_940,
$file_url_generator->generate($image->get('oe_media_image')->entity->getFileUri())->toString(),
$attribute_940
),
],
'media' => [
'caption_title' => 'Image title',
'rendered' => sprintf(
'<img loading="lazy" data-src="%s" width="200" height="89" alt="Alt text" class="img-fluid">',
$file_url_generator->generate($image->get('oe_media_image')->entity->getFileUri())->toString()
'<img %sdata-src="%s" width="200" height="89" alt="Alt text" %sclass="img-fluid">',
$attribute_pre_940,
$file_url_generator->generate($image->get('oe_media_image')->entity->getFileUri())->toString(),
$attribute_940
),
],
],
[
'thumbnail' => [
'caption_title' => 'Euro with miniature figurines',
'rendered' => sprintf(
'<img loading="lazy" src="%s" width="639" height="426" alt="Euro with miniature figurines" class="img-fluid">',
$file_url_generator->generate($avportal_photo->get('thumbnail')->entity->getFileUri())->toString()
'<img %ssrc="%s" width="639" height="426" alt="Euro with miniature figurines" %sclass="img-fluid">',
$attribute_pre_940,
$file_url_generator->generate($avportal_photo->get('thumbnail')->entity->getFileUri())->toString(),
$attribute_940
),
],
'media' => [
Expand All @@ -90,8 +99,10 @@ public function testRendering(): void {
'thumbnail' => [
'caption_title' => 'Economic and Financial Affairs Council - Arrivals',
'rendered' => sprintf(
'<img loading="lazy" src="%s" width="352" height="200" alt="" class="img-fluid">',
$file_url_generator->generate($avportal_video->get('thumbnail')->entity->getFileUri())->toString()
'<img %ssrc="%s" width="352" height="200" alt="" %sclass="img-fluid">',
$attribute_pre_940,
$file_url_generator->generate($avportal_video->get('thumbnail')->entity->getFileUri())->toString(),
$attribute_940
),
'play_icon' => TRUE,
],
Expand All @@ -104,8 +115,10 @@ public function testRendering(): void {
'thumbnail' => [
'caption_title' => 'Energy, let\'s save it!',
'rendered' => sprintf(
'<img loading="lazy" src="%s" width="480" height="360" alt="" class="img-fluid">',
$file_url_generator->generate($video->get('thumbnail')->entity->getFileUri())->toString()
'<img %ssrc="%s" width="480" height="360" alt="" %sclass="img-fluid">',
$attribute_pre_940,
$file_url_generator->generate($video->get('thumbnail')->entity->getFileUri())->toString(),
$attribute_940
),
'play_icon' => TRUE,
],
Expand Down

0 comments on commit f60e475

Please sign in to comment.