Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / metatag / metatag_twitter_cards / src / Tests / MetatagTwitterCardsTagsTest.php
1 <?php
2
3 namespace Drupal\metatag_twitter_cards\Tests;
4
5 use Drupal\metatag\Tests\MetatagTagsTestBase;
6
7 /**
8  * Tests that each of the Metatag Twitter Cards tags work correctly.
9  *
10  * @group metatag
11  */
12 class MetatagTwitterCardsTagsTest extends MetatagTagsTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   private $tags = [
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',
50     'twitter_cards_site',
51     'twitter_cards_site_id',
52     'twitter_cards_title',
53     'twitter_cards_type',
54   ];
55
56   /**
57    * {@inheritdoc}
58    */
59   protected function setUp() {
60     parent::$modules[] = 'metatag_twitter_cards';
61     parent::setUp();
62   }
63
64   /**
65    * Twitter meta tags (almost) all have colons instead of underlines.
66    *
67    * They also don't have "cards" in their name.
68    */
69   private function getTestTagName($tag_name) {
70     $tag_name = str_replace('twitter_cards', 'twitter', $tag_name);
71     $tag_name = str_replace('_', ':', $tag_name);
72
73     if ($tag_name == 'twitter:app:store:country') {
74       $tag_name = 'twitter:app:country';
75     }
76     elseif ($tag_name == 'twitter:page:url') {
77       $tag_name = 'twitter:url';
78     }
79     elseif ($tag_name == 'twitter:player:stream:content:type') {
80       $tag_name = 'twitter:player:stream:content_type';
81     }
82     elseif ($tag_name == 'twitter:type') {
83       $tag_name = 'twitter:card';
84     }
85     elseif ($tag_name == 'twitter:donottrack') {
86       $tag_name = 'twitter:dnt';
87     }
88
89     return $tag_name;
90   }
91
92   /**
93    * Implements {tag_name}TestFieldXpath() for 'twitter_cards_type'.
94    */
95   private function twitterCardsTypeTestFieldXpath() {
96     return "//select[@name='twitter_cards_type']";
97   }
98
99   /**
100    * Implements {tag_name}TestValue() for 'twitter_cards_type'.
101    */
102   private function twitterCardsTypeTestValue() {
103     return 'summary_large_image';
104   }
105
106 }