public function MetatagContextWithI18nTest::testExportedContext in Metatag 7
Test the Metatag:Context translations for an exported configuration.
File
- metatag_context/
tests/ MetatagContextWithI18nTest.test, line 105 - Tests the Metatag:Context module for i18n integration.
Class
- MetatagContextWithI18nTest
- Tests the Metatag:Context module for i18n integration.
Code
public function testExportedContext() {
// Plan out the different translation string tests.
$string_en = 'Metatag:Context test description tag.';
$string_fr = 'French page description';
$config_name = 'metatag_context:metatag_context_test:description';
$path = 'metatag-context-test';
// Confirm the string is present as it has been grabbed by the string-
// refresh triggered in $this->setUp().
$this
->searchTranslationPage($string_en, $config_name);
// Get the translation string lid for the generator tag.
$lid = $this
->getTranslationLidByContext($config_name);
$this
->assertNotEqual($lid, 0, 'Found the locales_source string for the description tag.');
// Save the translation string.
$this
->saveTranslationString($lid, $config_name, 'fr', $string_en, $string_fr);
// Load the English page again.
$this
->drupalGet($path);
$this
->assertResponse(200, 'Loaded the default test page again.');
// Confirm the page's description is what we set it to.
$xpath = $this
->xpath("//meta[@name='description']");
$this
->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.');
$this
->assertEqual($xpath[0]['content'], $string_en);
$this
->assertNotEqual($xpath[0]['content'], $string_fr);
// Load the French page.
$this
->drupalGet('fr/' . $path);
$this
->assertResponse(200, 'Loaded the French test page.');
// Confirm the generator string was translated.
$xpath = $this
->xpath("//meta[@name='description']");
$this
->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.');
$this
->assertEqual($xpath[0]['content'], $string_fr);
$this
->assertNotEqual($xpath[0]['content'], $string_en);
}