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',
34 * Run tests on the custom route.
36 public function testCustomRoute() {
37 $entity_test = EntityTest::create([
38 'name' => 'test name',
39 'type' => 'entity_test',
43 MetatagDefaults::create([
44 'id' => 'entity_test__entity_test',
50 $this->drupalGet('metatag_test_custom_route/' . $entity_test->id());
51 $this->assertResponse(200);
52 $xpath = $this->xpath("//meta[@name='keywords']");
53 $this->assertEqual(count($xpath), 1);
54 $this->assertEqual((string) $xpath[0]->attributes()['content'], 'test');