metatag_twitter_cards.tags.test 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /**
  3. * @file
  4. * Tests that each of the Metatag Twitter Cards tags work correctly.
  5. */
  6. /**
  7. * Tests that each of the Metatag Twitter Cards tags work correctly.
  8. */
  9. class MetatagTwitterCardsTagsTest extends MetatagTagsTestBase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Metatag tags: Twitter Cards',
  16. 'description' => 'Test the Twitter Cards meta tags.',
  17. 'group' => 'Metatag',
  18. );
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public $tags = array(
  24. 'twitter:app:country',
  25. 'twitter:app:id:googleplay',
  26. 'twitter:app:id:ipad',
  27. 'twitter:app:id:iphone',
  28. 'twitter:app:name:googleplay',
  29. 'twitter:app:name:ipad',
  30. 'twitter:app:name:iphone',
  31. 'twitter:app:url:googleplay',
  32. 'twitter:app:url:ipad',
  33. 'twitter:app:url:iphone',
  34. 'twitter:card',
  35. 'twitter:creator',
  36. 'twitter:creator:id',
  37. 'twitter:data1',
  38. 'twitter:data2',
  39. 'twitter:description',
  40. 'twitter:dnt',
  41. 'twitter:image',
  42. 'twitter:image0',
  43. 'twitter:image1',
  44. 'twitter:image2',
  45. 'twitter:image3',
  46. 'twitter:image:alt',
  47. 'twitter:image:height',
  48. 'twitter:image:width',
  49. 'twitter:label1',
  50. 'twitter:label2',
  51. 'twitter:player',
  52. 'twitter:player:height',
  53. 'twitter:player:stream',
  54. 'twitter:player:stream:content_type',
  55. 'twitter:player:width',
  56. 'twitter:site',
  57. 'twitter:site:id',
  58. 'twitter:title',
  59. 'twitter:url',
  60. );
  61. /**
  62. * {@inheritdoc}
  63. */
  64. function setUp(array $modules = array()) {
  65. $modules[] = 'metatag_twitter_cards';
  66. parent::setUp($modules);
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public function getTestTagName($tag_name) {
  72. // All OG tags use colons to separate levels.
  73. $tag_name = str_replace('_', ':', $tag_name);
  74. // Fix a few specific tags.
  75. $tag_name = str_replace('content:type', 'content_type', $tag_name);
  76. return $tag_name;
  77. }
  78. /**
  79. * Implements {meta_tag_name}_test_key() for 'twitter:card'.
  80. */
  81. public function twitter_card_test_key() {
  82. return 'metatags[und][twitter:card][value]';
  83. }
  84. /**
  85. * Implements {meta_tag_name}_test_value() for 'twitter:card'.
  86. */
  87. public function twitter_card_test_value() {
  88. return 'summary';
  89. }
  90. /**
  91. * Implements {meta_tag_name}_test_field_xpath() for 'twitter:card'.
  92. */
  93. public function twitter_card_test_field_xpath() {
  94. return "//select[@name='metatags[und][twitter:card][value]']";
  95. }
  96. /**
  97. * Implements {meta_tag_name}_test_value() for 'twitter:image'.
  98. */
  99. public function twitter_image_test_value() {
  100. return $this->randomImageUrl();
  101. }
  102. /**
  103. * Implements {meta_tag_name}_test_value() for 'twitter:image0'.
  104. */
  105. public function twitter_image0_test_value() {
  106. return $this->randomImageUrl();
  107. }
  108. /**
  109. * Implements {meta_tag_name}_test_value() for 'twitter:image1'.
  110. */
  111. public function twitter_image1_test_value() {
  112. return $this->randomImageUrl();
  113. }
  114. /**
  115. * Implements {meta_tag_name}_test_value() for 'twitter:image2'.
  116. */
  117. public function twitter_image2_test_value() {
  118. return $this->randomImageUrl();
  119. }
  120. /**
  121. * Implements {meta_tag_name}_test_value() for 'twitter:image3'.
  122. */
  123. public function twitter_image3_test_value() {
  124. return $this->randomImageUrl();
  125. }
  126. }