metatag.tags.test 6.5 KB

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