MetatagPanelizerTest.php in Metatag 8
File
tests/src/Functional/MetatagPanelizerTest.php
View source
<?php
namespace Drupal\Tests\metatag\Functional;
use Drupal\Tests\BrowserTestBase;
class MetatagPanelizerTest extends BrowserTestBase {
use MetatagHelperTrait;
public static $modules = [
'node',
'field',
'field_ui',
'user',
'panelizer',
'token',
'metatag',
];
protected $defaultTheme = 'bartik';
public function testPanelizerMetatagPreRender() {
$title = 'Panelizer Metatag Test Title';
$body = 'Testing JSON output for a content type';
$node = $this
->createContentTypeNode($title, $body);
$url = $node
->toUrl();
$permissions = [
'administer node display',
'administer meta tags',
];
$account = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($account);
$this
->drupalPostForm('admin/structure/types/manage/metatag_test/display', [
'panelizer[enable]' => TRUE,
], 'Save');
$this
->drupalGet('admin/structure/types/manage/metatag_test/display');
$this
->assertSession()
->checkboxChecked('panelizer[enable]');
$this
->drupalGet($url);
$this
->assertSession()
->elementContains('css', 'title', $title . ' | Drupal');
$xpath = $this
->xpath("//link[@rel='canonical']");
self::assertEquals((string) $xpath[0]
->getAttribute('href'), $url
->toString());
self::assertEquals(count($xpath), 1);
}
}