Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / metatag / src / Tests / MetatagCustomRouteTest.php
1 <?php
2
3 namespace Drupal\metatag\Tests;
4
5 use Drupal\entity_test\Entity\EntityTest;
6 use Drupal\metatag\Entity\MetatagDefaults;
7 use Drupal\simpletest\WebTestBase;
8
9 /**
10  * Tests custom route integration.
11  *
12  * @group metatag
13  *
14  * @see hook_metatag_route_entity()
15  */
16 class MetatagCustomRouteTest extends WebTestBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   public static $modules = [
22     'node',
23     // Dependencies.
24     'token',
25     // Metatag itself.
26     'metatag',
27     // This module will be used to load a static page which will inherit the
28     // global defaults, without loading values from other configs.
29     'metatag_test_custom_route',
30     'entity_test',
31   ];
32
33   public function testCustomRoute() {
34     $entity_test = EntityTest::create([
35       'name' => 'test name',
36       'type' => 'entity_test',
37     ]);
38     $entity_test->save();
39
40     MetatagDefaults::create([
41       'id' => 'entity_test__entity_test',
42       'tags' => [
43         'keywords' => 'test',
44       ],
45     ])->save();
46
47     $this->drupalGet('metatag_test_custom_route/' . $entity_test->id());
48     $this->assertResponse(200);
49     $xpath = $this->xpath("//meta[@name='keywords']");
50     $this->assertEqual(count($xpath), 1);
51     $this->assertEqual((string) $xpath[0]->attributes()['content'], 'test');
52   }
53
54 }