Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / metatag / metatag_pinterest / src / Tests / MetatagPinterestTagsTest.php
diff --git a/web/modules/contrib/metatag/metatag_pinterest/src/Tests/MetatagPinterestTagsTest.php b/web/modules/contrib/metatag/metatag_pinterest/src/Tests/MetatagPinterestTagsTest.php
new file mode 100644 (file)
index 0000000..06d5cbe
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+namespace Drupal\metatag_pinterest\Tests;
+
+use Drupal\metatag\Tests\MetatagTagsTestBase;
+
+/**
+ * Tests that each of the Metatag Pinterest tags work correctly.
+ *
+ * @group metatag
+ */
+class MetatagPinterestTagsTest extends MetatagTagsTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  private $tags = [
+    'pinterest_description',
+    'pinterest_id',
+    'pinterest_media',
+    'pinterest_nopin',
+    'pinterest_nohover',
+    'pinterest_nosearch',
+    'pinterest_url',
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  private $testTag = 'meta';
+
+  /**
+   * {@inheritdoc}
+   */
+  private $testNameAttribute = 'property';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::$modules[] = 'metatag_pinterest';
+    parent::setUp();
+  }
+
+  /**
+   * Each of these meta tags has a different tag name vs its internal name.
+   */
+  private function getTestTagName($tag_name) {
+    if ($tag_name == ('pinterest_nopin' || 'pinterest_nohover' || 'pinterest_nosearch')) {
+      $tag_name = 'pinterest';
+    }
+    else {
+      // Replace "pinterest_" with "pin:".
+      $tag_name = str_replace('pinterest_', 'pin:', $tag_name);
+    }
+
+    return $tag_name;
+  }
+
+  /**
+   * Implements {tag_name}TestFieldXpath() for 'pinterest'.
+   */
+  private function pinterestTestFieldXpath() {
+    return "//input[@name='pinterest[index]' and @type='checkbox']";
+  }
+
+  /**
+   * Implements {tag_name}TestKey() for 'pinterest'.
+   */
+  private function pinterestTestKey() {
+    return 'pinterest[index]';
+  }
+
+  /**
+   * Implements {tag_name}TestValue() for 'pinterest'.
+   */
+  private function pinterestTestValue() {
+    return TRUE;
+  }
+
+}