Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / metatag / metatag_mobile / src / Tests / MetatagMobileTagsTest.php
1 <?php
2
3 namespace Drupal\metatag_mobile\Tests;
4
5 use Drupal\metatag\Tests\MetatagTagsTestBase;
6
7 /**
8  * Tests that each of the Metatag mobile tags work correctly.
9  *
10  * @group metatag
11  */
12 class MetatagMobileTagsTest extends MetatagTagsTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   private $tags = [
18     'android_app_link_alternative',
19     'android_manifest',
20     'apple_itunes_app',
21     'apple_mobile_web_app_capable',
22     'apple_mobile_web_app_status_bar_style',
23     'apple_mobile_web_app_title',
24     'application_name',
25     'cleartype',
26     'format_detection',
27     'handheldfriendly',
28     'ios_app_link_alternative',
29     'mobileoptimized',
30     'msapplication_allowDomainApiCalls',
31     'msapplication_allowDomainMetaTags',
32     'msapplication_badge',
33     'msapplication_config',
34     'msapplication_navbutton_color',
35     'msapplication_notification',
36     'msapplication_square150x150logo',
37     'msapplication_square310x310logo',
38     'msapplication_square70x70logo',
39     'msapplication_starturl',
40     'msapplication_task',
41     'msapplication_task_separator',
42     'msapplication_tilecolor',
43     'msapplication_tileimage',
44     'msapplication_tooltip',
45     'msapplication_wide310x150logo',
46     'msapplication_window',
47     'theme_color',
48     'viewport',
49     'web_manifest',
50     'x_ua_compatible',
51   ];
52
53   /**
54    * {@inheritdoc}
55    */
56   protected function setUp() {
57     parent::$modules[] = 'metatag_mobile';
58     parent::setUp();
59   }
60
61   /**
62    * {@inheritdoc}
63    */
64   private function getTestTagName($tag_name) {
65     // These tags all use dashes instead of underlines.
66     $tag_name = str_replace('_', '-', $tag_name);
67
68     // Fix a few specific tags.
69     $tag_name = str_replace('mobileoptimized', 'MobileOptimized', $tag_name);
70     $tag_name = str_replace('handheldfriendly', 'HandheldFriendly', $tag_name);
71
72     return $tag_name;
73   }
74
75   /**
76    * Implements {tag_name}TestOutputXpath() for 'alternate-handheld'.
77    */
78   private function alternateHandheldTestOutputXpath() {
79     return "//link[@rel='alternate' and @media='handheld']";
80   }
81
82   /**
83    * Implements {tag_name}TestValueAttribute() for 'alternate-handheld'.
84    */
85   private function alternateHandheldTestValueAttribute() {
86     return 'href';
87   }
88
89   /**
90    * Implements {tag_name}TestOutputXpath() for 'amphtml'.
91    */
92   private function amphtmlTestOutputXpath() {
93     return "//link[@rel='amphtml']";
94   }
95
96   /**
97    * Implements {tag_name}TestValueAttribute() for 'amphtml'.
98    */
99   private function amphtmlTestValueAttribute() {
100     return 'href';
101   }
102
103   /**
104    * Implements {tag_name}TestValue() for 'android_app_link_alternative'.
105    */
106   private function androidAppLinkAlternativeTestValue() {
107     return 'android-app:' . $this->randomMachineName();
108   }
109
110   /**
111    * Implements {tag_name}TestOutputXpath() for 'android-app-link-alternative'.
112    */
113   private function androidAppLinkAlternativeTestOutputXpath() {
114     return "//link[@rel='alternate' and starts-with(@href, 'android-app:')]";
115   }
116
117   /**
118    * Implements {tag_name}TestValueAttribute().
119    *
120    * For 'android-app-link-alternative'.
121    */
122   private function androidAppLinkAlternativeTestValueAttribute() {
123     return 'href';
124   }
125
126   /**
127    * Implements {tag_name}TestOutputXpath() for 'android_manifest'.
128    */
129   private function androidManifestTestOutputXpath() {
130     return "//link[@rel='manifest']";
131   }
132
133   /**
134    * Implements {tag_name}TestValueAttribute() for 'android_manifest'.
135    */
136   private function androidManifestTestValueAttribute() {
137     return 'href';
138   }
139
140   /**
141    * Implements {tag_name}TestNameAttribute() for 'cleartype'.
142    */
143   private function cleartypeTestNameAttribute() {
144     return 'http-equiv';
145   }
146
147   /**
148    * Implements {tag_name}TestOutputXpath() for 'handheldfriendly'.
149    */
150   private function handheldfriendlyTestOutputXpath() {
151     return "//meta[@name='HandheldFriendly']";
152   }
153
154   /**
155    * Implements {tag_name}TestValue() for 'ios_app_link_alternative'.
156    */
157   private function iosAppLinkAlternativeTestValue() {
158     return 'ios-app:' . $this->randomMachineName();
159   }
160
161   /**
162    * Implements {tag_name}TestOutputXpath() for 'ios_app_link_alternative'.
163    */
164   private function iosAppLinkAlternativeTestOutputXpath() {
165     return "//link[@rel='alternate' and starts-with(@href, 'ios-app:')]";
166   }
167
168   /**
169    * Implements {tag_name}TestValueAttribute() for 'ios_app_link_alternative'.
170    */
171   private function iosAppLinkAlternativeTestValueAttribute() {
172     return 'href';
173   }
174
175   /**
176    * Implements {tag_name}TestOutputXpath() for 'mobileoptimized'.
177    */
178   private function mobileoptimizedTestOutputXpath() {
179     return "//meta[@name='MobileOptimized']";
180   }
181
182   /**
183    * Implements {tag_name}TestValue() for 'msapplication-square150x150logo'.
184    */
185   private function msapplicationSquare150x150logoTestValue() {
186     return $this->randomImageUrl();
187   }
188
189   /**
190    * Implements {tag_name}TestValue() for 'msapplication-square310x310logo'.
191    */
192   private function msapplicationSquare310x310logoTestValue() {
193     return $this->randomImageUrl();
194   }
195
196   /**
197    * Implements {tag_name}TestValue() for 'msapplication-square70x70logo'.
198    */
199   private function msapplicationSquare70x70logoTestValue() {
200     return $this->randomImageUrl();
201   }
202
203   /**
204    * Implements {tag_name}TestValue() for 'msapplication-tileimage'.
205    */
206   private function msapplicationTileimageTestValue() {
207     return $this->randomImageUrl();
208   }
209
210   /**
211    * Implements {tag_name}TestValue() for 'msapplication-wide310x150logo'.
212    */
213   private function msapplicationWide310x150logoTestValue() {
214     return $this->randomImageUrl();
215   }
216
217   /**
218    * Implements {tag_name}TestOutputXpath() for 'web_manifest'.
219    */
220   private function webManifestTestOutputXpath() {
221     return "//link[@rel='manifest']";
222   }
223
224   /**
225    * Implements {tag_name}TestValueAttribute() for 'web_manifest'.
226    */
227   private function webManifestTestValueAttribute() {
228     return 'href';
229   }
230
231   /**
232    * Implements {tag_name}TestNameAttribute() for 'x-ua-compatible'.
233    */
234   private function xUaCompatibleTestNameAttribute() {
235     return 'http-equiv';
236   }
237
238 }