metatag.tags.test 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <?php
  2. /**
  3. * Tests that each of the Metatag base tags work correctly.
  4. */
  5. class MetatagTagsTest extends MetatagTagsTestBase {
  6. /**
  7. * {@inheritdoc}
  8. */
  9. public static function getInfo() {
  10. return array(
  11. 'name' => 'Metatag tags: Basic',
  12. 'description' => 'Test the basic meta tags.',
  13. 'group' => 'Metatag',
  14. 'dependencies' => array('ctools', 'token'),
  15. );
  16. }
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public $tags = array(
  21. 'abstract',
  22. 'cache-control',
  23. 'canonical',
  24. 'content-language',
  25. 'description',
  26. 'expires',
  27. 'generator',
  28. 'geo.placename',
  29. 'geo.position',
  30. 'geo.region',
  31. 'icbm',
  32. 'image_src',
  33. 'keywords',
  34. 'news_keywords',
  35. 'next',
  36. 'original-source',
  37. 'pragma',
  38. 'prev',
  39. 'rating',
  40. 'referrer',
  41. 'refresh',
  42. // @todo 'revisit-after',
  43. 'rights',
  44. 'robots',
  45. 'shortlink',
  46. 'standout',
  47. 'title',
  48. );
  49. /**
  50. * Implements {meta_tag_name}_test_field_xpath() for 'abstract'.
  51. */
  52. public function abstract_test_field_xpath() {
  53. return "//textarea[@name='metatags[und][abstract][value]']";
  54. }
  55. /**
  56. * Implements {meta_tag_name}_test_output_xpath() for 'cache_control'.
  57. */
  58. public function cache_control_test_output_xpath() {
  59. return "//meta[@http-equiv='cache-control']";
  60. }
  61. /**
  62. * Implements {meta_tag_name}_test_value_attribute() for 'canonical'.
  63. */
  64. public function canonical_test_value_attribute() {
  65. return 'href';
  66. }
  67. /**
  68. * Implements {meta_tag_name}_test_output_xpath() for 'canonical'.
  69. */
  70. public function canonical_test_output_xpath() {
  71. return "//link[@rel='canonical']";
  72. }
  73. /**
  74. * Implements {meta_tag_name}_test_name_attribute() for 'content_language'.
  75. */
  76. public function content_language_test_name_attribute() {
  77. return 'http-equiv';
  78. }
  79. /**
  80. * Implements {meta_tag_name}_test_tag_name() for 'content_language'.
  81. */
  82. public function content_language_test_tag_name() {
  83. return 'content-language';
  84. }
  85. /**
  86. * Implements {meta_tag_name}_test_field_xpath() for 'description'.
  87. */
  88. public function description_test_field_xpath() {
  89. return "//textarea[@name='metatags[und][description][value]']";
  90. }
  91. /**
  92. * Implements {meta_tag_name}_test_tag_name() for 'geo_placename'.
  93. */
  94. public function geo_placename_test_tag_name() {
  95. return 'geo.placename';
  96. }
  97. /**
  98. * Implements {meta_tag_name}_test_tag_name() for 'geo_position'.
  99. */
  100. public function geo_position_test_tag_name() {
  101. return 'geo.position';
  102. }
  103. /**
  104. * Implements {meta_tag_name}_test_tag_name() for 'geo_region'.
  105. */
  106. public function geo_region_test_tag_name() {
  107. return 'geo.region';
  108. }
  109. /**
  110. * Implements {meta_tag_name}_test_output_xpath() for 'image_src'.
  111. */
  112. public function image_src_test_output_xpath() {
  113. return "//link[@rel='image_src']";
  114. }
  115. /**
  116. * Implements {meta_tag_name}_test_value_attribute() for 'image_src'.
  117. */
  118. public function image_src_test_value_attribute() {
  119. return 'href';
  120. }
  121. /**
  122. * Implements {meta_tag_name}_test_value() for 'image_src'.
  123. */
  124. public function image_src_test_value() {
  125. return 'http://example.com/images/test-image.gif';
  126. }
  127. /**
  128. * Implements {meta_tag_name}_test_output_xpath() for 'next'.
  129. */
  130. public function next_test_output_xpath() {
  131. return "//link[@rel='next']";
  132. }
  133. /**
  134. * Implements {meta_tag_name}_test_value_attribute() for 'next'.
  135. */
  136. public function next_test_value_attribute() {
  137. return 'href';
  138. }
  139. /**
  140. * Implements {meta_tag_name}_test_tag_name() for 'original-source'.
  141. */
  142. public function original_source_test_tag_name() {
  143. return 'original-source';
  144. }
  145. /**
  146. * Implements {meta_tag_name}_test_name_attribute() for 'pragma'.
  147. */
  148. public function pragma_test_name_attribute() {
  149. return 'http-equiv';
  150. }
  151. /**
  152. * Implements {meta_tag_name}_test_output_xpath() for 'prev'.
  153. */
  154. public function prev_test_output_xpath() {
  155. return "//link[@rel='prev']";
  156. }
  157. /**
  158. * Implements {meta_tag_name}_test_value_attribute() for 'prev'.
  159. */
  160. public function prev_test_value_attribute() {
  161. return 'href';
  162. }
  163. /**
  164. * Implements {meta_tag_name}_test_key() for 'rating'.
  165. */
  166. public function rating_test_key() {
  167. return 'metatags[und][rating][value]';
  168. }
  169. /**
  170. * Implements {meta_tag_name}_test_value() for 'general'.
  171. */
  172. public function rating_test_value() {
  173. return 'general';
  174. }
  175. /**
  176. * Implements {meta_tag_name}_test_field_xpath() for 'rating'.
  177. */
  178. public function rating_test_field_xpath() {
  179. return "//select[@name='metatags[und][rating][value]']";
  180. }
  181. /**
  182. * Implements {meta_tag_name}_test_key() for 'referrer'.
  183. */
  184. public function referrer_test_key() {
  185. return 'metatags[und][referrer][value]';
  186. }
  187. /**
  188. * Implements {meta_tag_name}_test_value() for 'referrer'.
  189. */
  190. public function referrer_test_value() {
  191. return 'origin';
  192. }
  193. /**
  194. * Implements {meta_tag_name}_test_field_xpath() for 'referrer'.
  195. */
  196. public function referrer_test_field_xpath() {
  197. return "//select[@name='metatags[und][referrer][value]']";
  198. }
  199. /**
  200. * Implements {meta_tag_name}_test_name_attribute() for 'refresh'.
  201. */
  202. public function refresh_test_name_attribute() {
  203. return 'http-equiv';
  204. }
  205. /**
  206. * Implements {meta_tag_name}_test_value() for 'robots'.
  207. */
  208. public function robots_test_key() {
  209. return 'metatags[und][robots][value][index]';
  210. }
  211. /**
  212. * Implements {meta_tag_name}_test_value() for 'robots'.
  213. */
  214. public function robots_test_value() {
  215. return TRUE;
  216. }
  217. /**
  218. * Implements {meta_tag_name}_test_field_xpath() for 'robots'.
  219. */
  220. public function robots_test_field_xpath() {
  221. return "//input[@name='metatags[und][robots][value][index]' and @type='checkbox']";
  222. }
  223. /**
  224. * Implements {meta_tag_name}_test_value() for 'revisit-after'.
  225. */
  226. public function revisit_after_test_value() {
  227. return 2;
  228. }
  229. /**
  230. * Implements {meta_tag_name}_test_output_xpath() for 'shortlink'.
  231. */
  232. public function shortlink_test_output_xpath() {
  233. return "//link[@rel='shortlink']";
  234. }
  235. /**
  236. * Implements {meta_tag_name}_test_value_attribute() for 'shortlink'.
  237. */
  238. public function shortlink_test_value_attribute() {
  239. return 'href';
  240. }
  241. /**
  242. * Implements {meta_tag_name}_test_output_xpath() for 'title'.
  243. */
  244. public function title_test_output_xpath() {
  245. return "//title";
  246. }
  247. /**
  248. * Implements {meta_tag_name}_test_value_attribute() for 'title';
  249. */
  250. public function title_test_value_attribute() {
  251. return '';
  252. }
  253. }