Skip to content

Commit

Permalink
EWPP-4578: Fix banner and carousel kernel tests rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
fmmribeiro committed Oct 11, 2024
1 parent 4384930 commit 28eac43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions oe_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -1705,25 +1705,25 @@ function oe_theme_preprocess_paragraph__oe_banner(array &$variables): void {
* @return array
* Returns sources and fallback url.
*/
function _oe_theme_load_from_responsive_image_style_id($responsive_image_style_id, $uri) {
function _oe_theme_load_from_responsive_image_style_id(string $responsive_image_style_id, string $uri):array {
$responsive_image_style = ResponsiveImageStyle::load($responsive_image_style_id);
$resp_image = [];
$responsive_image_generator = [];
$breakpoints = array_reverse(\Drupal::service('breakpoint.manager')->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup()));
foreach ($responsive_image_style->getKeyedImageStyleMappings() as $breakpoint_id => $multipliers) {
if (isset($breakpoints[$breakpoint_id])) {
$responsive_image = _responsive_image_build_source_attributes(['uri' => $uri], $breakpoints[$breakpoint_id], $multipliers);
$responsive_image_array = $responsive_image->toArray();
$resp_image['sources'][] = [
$responsive_image_generator['sources'][] = [
'src' => $responsive_image_array['srcset'],
'media' => $responsive_image_array['media'] ?? '',
];
}
}

// Add fallback style.
$resp_image['fallback'] = _responsive_image_image_style_url($responsive_image_style->getFallbackImageStyle(), $uri);
$responsive_image_generator['fallback'] = _responsive_image_image_style_url($responsive_image_style->getFallbackImageStyle(), $uri);

return $resp_image;
return $responsive_image_generator;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/Paragraphs/MediaParagraphsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ public function testTextWithMedia(): void {
*/
public function testBanner(): void {

$breakpointsByGroup = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('oe_theme');
$this->assertCount(5, $breakpointsByGroup);
$breakpoints_by_group = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('oe_theme');
$this->assertCount(5, $breakpoints_by_group);

// Set image media translatable.
$this->container->get('content_translation.manager')->setEnabled('media', 'image', TRUE);
Expand Down

0 comments on commit 28eac43

Please sign in to comment.