Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / metatag / metatag_hreflang / src / Tests / MetatagHreflangTagsTest.php
index bfa93d886c82bb22f525da8a7bbb4dc7d6005a60..dc5d2d3b1d651dc1876c991080d7006c2f99297e 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Drupal\metatag_hreflang\Tests;
 
-use Drupal\simpletest\WebTestBase;
+use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\metatag\Tests\MetatagTagsTestBase;
 
 /**
@@ -15,45 +15,77 @@ class MetatagHreflangTagsTest extends 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']";
+  }
+
 }