MetatagCustomRouteTest.php in Metatag 8
File
tests/src/Functional/MetatagCustomRouteTest.php
View source
<?php
namespace Drupal\Tests\metatag\Functional;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\metatag\Entity\MetatagDefaults;
use Drupal\Tests\BrowserTestBase;
class MetatagCustomRouteTest extends BrowserTestBase {
protected static $modules = [
'node',
'token',
'metatag',
'metatag_test_custom_route',
'entity_test',
];
protected $defaultTheme = 'stark';
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'));
}
}