3 namespace Drupal\metatag_mobile\Tests;
5 use Drupal\metatag\Tests\MetatagTagsTestBase;
8 * Tests that each of the Metatag mobile tags work correctly.
12 class MetatagMobileTagsTest extends MetatagTagsTestBase {
18 'android_app_link_alternative',
21 'apple_mobile_web_app_capable',
22 'apple_mobile_web_app_status_bar_style',
23 'apple_mobile_web_app_title',
28 'ios_app_link_alternative',
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',
41 'msapplication_task_separator',
42 'msapplication_tilecolor',
43 'msapplication_tileimage',
44 'msapplication_tooltip',
45 'msapplication_wide310x150logo',
46 'msapplication_window',
56 protected function setUp() {
57 parent::$modules[] = 'metatag_mobile';
64 private function getTestTagName($tag_name) {
65 // These tags all use dashes instead of underlines.
66 $tag_name = str_replace('_', '-', $tag_name);
68 // Fix a few specific tags.
69 $tag_name = str_replace('mobileoptimized', 'MobileOptimized', $tag_name);
70 $tag_name = str_replace('handheldfriendly', 'HandheldFriendly', $tag_name);
76 * Implements {tag_name}TestOutputXpath() for 'alternate-handheld'.
78 private function alternateHandheldTestOutputXpath() {
79 return "//link[@rel='alternate' and @media='handheld']";
83 * Implements {tag_name}TestValueAttribute() for 'alternate-handheld'.
85 private function alternateHandheldTestValueAttribute() {
90 * Implements {tag_name}TestOutputXpath() for 'amphtml'.
92 private function amphtmlTestOutputXpath() {
93 return "//link[@rel='amphtml']";
97 * Implements {tag_name}TestValueAttribute() for 'amphtml'.
99 private function amphtmlTestValueAttribute() {
104 * Implements {tag_name}TestValue() for 'android_app_link_alternative'.
106 private function androidAppLinkAlternativeTestValue() {
107 return 'android-app:' . $this->randomMachineName();
111 * Implements {tag_name}TestOutputXpath() for 'android-app-link-alternative'.
113 private function androidAppLinkAlternativeTestOutputXpath() {
114 return "//link[@rel='alternate' and starts-with(@href, 'android-app:')]";
118 * Implements {tag_name}TestValueAttribute().
120 * For 'android-app-link-alternative'.
122 private function androidAppLinkAlternativeTestValueAttribute() {
127 * Implements {tag_name}TestOutputXpath() for 'android_manifest'.
129 private function androidManifestTestOutputXpath() {
130 return "//link[@rel='manifest']";
134 * Implements {tag_name}TestValueAttribute() for 'android_manifest'.
136 private function androidManifestTestValueAttribute() {
141 * Implements {tag_name}TestNameAttribute() for 'cleartype'.
143 private function cleartypeTestNameAttribute() {
148 * Implements {tag_name}TestOutputXpath() for 'handheldfriendly'.
150 private function handheldfriendlyTestOutputXpath() {
151 return "//meta[@name='HandheldFriendly']";
155 * Implements {tag_name}TestValue() for 'ios_app_link_alternative'.
157 private function iosAppLinkAlternativeTestValue() {
158 return 'ios-app:' . $this->randomMachineName();
162 * Implements {tag_name}TestOutputXpath() for 'ios_app_link_alternative'.
164 private function iosAppLinkAlternativeTestOutputXpath() {
165 return "//link[@rel='alternate' and starts-with(@href, 'ios-app:')]";
169 * Implements {tag_name}TestValueAttribute() for 'ios_app_link_alternative'.
171 private function iosAppLinkAlternativeTestValueAttribute() {
176 * Implements {tag_name}TestOutputXpath() for 'mobileoptimized'.
178 private function mobileoptimizedTestOutputXpath() {
179 return "//meta[@name='MobileOptimized']";
183 * Implements {tag_name}TestValue() for 'msapplication-square150x150logo'.
185 private function msapplicationSquare150x150logoTestValue() {
186 return $this->randomImageUrl();
190 * Implements {tag_name}TestValue() for 'msapplication-square310x310logo'.
192 private function msapplicationSquare310x310logoTestValue() {
193 return $this->randomImageUrl();
197 * Implements {tag_name}TestValue() for 'msapplication-square70x70logo'.
199 private function msapplicationSquare70x70logoTestValue() {
200 return $this->randomImageUrl();
204 * Implements {tag_name}TestValue() for 'msapplication-tileimage'.
206 private function msapplicationTileimageTestValue() {
207 return $this->randomImageUrl();
211 * Implements {tag_name}TestValue() for 'msapplication-wide310x150logo'.
213 private function msapplicationWide310x150logoTestValue() {
214 return $this->randomImageUrl();
218 * Implements {tag_name}TestOutputXpath() for 'web_manifest'.
220 private function webManifestTestOutputXpath() {
221 return "//link[@rel='manifest']";
225 * Implements {tag_name}TestValueAttribute() for 'web_manifest'.
227 private function webManifestTestValueAttribute() {
232 * Implements {tag_name}TestNameAttribute() for 'x-ua-compatible'.
234 private function xUaCompatibleTestNameAttribute() {