You are here

public function DefaultTags::testUserLoginPages in Metatag 8

Test the default values for the user login page, etc.

File

tests/src/Functional/DefaultTags.php, line 135

Class

DefaultTags
Verify that the configured defaults load as intended.

Namespace

Drupal\Tests\metatag\Functional

Code

public function testUserLoginPages() {
  $front_url = $this
    ->buildUrl('<front>', [
    'absolute' => TRUE,
  ]);

  // A list of paths to examine.
  $routes = [
    '/user/login',
    '/user/register',
    '/user/password',
  ];
  foreach ($routes as $route) {

    // Identify the path to load.
    $this_page_url = $this
      ->buildUrl($route, [
      'absolute' => TRUE,
    ]);
    $this
      ->assertNotEmpty($this_page_url);

    // Load the path.
    $this
      ->drupalGet($this_page_url);
    $this
      ->assertSession()
      ->statusCodeEquals(200);

    // Check the meta tags.
    $xpath = $this
      ->xpath("//link[@rel='canonical']");
    $this
      ->assertNotEquals((string) $xpath[0]
      ->getAttribute('href'), $front_url);
    self::assertEquals((string) $xpath[0]
      ->getAttribute('href'), $this_page_url);
  }
}