metatag_google_plus.tags.test 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * Tests that each of the Metatag GooglePlus tags work correctly.
  4. */
  5. class MetatagGooglePlusTagsTest extends MetatagTagsTestBase {
  6. /**
  7. * {@inheritdoc}
  8. */
  9. public static function getInfo() {
  10. return array(
  11. 'name' => 'Metatag tags: GooglePlus',
  12. 'description' => 'Test the Google Plus meta tags.',
  13. 'group' => 'Metatag',
  14. );
  15. }
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public $tags = array(
  20. // @todo Can't test the output of this tag, it depends upon changes to the
  21. // html.tpl.php file.
  22. // 'itemtype',
  23. 'itemprop:name',
  24. 'itemprop:description',
  25. 'itemprop:image',
  26. 'author',
  27. 'publisher',
  28. );
  29. /**
  30. * {@inheritdoc}
  31. */
  32. function setUp(array $modules = array()) {
  33. $modules[] = 'metatag_google_plus';
  34. parent::setUp($modules);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function getTestTagName($tag_name) {
  40. // The itemprop meta tags don't have 'itemprop' in their attribute value,
  41. // 'itemprop' is the name of the attribute itself.
  42. return str_replace('itemprop_', '', $tag_name);
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public $test_name_attribute = 'itemprop';
  48. /**
  49. * Implements {meta_tag_name}_test_output_xpath() for 'author'.
  50. */
  51. public function author_test_output_xpath() {
  52. return "//link[@rel='author']";
  53. }
  54. /**
  55. * Implements {meta_tag_name}_test_value_attribute() for 'author'.
  56. */
  57. public function author_test_value_attribute() {
  58. return 'href';
  59. }
  60. /**
  61. * Implements {meta_tag_name}_test_key() for 'itemtype'.
  62. */
  63. public function itemtype_test_key() {
  64. return 'metatags[und][itemtype][value]';
  65. }
  66. /**
  67. * Implements {meta_tag_name}_test_value() for 'itemtype'.
  68. */
  69. public function itemtype_test_value() {
  70. return 'Article';
  71. }
  72. /**
  73. * Implements {meta_tag_name}_test_value() for 'itemprop_image'.
  74. */
  75. public function itemprop_image_test_value() {
  76. return $this->randomImageUrl();
  77. }
  78. /**
  79. * Implements {meta_tag_name}_test_field_xpath() for 'itemtype'.
  80. */
  81. public function itemtype_test_field_xpath() {
  82. return "//select[@name='metatags[und][itemtype][value]']";
  83. }
  84. /**
  85. * Implements {meta_tag_name}_test_output_xpath() for 'itemtype'.
  86. */
  87. public function itemtype_test_output_xpath() {
  88. return "//html[@rel='itemtype']";
  89. }
  90. /**
  91. * Implements {meta_tag_name}_test_output_xpath() for 'publisher'.
  92. */
  93. public function publisher_test_output_xpath() {
  94. return "//link[@rel='publisher']";
  95. }
  96. /**
  97. * Implements {meta_tag_name}_test_output_xpath() for 'publisher'.
  98. */
  99. public function publisher_test_value_attribute() {
  100. return 'href';
  101. }
  102. }