metatag_opengraph.tags.test 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. /**
  3. * @file
  4. * Tests that each of the Metatag OpenGraph tags work correctly.
  5. */
  6. /**
  7. * Tests that each of the Metatag OpenGraph tags work correctly.
  8. */
  9. class MetatagOpenGraphTagsTest extends MetatagTagsTestBase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Metatag tags: OpenGraph',
  16. 'description' => 'Test the OpenGraph meta tags.',
  17. 'group' => 'Metatag',
  18. );
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public $tags = array(
  24. 'article:author',
  25. 'article:expiration_time',
  26. 'article:modified_time',
  27. 'article:published_time',
  28. 'article:publisher',
  29. 'article:section',
  30. 'article:tag',
  31. 'book:author',
  32. 'book:isbn',
  33. 'book:release_date',
  34. 'book:tag',
  35. 'og:audio',
  36. 'og:audio:secure_url',
  37. 'og:audio:type',
  38. 'og:country_name',
  39. 'og:description',
  40. 'og:determiner',
  41. 'og:email',
  42. 'og:fax_number',
  43. 'og:image',
  44. 'og:image:height',
  45. 'og:image:secure_url',
  46. 'og:image:type',
  47. 'og:image:url',
  48. 'og:image:width',
  49. 'og:latitude',
  50. 'og:locale',
  51. 'og:locale:alternate',
  52. 'og:locality',
  53. 'og:longitude',
  54. 'og:phone_number',
  55. 'og:postal_code',
  56. 'og:region',
  57. 'og:see_also',
  58. 'og:site_name',
  59. 'og:street_address',
  60. 'og:title',
  61. 'og:type',
  62. 'og:updated_time',
  63. 'og:url',
  64. 'og:video:height',
  65. 'og:video:secure_url',
  66. 'og:video:type',
  67. 'og:video:url',
  68. 'og:video:width',
  69. 'profile:first_name',
  70. 'profile:gender',
  71. 'profile:last_name',
  72. 'profile:username',
  73. 'video:actor',
  74. 'video:actor:role',
  75. 'video:director',
  76. 'video:duration',
  77. 'video:release_date',
  78. 'video:series',
  79. 'video:tag',
  80. 'video:writer',
  81. );
  82. /**
  83. * {@inheritdoc}
  84. */
  85. function setUp(array $modules = array()) {
  86. $modules[] = 'metatag_opengraph';
  87. parent::setUp($modules);
  88. }
  89. /**
  90. * {@inheritdoc}
  91. */
  92. public $test_name_attribute = 'property';
  93. /**
  94. * {@inheritdoc}
  95. */
  96. public function getTestTagName($tag_name) {
  97. // All OG tags use colons to separate levels.
  98. $tag_name = str_replace('_', ':', $tag_name);
  99. // Fix a few specific tags.
  100. $tag_name = str_replace('secure:url', 'secure_url', $tag_name);
  101. $tag_name = str_replace(':time', '_time', $tag_name);
  102. $tag_name = str_replace(':date', '_date', $tag_name);
  103. $tag_name = str_replace(':name', '_name', $tag_name);
  104. $tag_name = str_replace(':address', '_address', $tag_name);
  105. $tag_name = str_replace('see:also', 'see_also', $tag_name);
  106. $tag_name = str_replace(':number', '_number', $tag_name);
  107. $tag_name = str_replace(':code', '_code', $tag_name);
  108. return $tag_name;
  109. }
  110. /**
  111. * Implements {meta_tag_name}_test_key() for 'og:type'.
  112. */
  113. public function og_type_test_key() {
  114. return 'metatags[und][og:type][value]';
  115. }
  116. /**
  117. * Implements {meta_tag_name}_test_value() for 'og:type'.
  118. */
  119. public function og_type_test_value() {
  120. return 'article';
  121. }
  122. /**
  123. * Implements {meta_tag_name}_test_field_xpath() for 'og:type'.
  124. */
  125. public function og_type_test_field_xpath() {
  126. return "//select[@name='metatags[und][og:type][value]']";
  127. }
  128. /**
  129. * Implements {meta_tag_name}_test_key() for 'og:determiner'.
  130. */
  131. public function og_determiner_test_key() {
  132. return 'metatags[und][og:determiner][value]';
  133. }
  134. /**
  135. * Implements {meta_tag_name}_test_value() for 'og:determiner'.
  136. */
  137. public function og_determiner_test_value() {
  138. return 'a';
  139. }
  140. /**
  141. * Implements {meta_tag_name}_test_field_xpath() for 'og:determiner'.
  142. */
  143. public function og_determiner_test_field_xpath() {
  144. return "//select[@name='metatags[und][og:determiner][value]']";
  145. }
  146. /**
  147. * Implements {meta_tag_name}_test_value() for 'og:image'.
  148. */
  149. public function og_image_test_value() {
  150. return $this->randomImageUrl();
  151. }
  152. /**
  153. * Implements {meta_tag_name}_test_value() for 'og:image:url'.
  154. */
  155. public function og_image_url_test_value() {
  156. return $this->randomImageUrl();
  157. }
  158. /**
  159. * Implements {meta_tag_name}_test_value() for 'og:image:secure_url'.
  160. */
  161. public function og_image_secure_url_test_value() {
  162. return str_replace('http://', 'https://', $this->randomImageUrl());
  163. }
  164. }