3 namespace Drupal\metatag_hreflang\Tests;
5 use Drupal\language\Entity\ConfigurableLanguage;
6 use Drupal\metatag\Tests\MetatagTagsTestBase;
9 * Tests that each of the Metatag hreflang tags work correctly.
13 class MetatagHreflangTagsTest extends MetatagTagsTestBase {
28 private $testTag = 'link';
33 private $testNameAttribute = 'alternate';
38 private $testValueAttribute = 'href';
43 protected function setUp() {
44 // Need the Language module in order for any of this to work.
45 parent::$modules[] = 'language';
47 parent::$modules[] = 'metatag_hreflang';
50 // Enable additional languages.
51 foreach (['es', 'fr'] as $langcode) {
52 ConfigurableLanguage::createFromLangcode($langcode)->save();
57 * Each of these meta tags has a different tag name vs its internal name.
59 private function getTestTagName($tag_name) {
60 return str_replace('hreflang_', '', $tag_name);
64 * Implements {tag_name}TestOutputXpath() for 'hreflang_xdefault'.
66 private function hreflangXdefaultTestOutputXpath() {
67 return "//link[@hreflang='x-default']";
71 * Implements {tag_name}TestOutputXpath() for 'hreflang_en'.
73 private function hreflangEnTestOutputXpath() {
74 return "//link[@hreflang='en']";
78 * Implements {tag_name}TestOutputXpath() for 'hreflang_es'.
80 private function hreflangEsTestOutputXpath() {
81 return "//link[@hreflang='es']";
85 * Implements {tag_name}TestOutputXpath() for 'hreflang_fr'.
87 private function hreflangFrTestOutputXpath() {
88 return "//link[@hreflang='fr']";