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',
55 protected function setUp() {
56 parent::$modules[] = 'metatag_mobile';
63 private function getTestTagName($tag_name) {
64 // These tags all use dashes instead of underlines.
65 $tag_name = str_replace('_', '-', $tag_name);
67 // Fix a few specific tags.
68 $tag_name = str_replace('mobileoptimized', 'MobileOptimized', $tag_name);
69 $tag_name = str_replace('handheldfriendly', 'HandheldFriendly', $tag_name);
75 * Implements {tag_name}TestOutputXpath() for 'alternate-handheld'.
77 private function alternateHandheldTestOutputXpath() {
78 return "//link[@rel='alternate' and @media='handheld']";
82 * Implements {tag_name}TestValueAttribute() for 'alternate-handheld'.
84 private function alternateHandheldTestValueAttribute() {
89 * Implements {tag_name}TestOutputXpath() for 'amphtml'.
91 private function amphtmlTestOutputXpath() {
92 return "//link[@rel='amphtml']";
96 * Implements {tag_name}TestValueAttribute() for 'amphtml'.
98 private function amphtmlTestValueAttribute() {
103 * Implements {tag_name}TestValue() for 'android_app_link_alternative'.
105 private function androidAppLinkAlternativeTestValue() {
106 return 'android-app:' . $this->randomMachineName();
110 * Implements {tag_name}TestOutputXpath() for 'android-app-link-alternative'.
112 private function androidAppLinkAlternativeTestOutputXpath() {
113 return "//link[@rel='alternate' and starts-with(@href, 'android-app:')]";
117 * Implements {tag_name}TestValueAttribute() for
118 * 'android-app-link-alternative'.
120 private function androidAppLinkAlternativeTestValueAttribute() {
125 * Implements {tag_name}TestOutputXpath() for 'android_manifest'.
127 private function androidManifestTestOutputXpath() {
128 return "//link[@rel='manifest']";
132 * Implements {tag_name}TestValueAttribute() for 'android_manifest'.
134 private function androidManifestTestValueAttribute() {
139 * Implements {tag_name}TestNameAttribute() for 'cleartype'.
141 private function cleartypeTestNameAttribute() {
146 * Implements {tag_name}TestOutputXpath() for 'handheldfriendly'.
148 private function handheldfriendlyTestOutputXpath() {
149 return "//meta[@name='HandheldFriendly']";
153 * Implements {tag_name}TestValue() for 'ios_app_link_alternative'.
155 private function iosAppLinkAlternativeTestValue() {
156 return 'ios-app:' . $this->randomMachineName();
160 * Implements {tag_name}TestOutputXpath() for 'ios_app_link_alternative'.
162 private function iosAppLinkAlternativeTestOutputXpath() {
163 return "//link[@rel='alternate' and starts-with(@href, 'ios-app:')]";
167 * Implements {tag_name}TestValueAttribute() for 'ios_app_link_alternative'.
169 private function iosAppLinkAlternativeTestValueAttribute() {
174 * Implements {tag_name}TestOutputXpath() for 'mobileoptimized'.
176 private function mobileoptimizedTestOutputXpath() {
177 return "//meta[@name='MobileOptimized']";
181 * Implements {tag_name}TestValue() for 'msapplication-square150x150logo'.
183 private function msapplicationSquare150x150logoTestValue() {
184 return $this->randomImageUrl();
188 * Implements {tag_name}TestValue() for 'msapplication-square310x310logo'.
190 private function msapplicationSquare310x310logoTestValue() {
191 return $this->randomImageUrl();
195 * Implements {tag_name}TestValue() for 'msapplication-square70x70logo'.
197 private function msapplicationSquare70x70logoTestValue() {
198 return $this->randomImageUrl();
202 * Implements {tag_name}TestValue() for 'msapplication-tileimage'.
204 private function msapplicationTileimageTestValue() {
205 return $this->randomImageUrl();
209 * Implements {tag_name}TestValue() for 'msapplication-wide310x150logo'.
211 private function msapplicationWide310x150logoTestValue() {
212 return $this->randomImageUrl();
216 * Implements {tag_name}TestNameAttribute() for 'x-ua-compatible'.
218 private function xUaCompatibleTestNameAttribute() {