metatag_mobile.tags.test 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <?php
  2. /**
  3. * Tests that each of the Metatag Mobile tags work correctly.
  4. */
  5. class MetatagMobileTagsTest extends MetatagTagsTestBase {
  6. /**
  7. * {@inheritdoc}
  8. */
  9. public static function getInfo() {
  10. return array(
  11. 'name' => 'Metatag tags: Mobile',
  12. 'description' => 'Test the mobile meta tags.',
  13. 'group' => 'Metatag',
  14. );
  15. }
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public $tags = array(
  20. 'alternate_handheld',
  21. 'amphtml',
  22. 'android-app-link-alternative',
  23. 'android-manifest',
  24. 'apple-itunes-app',
  25. 'apple-mobile-web-app-capable',
  26. 'apple-mobile-web-app-status-bar-style',
  27. 'apple-mobile-web-app-title',
  28. 'application-name',
  29. 'cleartype',
  30. 'format-detection',
  31. 'HandheldFriendly',
  32. 'ios-app-link-alternative',
  33. 'MobileOptimized',
  34. 'msapplication-allowDomainApiCalls',
  35. 'msapplication-allowDomainMetaTags',
  36. 'msapplication-badge',
  37. 'msapplication-config',
  38. 'msapplication-navbutton-color',
  39. 'msapplication-notification',
  40. 'msapplication-square150x150logo',
  41. 'msapplication-square310x310logo',
  42. 'msapplication-square70x70logo',
  43. 'msapplication-starturl',
  44. 'msapplication-task',
  45. 'msapplication-task-separator',
  46. 'msapplication-tilecolor',
  47. 'msapplication-tileimage',
  48. 'msapplication-tooltip',
  49. 'msapplication-wide310x150logo',
  50. 'msapplication-window',
  51. 'theme-color',
  52. 'viewport',
  53. 'x-ua-compatible',
  54. );
  55. /**
  56. * {@inheritdoc}
  57. */
  58. function setUp(array $modules = array()) {
  59. $modules[] = 'metatag_mobile';
  60. parent::setUp($modules);
  61. }
  62. /**
  63. * {@inheritdoc}
  64. */
  65. public function getTestTagName($tag_name) {
  66. // These tags all use dashes instead of underlines.
  67. $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);
  71. return $tag_name;
  72. }
  73. /**
  74. * Implements {meta_tag_name}_test_output_xpath() for 'alternate-handheld'.
  75. */
  76. public function alternate_handheld_test_output_xpath() {
  77. return "//link[@rel='alternate' and @media='handheld']";
  78. }
  79. /**
  80. * Implements {meta_tag_name}_test_value_attribute() for 'alternate-handheld'.
  81. */
  82. public function alternate_handheld_test_value_attribute() {
  83. return 'href';
  84. }
  85. /**
  86. * Implements {meta_tag_name}_test_output_xpath() for 'amphtml'.
  87. */
  88. public function amphtml_test_output_xpath() {
  89. return "//link[@rel='amphtml']";
  90. }
  91. /**
  92. * Implements {meta_tag_name}_test_value_attribute() for 'amphtml'.
  93. */
  94. public function amphtml_test_value_attribute() {
  95. return 'href';
  96. }
  97. /**
  98. * Implements {meta_tag_name}_test_output_xpath() for
  99. * 'android-app-link-alternative'.
  100. */
  101. public function android_app_link_alternative_test_output_xpath() {
  102. return "//link[@rel='alternate' and starts-with(@href, 'android-app:')]";
  103. }
  104. /**
  105. * Implements {meta_tag_name}_test_preprocess_output() for
  106. * 'android-app-link-alternative'.
  107. */
  108. public function android_app_link_alternative_test_preprocess_output($string) {
  109. return 'android-app://' . $string;
  110. }
  111. /**
  112. * Implements {meta_tag_name}_test_value_attribute() for
  113. * 'android-app-link-alternative'.
  114. */
  115. public function android_app_link_alternative_test_value_attribute() {
  116. return 'href';
  117. }
  118. /**
  119. * Implements {meta_tag_name}_test_output_xpath() for 'android_manifest'.
  120. */
  121. public function android_manifest_test_output_xpath() {
  122. return "//link[@rel='manifest']";
  123. }
  124. /**
  125. * Implements {meta_tag_name}_test_value_attribute() for 'android_manifest'.
  126. */
  127. public function android_manifest_test_value_attribute() {
  128. return 'href';
  129. }
  130. /**
  131. * Implements {meta_tag_name}_test_name_attribute() for 'cleartype'.
  132. */
  133. public function cleartype_test_name_attribute() {
  134. return 'http-equiv';
  135. }
  136. /**
  137. * Implements {meta_tag_name}_test_output_xpath() for
  138. * 'ios_app_link_alternative'.
  139. */
  140. public function ios_app_link_alternative_test_output_xpath() {
  141. return "//link[@rel='alternate' and starts-with(@href, 'ios-app:')]";
  142. }
  143. /**
  144. * Implements {meta_tag_name}_test_output_prefix() for
  145. * 'ios_app_link_alternative'.
  146. */
  147. public function ios_app_link_alternative_test_preprocess_output($string) {
  148. return 'ios-app://' . $string;
  149. }
  150. /**
  151. * Implements {meta_tag_name}_test_value_attribute() for
  152. * 'ios_app_link_alternative'.
  153. */
  154. public function ios_app_link_alternative_test_value_attribute() {
  155. return 'href';
  156. }
  157. /**
  158. * Implements {meta_tag_name}_test_value() for 'msapplication-square150x150logo'.
  159. */
  160. public function msapplication_square150x150logo_test_value() {
  161. return $this->randomImageUrl();
  162. }
  163. /**
  164. * Implements {meta_tag_name}_test_value() for 'msapplication-square310x310logo'.
  165. */
  166. public function msapplication_square310x310logo_test_value() {
  167. return $this->randomImageUrl();
  168. }
  169. /**
  170. * Implements {meta_tag_name}_test_value() for 'msapplication-square70x70logo'.
  171. */
  172. public function msapplication_square70x70logo_test_value() {
  173. return $this->randomImageUrl();
  174. }
  175. /**
  176. * Implements {meta_tag_name}_test_value() for 'msapplication-tileimage'.
  177. */
  178. public function msapplication_tileimage_test_value() {
  179. return $this->randomImageUrl();
  180. }
  181. /**
  182. * Implements {meta_tag_name}_test_value() for 'msapplication-wide310x150logo'.
  183. */
  184. public function msapplication_wide310x150logo_test_value() {
  185. return $this->randomImageUrl();
  186. }
  187. /**
  188. * Implements {meta_tag_name}_test_name_attribute() for 'x-ua-compatible'.
  189. */
  190. public function x_ua_compatible_test_name_attribute() {
  191. return 'http-equiv';
  192. }
  193. }