3 namespace Drupal\metatag\Tests;
5 use Drupal\entity_test\Entity\EntityTest;
6 use Drupal\metatag\Entity\MetatagDefaults;
7 use Drupal\simpletest\WebTestBase;
10 * Tests custom route integration.
14 * @see hook_metatag_route_entity()
16 class MetatagCustomRouteTest extends WebTestBase {
21 public static $modules = [
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',
33 public function testCustomRoute() {
34 $entity_test = EntityTest::create([
35 'name' => 'test name',
36 'type' => 'entity_test',
40 MetatagDefaults::create([
41 'id' => 'entity_test__entity_test',
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');