Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / metatag / src / Tests / MetatagTagsTest.php
1 <?php
2
3 namespace Drupal\metatag\Tests;
4
5 /**
6  * Tests that each of the Metatag base tags work correctly.
7  *
8  * @group metatag
9  */
10 class MetatagTagsTest extends MetatagTagsTestBase {
11
12   /**
13    * {@inheritdoc}
14    */
15   private $tags = [
16     'abstract',
17     'canonical_url',
18     'content_language',
19     'description',
20     'generator',
21     'geo_placename',
22     'geo_position',
23     'geo_region',
24     'google',
25     'icbm',
26     'image_src',
27     'keywords',
28     'news_keywords',
29     'original_source',
30     'referrer',
31     'rights',
32     'robots',
33     'set_cookie',
34     'shortlink',
35     'standout',
36     'title',
37   ];
38
39   /**
40    * Each of these meta tags has a different tag name vs its internal name.
41    */
42   private function getTestTagName($tag_name) {
43     if ($tag_name == 'geo_placename') {
44       $tag_name = 'geo.placename';
45     }
46     elseif ($tag_name == 'geo_position') {
47       $tag_name = 'geo.position';
48     }
49     elseif ($tag_name == 'geo_region') {
50       $tag_name = 'geo.region';
51     }
52     elseif ($tag_name == 'content_language') {
53       $tag_name = 'content-language';
54     }
55     elseif ($tag_name == 'original_source') {
56       $tag_name = 'original-source';
57     }
58     elseif ($tag_name == 'set_cookie') {
59       $tag_name = 'set-cookie';
60     }
61
62     return $tag_name;
63   }
64
65   /**
66    * Implements {tag_name}TestFieldXpath() for 'abstract'.
67    */
68   private function abstractTestFieldXpath() {
69     return "//textarea[@name='abstract']";
70   }
71
72   /**
73    * Implements {tag_name}TestNameAttribute() for 'author'.
74    */
75   private function authorTestOutputXpath() {
76     return "//link[@rel='author']";
77   }
78
79   /**
80    * Implements {tag_name}TestValueAttribute() for 'author'.
81    */
82   private function authorTestValueAttribute() {
83     return 'href';
84   }
85
86   /**
87    * Implements {tag_name}TestNameAttribute() for 'canonical_url'.
88    */
89   private function canonicalUrlTestOutputXpath() {
90     return "//link[@rel='canonical']";
91   }
92
93   /**
94    * Implements {tag_name}TestValueAttribute() for 'canonical_url'.
95    */
96   private function canonicalUrlTestValueAttribute() {
97     return 'href';
98   }
99
100   /**
101    * Implements {tag_name}TestNameAttribute() for 'content_language'.
102    */
103   private function contentLanguageTestNameAttribute() {
104     return 'http-equiv';
105   }
106
107   /**
108    * Implements {tag_name}TestNameAttribute() for 'set_cookie'.
109    */
110   private function setCookieTestNameAttribute() {
111     return 'http-equiv';
112   }
113
114   /**
115    * Implements {tag_name}TestFieldXpath() for 'description'.
116    */
117   private function descriptionTestFieldXpath() {
118     return "//textarea[@name='description']";
119   }
120
121   /**
122    * Implements {tag_name}TestOutputXpath() for 'image_src'.
123    */
124   private function imageSrcTestOutputXpath() {
125     return "//link[@rel='image_src']";
126   }
127
128   /**
129    * Implements {tag_name}TestValueAttribute() for 'image_src'.
130    */
131   private function imageSrcTestValueAttribute() {
132     return 'href';
133   }
134
135   /**
136    * Implements {tag_name}TestFieldXpath() for 'referrer'.
137    */
138   private function referrerTestFieldXpath() {
139     return "//select[@name='referrer']";
140   }
141
142   /**
143    * Implements {tag_name}TestFieldXpath() for 'robots'.
144    */
145   private function robotsTestFieldXpath() {
146     return "//input[@name='robots[index]' and @type='checkbox']";
147   }
148
149   /**
150    * Implements {tag_name}TestValue() for 'referrer'.
151    */
152   private function referrerTestValue() {
153     return 'origin';
154   }
155
156   /**
157    * Implements {tag_name}TestValue() for 'robots'.
158    */
159   private function robotsTestKey() {
160     return 'robots[index]';
161   }
162
163   /**
164    * Implements {tag_name}TestValue() for 'robots'.
165    */
166   private function robotsTestValue() {
167     return TRUE;
168   }
169
170   /**
171    * Implements {tag_name}TestOutputXpath() for 'shortlink'.
172    */
173   private function shortlinkTestOutputXpath() {
174     return "//link[@rel='shortlink']";
175   }
176
177   /**
178    * Implements {tag_name}TestValueAttribute() for 'shortlink'.
179    */
180   private function shortlinkTestValueAttribute() {
181     return 'href';
182   }
183
184 }