metatag_twitter_cards.tags.test 3.1 KB

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