Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit af442895 authored by Gilmar Lima's avatar Gilmar Lima
Browse files

OEL-1167: Update tests.

parent a369c612
No related branches found
No related tags found
2 merge requests!102Merge 1.x into EPIC-OEL-1255-migrate-paragraphs.,!94OEL-1167: Theme the content language switcher
......@@ -28,6 +28,7 @@ class ContentLanguageSwitcherTest extends KernelTestBase {
'oe_whitelabel_multilingual',
'system',
'user',
'oe_corporate_blocks',
];
/**
......@@ -117,6 +118,37 @@ class ContentLanguageSwitcherTest extends KernelTestBase {
// Make sure that available languages are properly rendered.
$this->assertTranslationLinks($crawler, ['español', 'English']);
// Remove the spanish translation.
$node->removeTranslation('es');
$node->save();
// Re-render the block assuming a request to the Spanish version of the
// node.
$this->setCurrentRequest('/es/node/' . $node->id());
$render = $plugin_block->build();
$html = (string) $this->container->get('renderer')->renderRoot($render);
$crawler = new Crawler($html);
// Verify that the requested language is set as unavailable.
$this->assertUnavailableLanguage($crawler, 'This page is not available in español.');
// Verify that the content has been rendered in the fallback language.
$this->assertSelectedLanguage($crawler, 'English');
}
/**
* Asserts that a language is marked as the current rendered.
*
* @param \Symfony\Component\DomCrawler\Crawler $crawler
* The content language block crawler.
* @param string $expected
* The label of the language.
*/
protected function assertSelectedLanguage(Crawler $crawler, string $expected): void {
$actual = $crawler->filter('#dropdown-languages > div > a')->text();
$this->assertEquals($expected, trim($actual));
}
/**
......
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