119b09e8961f2436f05e8025f8412f5dd1bc02e0
[yaffs-website] / web / modules / contrib / metatag / tests / src / Kernel / MetatagManagerTest.php
1 <?php
2
3 namespace Drupal\Tests\metatag\Kernel;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Test the Metatag Manager class.
9  *
10  * @group metatag
11  */
12 class MetatagManagerTest extends KernelTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = [
18     'metatag',
19     'metatag_open_graph',
20   ];
21
22   /**
23    * Test the order of the meta tags as they are output.
24    */
25   public function testMetatagOrder() {
26     /** @var \Drupal\metatag\MetatagManager $metatag_manager */
27     $metatag_manager = \Drupal::service('metatag.manager');
28
29     $tags = $metatag_manager->generateElements([
30       'og_image_width' => 100,
31       'og_image_height' => 100,
32       'og_image_url' => 'http://www.example.com/example/foo.png',
33     ]);
34
35     $expected = [
36       '#attached' => ['html_head' => [
37         [
38           [
39             '#tag'=> 'meta',
40             '#attributes' => [
41               'property' => 'og:image:url',
42               'content' => 'http://www.example.com/example/foo.png',
43             ],
44           ],
45           'og_image_url',
46         ],
47         [
48           [
49             '#tag'=> 'meta',
50             '#attributes' => [
51               'property' => 'og:image:width',
52               'content' => 100,
53             ],
54           ],
55           'og_image_width',
56         ],
57         [
58           [
59             '#tag'=> 'meta',
60             '#attributes' => [
61               'property' => 'og:image:height',
62               'content' => 100,
63             ],
64           ],
65           'og_image_height',
66         ],
67       ]],
68     ];
69     $this->assertEquals($expected, $tags);
70   }
71
72 }