namespace Drupal\metatag_hreflang\Tests;
-use Drupal\simpletest\WebTestBase;
+use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\metatag\Tests\MetatagTagsTestBase;
/**
/**
* {@inheritdoc}
*/
- public $tags = [
+ private $tags = [
'hreflang_xdefault',
+ 'hreflang_en',
+ 'hreflang_es',
+ 'hreflang_fr',
];
/**
* {@inheritdoc}
*/
- public $test_tag = 'link';
+ private $testTag = 'link';
/**
* {@inheritdoc}
*/
- public $test_name_attribute = 'hreflang';
+ private $testNameAttribute = 'alternate';
/**
* {@inheritdoc}
*/
- public $test_value_attribute = 'href';
+ private $testValueAttribute = 'href';
/**
* {@inheritdoc}
*/
protected function setUp() {
+ // Need the Language module in order for any of this to work.
+ parent::$modules[] = 'language';
+ // This module.
parent::$modules[] = 'metatag_hreflang';
parent::setUp();
+
+ // Enable additional languages.
+ foreach (['es', 'fr'] as $langcode) {
+ ConfigurableLanguage::createFromLangcode($langcode)->save();
+ }
}
/**
* Each of these meta tags has a different tag name vs its internal name.
*/
- public function getTestTagName($tag_name) {
+ private function getTestTagName($tag_name) {
return str_replace('hreflang_', '', $tag_name);
}
/**
- * Implements {meta_tag_name}_test_output_xpath() for 'hreflang_xdefault'.
+ * Implements {tag_name}TestOutputXpath() for 'hreflang_xdefault'.
*/
- public function hreflang_xdefault_test_output_xpath() {
+ private function hreflangXdefaultTestOutputXpath() {
return "//link[@hreflang='x-default']";
}
+ /**
+ * Implements {tag_name}TestOutputXpath() for 'hreflang_en'.
+ */
+ private function hreflangEnTestOutputXpath() {
+ return "//link[@hreflang='en']";
+ }
+
+ /**
+ * Implements {tag_name}TestOutputXpath() for 'hreflang_es'.
+ */
+ private function hreflangEsTestOutputXpath() {
+ return "//link[@hreflang='es']";
+ }
+
+ /**
+ * Implements {tag_name}TestOutputXpath() for 'hreflang_fr'.
+ */
+ private function hreflangFrTestOutputXpath() {
+ return "//link[@hreflang='fr']";
+ }
+
}