2365155277c2676fcbe4e5e9ebcdc66d3038af3a
[yaffs-website] / web / modules / contrib / metatag / metatag_open_graph / src / Tests / MetatagOpenGraphTagsTest.php
1 <?php
2
3 namespace Drupal\metatag_open_graph\Tests;
4
5 use Drupal\metatag\Tests\MetatagTagsTestBase;
6
7 /**
8  * Tests that each of the Metatag Open Graph tags work correctly.
9  *
10  * @group metatag
11  */
12 class MetatagOpenGraphTagsTest extends MetatagTagsTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   private $tags = [
18     'article_author',
19     'article_expiration_time',
20     'article_modified_time',
21     'article_published_time',
22     'article_publisher',
23     'article_section',
24     'article_tag',
25     'book_author',
26     'book_isbn',
27     'book_releasedate',
28     'book_tag',
29     'og_country_name',
30     'og_description',
31     'og_determiner',
32     'og_email',
33     'og_fax_number',
34     'og_image',
35     'og_image_height',
36     'og_image_secure_url',
37     'og_image_type',
38     'og_image_url',
39     'og_image_width',
40     'og_latitude',
41     'og_locale',
42     'og_locale_alternative',
43     'og_locality',
44     'og_longitude',
45     'og_phone_number',
46     'og_postal_code',
47     'og_region',
48     'og_see_also',
49     'og_site_name',
50     'og_street_address',
51     'og_title',
52     'og_type',
53     'og_updated_time',
54     'og_url',
55     'og_video',
56     'og_video_height',
57     'og_video_secure_url',
58     'og_video_type',
59     'og_video_width',
60   ];
61
62   /**
63    * {@inheritdoc}
64    */
65   private $testTag = 'meta';
66
67   /**
68    * {@inheritdoc}
69    */
70   private $testNameAttribute = 'property';
71
72   /**
73    * {@inheritdoc}
74    */
75   protected function setUp() {
76     parent::$modules[] = 'metatag_open_graph';
77     parent::setUp();
78   }
79
80   /**
81    * Each of these meta tags has a different tag name vs its internal name.
82    */
83   private function getTestTagName($tag_name) {
84     // Replace the first underline with a colon.
85     $tag_name = str_replace('og_', 'og:', $tag_name);
86     $tag_name = str_replace('article_', 'article:', $tag_name);
87     $tag_name = str_replace('book_', 'book:', $tag_name);
88
89     // Some tags have an additional underline that turns into a colon.
90     $tag_name = str_replace('og:image_', 'og:image:', $tag_name);
91     $tag_name = str_replace('og:video_', 'og:video:', $tag_name);
92
93     // Additional fixes.
94     if ($tag_name == 'og:locale_alternative') {
95       $tag_name = 'og:locale:alternate';
96     }
97
98     return $tag_name;
99   }
100
101 }