You are here

public function MetatagCustomRouteTest::testCustomRoute in Metatag 8

Run tests on the custom route.

File

tests/src/Functional/MetatagCustomRouteTest.php, line 41

Class

MetatagCustomRouteTest
Tests custom route integration.

Namespace

Drupal\Tests\metatag\Functional

Code

public function testCustomRoute() {
  $entity_test = EntityTest::create([
    'name' => 'test name',
    'type' => 'entity_test',
  ]);
  $entity_test
    ->save();
  MetatagDefaults::create([
    'id' => 'entity_test__entity_test',
    'tags' => [
      'keywords' => 'test',
    ],
  ])
    ->save();
  $this
    ->drupalGet('metatag_test_custom_route/' . $entity_test
    ->id());
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $xpath = $this
    ->xpath("//meta[@name='keywords']");
  $this
    ->assertCount(1, $xpath);
  $this
    ->assertEquals('test', $xpath[0]
    ->getAttribute('content'));
}