.../Kernel/EntityEmbedFilterTranslationTest.php | 47 ++++++---------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/tests/src/Kernel/EntityEmbedFilterTranslationTest.php b/tests/src/Kernel/EntityEmbedFilterTranslationTest.php index 1608480..ef4da89 100644 --- a/tests/src/Kernel/EntityEmbedFilterTranslationTest.php +++ b/tests/src/Kernel/EntityEmbedFilterTranslationTest.php @@ -52,9 +52,9 @@ class EntityEmbedFilterTranslationTest extends EntityEmbedFilterTestBase { $this->applyFilter($content, 'pt-br'); $this->assertRaw($expected_title); - // Translate the embedded entity to the same language as the context. + // Translate the embedded entity to the same language as the context (i.e. + // the language of the host entity). $this->node->addTranslation('pt-br') - ->getTranslation('pt-br') ->setTitle('Embed em portugues') ->save(); @@ -69,28 +69,19 @@ class EntityEmbedFilterTranslationTest extends EntityEmbedFilterTestBase { * * @dataProvider providerTestFilterTranslations */ - public function testFilterTranslations(array $embed_attributes, $process_lang, $assert_title_from_source, $assert_title_lang, $assert_extra) { + public function testFilterTranslations(array $embed_attributes, $expected_title_langcode) { $content = $this->createEmbedCode($embed_attributes); - // Translate the embedded entity to the same language as the context. + // Translate the embedded entity to the same language as the context (i.e. + // the language of the host entity). $this->node->addTranslation('pt-br') - ->getTranslation('pt-br') ->setTitle('Embed em portugues') ->save(); - $this->applyFilter($content); - - // Run the assertions based on the data. - if ($assert_title_from_source) { - $this->assertRaw($this->node->getTitle()); - // @TODO: find better naming and implementation for this, maybe? - if ($assert_extra) { - $this->assertNoRaw($this->node->getTranslation($assert_extra)->getTitle()); - } - } - else { - $this->assertRaw($this->node->getTranslation($assert_title_lang)->getTitle()); - } + // The embedded entity's language is explicitly specified and therefore does + // not depend on the context. Prove by specifying a non-existent language. + $this->applyFilter($content, $this->randomMachineName()); + $this->assertRaw($this->node->getTranslation($expected_title_langcode)->getTitle()); } /** @@ -107,10 +98,7 @@ class EntityEmbedFilterTranslationTest extends EntityEmbedFilterTestBase { 'data-entity-embed-settings' => '{"link":"0"}', 'data-langcode' => 'en', ], - 'process_lang' => 'pt-br', - 'assert_title_from_source' => TRUE, - 'assert_title_lang' => NULL, - 'assert_extra' => 'pt-br', + 'en', ], 'Change the untranslated context to explicitly embed the Portugues translation of the embedded entity.' => [ 'embed_attributes' => [ @@ -121,10 +109,7 @@ class EntityEmbedFilterTranslationTest extends EntityEmbedFilterTestBase { 'data-entity-embed-settings' => '{"link":"0"}', 'data-langcode' => 'pt-br', ], - 'process_lang' => 'pt-br', - 'assert_title_from_source' => FALSE, - 'assert_title_lang' => 'pt-br', - 'assert_extra' => NULL, + 'pt-br', ], 'Change the translated context to explicitly embed a non-existing translation, en' => [ 'embed_attributes' => [ @@ -135,10 +120,7 @@ class EntityEmbedFilterTranslationTest extends EntityEmbedFilterTestBase { 'data-entity-embed-settings' => '{"link":"0"}', 'data-langcode' => 'nl', ], - 'process_lang' => 'en', - 'assert_title_from_source' => TRUE, - 'assert_title_lang' => NULL, - 'assert_extra' => NULL, + 'en', ], 'Change the translated context to explicitly embed a non-existing translation, pt-br' => [ 'embed_attributes' => [ @@ -149,10 +131,7 @@ class EntityEmbedFilterTranslationTest extends EntityEmbedFilterTestBase { 'data-entity-embed-settings' => '{"link":"0"}', 'data-langcode' => 'nl', ], - 'process_lang' => 'pt-br', - 'assert_title_from_source' => TRUE, - 'assert_title_lang' => NULL, - 'assert_extra' => NULL, + 'en', ], ]; }