metatag_mobile.tags.test 5.7 KB

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