06d5cbe6db1a18054e664730e78886ea960ae9d1
[yaffs-website] / web / modules / contrib / metatag / metatag_pinterest / src / Tests / MetatagPinterestTagsTest.php
1 <?php
2
3 namespace Drupal\metatag_pinterest\Tests;
4
5 use Drupal\metatag\Tests\MetatagTagsTestBase;
6
7 /**
8  * Tests that each of the Metatag Pinterest tags work correctly.
9  *
10  * @group metatag
11  */
12 class MetatagPinterestTagsTest extends MetatagTagsTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   private $tags = [
18     'pinterest_description',
19     'pinterest_id',
20     'pinterest_media',
21     'pinterest_nopin',
22     'pinterest_nohover',
23     'pinterest_nosearch',
24     'pinterest_url',
25   ];
26
27   /**
28    * {@inheritdoc}
29    */
30   private $testTag = 'meta';
31
32   /**
33    * {@inheritdoc}
34    */
35   private $testNameAttribute = 'property';
36
37   /**
38    * {@inheritdoc}
39    */
40   protected function setUp() {
41     parent::$modules[] = 'metatag_pinterest';
42     parent::setUp();
43   }
44
45   /**
46    * Each of these meta tags has a different tag name vs its internal name.
47    */
48   private function getTestTagName($tag_name) {
49     if ($tag_name == ('pinterest_nopin' || 'pinterest_nohover' || 'pinterest_nosearch')) {
50       $tag_name = 'pinterest';
51     }
52     else {
53       // Replace "pinterest_" with "pin:".
54       $tag_name = str_replace('pinterest_', 'pin:', $tag_name);
55     }
56
57     return $tag_name;
58   }
59
60   /**
61    * Implements {tag_name}TestFieldXpath() for 'pinterest'.
62    */
63   private function pinterestTestFieldXpath() {
64     return "//input[@name='pinterest[index]' and @type='checkbox']";
65   }
66
67   /**
68    * Implements {tag_name}TestKey() for 'pinterest'.
69    */
70   private function pinterestTestKey() {
71     return 'pinterest[index]';
72   }
73
74   /**
75    * Implements {tag_name}TestValue() for 'pinterest'.
76    */
77   private function pinterestTestValue() {
78     return TRUE;
79   }
80
81 }