3 namespace Drupal\metatag_mobile\Tests;
5 use Drupal\simpletest\WebTestBase;
6 use Drupal\metatag\Tests\MetatagTagsTestBase;
9 * Tests that each of the Metatag mobile tags work correctly.
13 class MetatagMobileTagsTest extends MetatagTagsTestBase {
19 'android_app_link_alternative',
22 'apple_mobile_web_app_capable',
23 'apple_mobile_web_app_status_bar_style',
24 'apple_mobile_web_app_title',
29 'ios_app_link_alternative',
31 'msapplication_allowDomainApiCalls',
32 'msapplication_allowDomainMetaTags',
33 'msapplication_badge',
34 'msapplication_config',
35 'msapplication_navbutton_color',
36 'msapplication_notification',
37 'msapplication_square150x150logo',
38 'msapplication_square310x310logo',
39 'msapplication_square70x70logo',
40 'msapplication_starturl',
42 'msapplication_task_separator',
43 'msapplication_tilecolor',
44 'msapplication_tileimage',
45 'msapplication_tooltip',
46 'msapplication_wide310x150logo',
47 'msapplication_window',
56 protected function setUp() {
57 parent::$modules[] = 'metatag_mobile';
64 public 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 {meta_tag_name}_test_output_xpath() for 'alternate-handheld'.
78 public function alternate_handheld_test_output_xpath() {
79 return "//link[@rel='alternate' and @media='handheld']";
83 * Implements {meta_tag_name}_test_value_attribute() for 'alternate-handheld'.
85 public function alternate_handheld_test_value_attribute() {
90 * Implements {meta_tag_name}_test_output_xpath() for 'amphtml'.
92 public function amphtml_test_output_xpath() {
93 return "//link[@rel='amphtml']";
97 * Implements {meta_tag_name}_test_value_attribute() for 'amphtml'.
99 public function amphtml_test_value_attribute() {
104 * Implements {meta_tag_name}_test_value() for 'android_app_link_alternative'.
106 public function android_app_link_alternative_test_value() {
107 return 'android-app:' . $this->randomMachineName();
111 * Implements {meta_tag_name}_test_output_xpath() for
112 * 'android-app-link-alternative'.
114 public function android_app_link_alternative_test_output_xpath() {
115 return "//link[@rel='alternate' and starts-with(@href, 'android-app:')]";
119 * Implements {meta_tag_name}_test_preprocess_output() for
120 * 'android-app-link-alternative'.
122 public function android_app_link_alternative_test_preprocess_output($string) {
123 return 'android-app://' . $string;
127 * Implements {meta_tag_name}_test_value_attribute() for
128 * 'android-app-link-alternative'.
130 public function android_app_link_alternative_test_value_attribute() {
135 * Implements {meta_tag_name}_test_output_xpath() for 'android_manifest'.
137 public function android_manifest_test_output_xpath() {
138 return "//link[@rel='manifest']";
142 * Implements {meta_tag_name}_test_value_attribute() for 'android_manifest'.
144 public function android_manifest_test_value_attribute() {
149 * Implements {meta_tag_name}_test_name_attribute() for 'cleartype'.
151 public function cleartype_test_name_attribute() {
156 * Implements {meta_tag_name}_test_output_xpath() for 'handheldfriendly'.
158 public function handheldfriendly_test_output_xpath() {
159 return "//meta[@name='HandheldFriendly']";
163 * Implements {meta_tag_name}_test_value() for
164 * 'ios_app_link_alternative'.
166 public function ios_app_link_alternative_test_value() {
167 return 'ios-app:' . $this->randomMachineName();
171 * Implements {meta_tag_name}_test_output_xpath() for
172 * 'ios_app_link_alternative'.
174 public function ios_app_link_alternative_test_output_xpath() {
175 return "//link[@rel='alternate' and starts-with(@href, 'ios-app:')]";
179 * Implements {meta_tag_name}_test_output_prefix() for
180 * 'ios_app_link_alternative'.
182 public function ios_app_link_alternative_test_preprocess_output($string) {
183 return 'ios-app://' . $string;
187 * Implements {meta_tag_name}_test_value_attribute() for
188 * 'ios_app_link_alternative'.
190 public function ios_app_link_alternative_test_value_attribute() {
195 * Implements {meta_tag_name}_test_output_xpath() for 'mobileoptimized'.
197 public function mobileoptimized_test_output_xpath() {
198 return "//meta[@name='MobileOptimized']";
202 * Implements {meta_tag_name}_test_value() for 'msapplication-square150x150logo'.
204 public function msapplication_square150x150logo_test_value() {
205 return $this->randomImageUrl();
209 * Implements {meta_tag_name}_test_value() for 'msapplication-square310x310logo'.
211 public function msapplication_square310x310logo_test_value() {
212 return $this->randomImageUrl();
216 * Implements {meta_tag_name}_test_value() for 'msapplication-square70x70logo'.
218 public function msapplication_square70x70logo_test_value() {
219 return $this->randomImageUrl();
223 * Implements {meta_tag_name}_test_value() for 'msapplication-tileimage'.
225 public function msapplication_tileimage_test_value() {
226 return $this->randomImageUrl();
230 * Implements {meta_tag_name}_test_value() for 'msapplication-wide310x150logo'.
232 public function msapplication_wide310x150logo_test_value() {
233 return $this->randomImageUrl();
237 * Implements {meta_tag_name}_test_name_attribute() for 'x-ua-compatible'.
239 public function x_ua_compatible_test_name_attribute() {