52f6306c57c2d43f27b3bf9a26f1455dc9b4efb3
[yaffs-website] / web / modules / contrib / metatag / src / Tests / MetatagTagsTest.php
1 <?php
2
3 namespace Drupal\metatag\Tests;
4
5 use Drupal\simpletest\WebTestBase;
6 use Drupal\metatag\Tests\MetatagTagsTestBase;
7
8 /**
9  * Tests that each of the Metatag base tags work correctly.
10  *
11  * @group metatag
12  */
13 class MetatagTagsTest extends MetatagTagsTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public $tags = [
19     'abstract',
20     'canonical_url',
21     'content_language',
22     'description',
23     'generator',
24     'geo_placename',
25     'geo_position',
26     'geo_region',
27     'icbm',
28     'image_src',
29     'keywords',
30     'news_keywords',
31     'original_source',
32     'referrer',
33     'rights',
34     'robots',
35     'shortlink',
36     'standout',
37     'title',
38   ];
39
40   /**
41    * Each of these meta tags has a different tag name vs its internal name.
42    */
43   public function getTestTagName($tag_name) {
44     if ($tag_name == 'geo_placename') {
45       $tag_name = 'geo.placename';
46     }
47     elseif ($tag_name == 'geo_position') {
48       $tag_name = 'geo.position';
49     }
50     elseif ($tag_name == 'geo_region') {
51       $tag_name = 'geo.region';
52     }
53     elseif ($tag_name == 'content_language') {
54       $tag_name = 'content-language';
55     }
56     elseif ($tag_name == 'original_source') {
57       $tag_name = 'original-source';
58     }
59     return $tag_name;
60   }
61
62   /**
63    * Implements {meta_tag_name}_test_field_xpath() for 'abstract'.
64    */
65   public function abstract_test_field_xpath() {
66     return "//textarea[@name='abstract']";
67   }
68
69   /**
70    * Implements {meta_tag_name}_test_name_attribute() for 'author'.
71    */
72   public function author_test_output_xpath() {
73     return "//link[@rel='author']";
74   }
75
76   /**
77    * Implements {meta_tag_name}_test_value_attribute() for 'author'.
78    */
79   public function author_test_value_attribute() {
80     return 'href';
81   }
82
83   /**
84    * Implements {meta_tag_name}_test_name_attribute() for 'canonical_url'.
85    */
86   public function canonical_url_test_output_xpath() {
87     return "//link[@rel='canonical']";
88   }
89
90   /**
91    * Implements {meta_tag_name}_test_value_attribute() for 'canonical_url'.
92    */
93   public function canonical_url_test_value_attribute() {
94     return 'href';
95   }
96
97   /**
98    * Implements {meta_tag_name}_test_name_attribute() for 'content_language'.
99    */
100   public function content_language_test_name_attribute() {
101     return 'http-equiv';
102   }
103
104   /**
105    * Implements {meta_tag_name}_test_field_xpath() for 'description'.
106    */
107   public function description_test_field_xpath() {
108     return "//textarea[@name='description']";
109   }
110
111   /**
112    * Implements {meta_tag_name}_test_output_xpath() for 'image_src'.
113    */
114   public function image_src_test_output_xpath() {
115     return "//link[@rel='image_src']";
116   }
117
118   /**
119    * Implements {meta_tag_name}_test_value_attribute() for 'image_src'.
120    */
121   public function image_src_test_value_attribute() {
122     return 'href';
123   }
124
125   /**
126    * Implements {meta_tag_name}_test_field_xpath() for 'referrer'.
127    */
128   public function referrer_test_field_xpath() {
129     return "//select[@name='referrer']";
130   }
131
132   /**
133    * Implements {meta_tag_name}_test_field_xpath() for 'robots'.
134    */
135   public function robots_test_field_xpath() {
136     return "//input[@name='robots[index]' and @type='checkbox']";
137   }
138
139   /**
140    * Implements {meta_tag_name}_test_value() for 'referrer'.
141    */
142   public function referrer_test_value() {
143     return 'origin';
144   }
145
146   /**
147    * Implements {meta_tag_name}_test_value() for 'robots'.
148    */
149   public function robots_test_key() {
150     return 'robots[index]';
151   }
152
153   /**
154    * Implements {meta_tag_name}_test_value() for 'robots'.
155    */
156   public function robots_test_value() {
157     return TRUE;
158   }
159
160   /**
161    * Implements {meta_tag_name}_test_output_xpath() for 'shortlink'.
162    */
163   public function shortlink_test_output_xpath() {
164     return "//link[@rel='shortlink']";
165   }
166
167   /**
168    * Implements {meta_tag_name}_test_value_attribute() for 'shortlink'.
169    */
170   public function shortlink_test_value_attribute() {
171     return 'href';
172   }
173
174 }