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