Updated to Drupal 8.5. Core Media not yet in use.
[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     'x_ua_compatible',
50   ];
51
52   /**
53    * {@inheritdoc}
54    */
55   protected function setUp() {
56     parent::$modules[] = 'metatag_mobile';
57     parent::setUp();
58   }
59
60   /**
61    * {@inheritdoc}
62    */
63   private function getTestTagName($tag_name) {
64     // These tags all use dashes instead of underlines.
65     $tag_name = str_replace('_', '-', $tag_name);
66
67     // Fix a few specific tags.
68     $tag_name = str_replace('mobileoptimized', 'MobileOptimized', $tag_name);
69     $tag_name = str_replace('handheldfriendly', 'HandheldFriendly', $tag_name);
70
71     return $tag_name;
72   }
73
74   /**
75    * Implements {tag_name}TestOutputXpath() for 'alternate-handheld'.
76    */
77   private function alternateHandheldTestOutputXpath() {
78     return "//link[@rel='alternate' and @media='handheld']";
79   }
80
81   /**
82    * Implements {tag_name}TestValueAttribute() for 'alternate-handheld'.
83    */
84   private function alternateHandheldTestValueAttribute() {
85     return 'href';
86   }
87
88   /**
89    * Implements {tag_name}TestOutputXpath() for 'amphtml'.
90    */
91   private function amphtmlTestOutputXpath() {
92     return "//link[@rel='amphtml']";
93   }
94
95   /**
96    * Implements {tag_name}TestValueAttribute() for 'amphtml'.
97    */
98   private function amphtmlTestValueAttribute() {
99     return 'href';
100   }
101
102   /**
103    * Implements {tag_name}TestValue() for 'android_app_link_alternative'.
104    */
105   private function androidAppLinkAlternativeTestValue() {
106     return 'android-app:' . $this->randomMachineName();
107   }
108
109   /**
110    * Implements {tag_name}TestOutputXpath() for 'android-app-link-alternative'.
111    */
112   private function androidAppLinkAlternativeTestOutputXpath() {
113     return "//link[@rel='alternate' and starts-with(@href, 'android-app:')]";
114   }
115
116   /**
117    * Implements {tag_name}TestValueAttribute() for
118    * 'android-app-link-alternative'.
119    */
120   private function androidAppLinkAlternativeTestValueAttribute() {
121     return 'href';
122   }
123
124   /**
125    * Implements {tag_name}TestOutputXpath() for 'android_manifest'.
126    */
127   private function androidManifestTestOutputXpath() {
128     return "//link[@rel='manifest']";
129   }
130
131   /**
132    * Implements {tag_name}TestValueAttribute() for 'android_manifest'.
133    */
134   private function androidManifestTestValueAttribute() {
135     return 'href';
136   }
137
138   /**
139    * Implements {tag_name}TestNameAttribute() for 'cleartype'.
140    */
141   private function cleartypeTestNameAttribute() {
142     return 'http-equiv';
143   }
144
145   /**
146    * Implements {tag_name}TestOutputXpath() for 'handheldfriendly'.
147    */
148   private function handheldfriendlyTestOutputXpath() {
149     return "//meta[@name='HandheldFriendly']";
150   }
151
152   /**
153    * Implements {tag_name}TestValue() for 'ios_app_link_alternative'.
154    */
155   private function iosAppLinkAlternativeTestValue() {
156     return 'ios-app:' . $this->randomMachineName();
157   }
158
159   /**
160    * Implements {tag_name}TestOutputXpath() for 'ios_app_link_alternative'.
161    */
162   private function iosAppLinkAlternativeTestOutputXpath() {
163     return "//link[@rel='alternate' and starts-with(@href, 'ios-app:')]";
164   }
165
166   /**
167    * Implements {tag_name}TestValueAttribute() for 'ios_app_link_alternative'.
168    */
169   private function iosAppLinkAlternativeTestValueAttribute() {
170     return 'href';
171   }
172
173   /**
174    * Implements {tag_name}TestOutputXpath() for 'mobileoptimized'.
175    */
176   private function mobileoptimizedTestOutputXpath() {
177     return "//meta[@name='MobileOptimized']";
178   }
179
180   /**
181    * Implements {tag_name}TestValue() for 'msapplication-square150x150logo'.
182    */
183   private function msapplicationSquare150x150logoTestValue() {
184     return $this->randomImageUrl();
185   }
186
187   /**
188    * Implements {tag_name}TestValue() for 'msapplication-square310x310logo'.
189    */
190   private function msapplicationSquare310x310logoTestValue() {
191     return $this->randomImageUrl();
192   }
193
194   /**
195    * Implements {tag_name}TestValue() for 'msapplication-square70x70logo'.
196    */
197   private function msapplicationSquare70x70logoTestValue() {
198     return $this->randomImageUrl();
199   }
200
201   /**
202    * Implements {tag_name}TestValue() for 'msapplication-tileimage'.
203    */
204   private function msapplicationTileimageTestValue() {
205     return $this->randomImageUrl();
206   }
207
208   /**
209    * Implements {tag_name}TestValue() for 'msapplication-wide310x150logo'.
210    */
211   private function msapplicationWide310x150logoTestValue() {
212     return $this->randomImageUrl();
213   }
214
215   /**
216    * Implements {tag_name}TestNameAttribute() for 'x-ua-compatible'.
217    */
218   private function xUaCompatibleTestNameAttribute() {
219     return 'http-equiv';
220   }
221
222 }