Yaffs site version 1.1
[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\simpletest\WebTestBase;
6 use Drupal\metatag\Tests\MetatagTagsTestBase;
7
8 /**
9  * Tests that each of the Metatag Twitter Cards tags work correctly.
10  *
11  * @group metatag
12  */
13 class MetatagTwitterCardsTagsTest extends MetatagTagsTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public $tags = [
19     'twitter_cards_app_id_googleplay',
20     'twitter_cards_app_id_ipad',
21     'twitter_cards_app_id_iphone',
22     'twitter_cards_app_name_googleplay',
23     'twitter_cards_app_name_ipad',
24     'twitter_cards_app_name_iphone',
25     'twitter_cards_app_store_country',
26     'twitter_cards_app_url_googleplay',
27     'twitter_cards_app_url_ipad',
28     'twitter_cards_app_url_iphone',
29     'twitter_cards_creator',
30     'twitter_cards_creator_id',
31     'twitter_cards_data1',
32     'twitter_cards_data2',
33     'twitter_cards_description',
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, and they
66    * don't have "cards" in their name.
67    */
68   public function getTestTagName($tag_name) {
69     $tag_name = str_replace('twitter_cards', 'twitter', $tag_name);
70     $tag_name = str_replace('_', ':', $tag_name);
71
72     if ($tag_name == 'twitter:app:store:country') {
73       $tag_name = 'twitter:app:country';
74     }
75     elseif ($tag_name == 'twitter:page:url') {
76       $tag_name = 'twitter:url';
77     }
78     elseif ($tag_name == 'twitter:player:stream:content:type') {
79       $tag_name = 'twitter:player:stream:content_type';
80     }
81     elseif ($tag_name == 'twitter:type') {
82       $tag_name = 'twitter:card';
83     }
84     elseif ($tag_name == '') {
85       $tag_name = '';
86     }
87
88     return $tag_name;
89   }
90
91   /**
92    * Implements {meta_tag_name}_test_field_xpath() for 'twitter_cards_type'.
93    */
94   public function twitter_cards_type_test_field_xpath() {
95     return "//select[@name='twitter_cards_type']";
96   }
97
98   /**
99    * Implements {meta_tag_name}_test_value() for 'twitter_cards_type'.
100    */
101   public function twitter_cards_type_test_value() {
102     return 'summary_large_image';
103   }
104
105 }