You are here

public function MetatagPageManagerTest::testSingleVariantPage in Metatag 8

Tests a single variant page.

File

metatag_page_manager/tests/src/Functional/MetatagPageManagerTest.php, line 70

Class

MetatagPageManagerTest
Confirm the Page Manager integration works.

Namespace

Drupal\Tests\metatag_page_manager\Functional

Code

public function testSingleVariantPage() {
  $this
    ->drupalGet('/metatag-test');
  $this->assertSession
    ->statusCodeEquals(200);

  // Confirm what the page title looks like by default.
  $this->assertSession
    ->titleEquals('Metatag Page | Drupal');

  // Create the Metatag object through the UI to check the custom label.
  $edit = [
    'id' => 'page_variant__metatag_page_manager_variant_test',
    'title' => 'My title',
  ];
  $this
    ->drupalPostForm('/admin/config/search/metatag/add', $edit, 'Save');
  $this->assertSession
    ->pageTextContains('Page Variant: Metatag Page: Metatag Variant');

  // Clear caches to load the right metatags.
  drupal_flush_all_caches();
  $this
    ->drupalGet('/metatag-test');
  $this->assertSession
    ->statusCodeEquals(200);

  // Confirm what the page title is overridden.
  $this->assertSession
    ->titleEquals('My title');
}