Skip to content

Commit

Permalink
EWPP-1149: Fix paragraphs and pattern rendering tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra authored and yenyasinn committed Jul 20, 2021
1 parent 931fd3d commit d744dfb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
5 changes: 2 additions & 3 deletions oe_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,15 @@ function oe_theme_preprocess_paragraph__oe_links_block(array &$variables): void
*/
function oe_theme_preprocess_paragraph__oe_accordion(array &$variables): void {
// Massage data to be compliant with ECL Accordion2 component data structure.
$builder = \Drupal::entityTypeManager()->getViewBuilder('paragraph');
$variables['identifier'] = 'paragraph-' . $variables['paragraph']->id();
$variables['items'] = [];

/** @var \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem $field_item */
foreach ($variables['paragraph']->get('field_oe_paragraphs') as $field_item) {
$paragraph = \Drupal::service('entity.repository')->getTranslationFromContext($field_item->entity);
$variables['items'][] = [
'title' => $builder->viewField($paragraph->get('field_oe_text')),
'body' => $builder->viewField($paragraph->get('field_oe_text_long')),
'title' => $paragraph->get('field_oe_text')->value,
'body' => $paragraph->get('field_oe_text_long')->value,
];
}
}
Expand Down
18 changes: 18 additions & 0 deletions tests/Functional/ParagraphsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ class ParagraphsTest extends BrowserTestBase {
'oe_content_timeline_field',
];

/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();

// Enable and set OpenEuropa Theme as default.
\Drupal::service('theme_installer')->install(['oe_theme']);
\Drupal::configFactory()
->getEditable('system.theme')
->set('default', 'oe_theme')
->save();

// Rebuild the ui_pattern definitions to collect the ones provided by
// oe_theme itself.
\Drupal::service('plugin.manager.ui_patterns')->clearCachedDefinitions();
}

/**
* Test Accordion item paragraph form.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/Kernel/fixtures/rendering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,7 @@
'div.ecl-fact-figures__item:nth-child(2) div.ecl-fact-figures__value': '10.0 millions'
'div.ecl-fact-figures__item:nth-child(2) div.ecl-fact-figures__title': 'Nam lacinia nisl eget diam mattis'
'div.ecl-fact-figures__item:nth-child(2) div.ecl-fact-figures__description': 'Sed efficitur bibendum rutrum. Nunc feugiat congue augue ac consectetur.'
'div.ecl-fact-figures__view-all a.ecl-link.ecl-link--standalone.ecl-fact-figures__view-all-link[href="https://example.com"]': 'View all metrics'
'div.ecl-fact-figures__view-all a.ecl-link.ecl-link--standalone.ecl-fact-figures__view-all-link[href="https://example.com"] span.ecl-link__label': 'View all metrics'
- array:
'#type': 'pattern'
'#id': 'facts_figures'
Expand Down

0 comments on commit d744dfb

Please sign in to comment.