3 namespace Drupal\metatag_twitter_cards\Tests;
5 use Drupal\metatag\Tests\MetatagTagsTestBase;
8 * Tests that each of the Metatag Twitter Cards tags work correctly.
12 class MetatagTwitterCardsTagsTest extends MetatagTagsTestBase {
18 'twitter_cards_app_id_googleplay',
19 'twitter_cards_app_id_ipad',
20 'twitter_cards_app_id_iphone',
21 'twitter_cards_app_name_googleplay',
22 'twitter_cards_app_name_ipad',
23 'twitter_cards_app_name_iphone',
24 'twitter_cards_app_store_country',
25 'twitter_cards_app_url_googleplay',
26 'twitter_cards_app_url_ipad',
27 'twitter_cards_app_url_iphone',
28 'twitter_cards_creator',
29 'twitter_cards_creator_id',
30 'twitter_cards_data1',
31 'twitter_cards_data2',
32 'twitter_cards_description',
33 'twitter_cards_donottrack',
34 'twitter_cards_gallery_image0',
35 'twitter_cards_gallery_image1',
36 'twitter_cards_gallery_image2',
37 'twitter_cards_gallery_image3',
38 'twitter_cards_image',
39 'twitter_cards_image_alt',
40 'twitter_cards_image_height',
41 'twitter_cards_image_width',
42 'twitter_cards_label1',
43 'twitter_cards_label2',
44 'twitter_cards_page_url',
45 'twitter_cards_player',
46 'twitter_cards_player_height',
47 'twitter_cards_player_stream',
48 'twitter_cards_player_stream_content_type',
49 'twitter_cards_player_width',
51 'twitter_cards_site_id',
52 'twitter_cards_title',
59 protected function setUp() {
60 parent::$modules[] = 'metatag_twitter_cards';
65 * Twitter meta tags (almost) all have colons instead of underlines.
67 * They also don't have "cards" in their name.
69 private function getTestTagName($tag_name) {
70 $tag_name = str_replace('twitter_cards', 'twitter', $tag_name);
71 $tag_name = str_replace('_', ':', $tag_name);
73 if ($tag_name == 'twitter:app:store:country') {
74 $tag_name = 'twitter:app:country';
76 elseif ($tag_name == 'twitter:page:url') {
77 $tag_name = 'twitter:url';
79 elseif ($tag_name == 'twitter:player:stream:content:type') {
80 $tag_name = 'twitter:player:stream:content_type';
82 elseif ($tag_name == 'twitter:type') {
83 $tag_name = 'twitter:card';
85 elseif ($tag_name == 'twitter:donottrack') {
86 $tag_name = 'twitter:dnt';
93 * Implements {tag_name}TestFieldXpath() for 'twitter_cards_type'.
95 private function twitterCardsTypeTestFieldXpath() {
96 return "//select[@name='twitter_cards_type']";
100 * Implements {tag_name}TestValue() for 'twitter_cards_type'.
102 private function twitterCardsTypeTestValue() {
103 return 'summary_large_image';