You are here

public function SecureLoginTestConfig::testSecureLoginBaseUrl in Secure Login 8

Ensure redirects use the configured base URL.

File

tests/src/Functional/SecureLoginTestConfig.php, line 36

Class

SecureLoginTestConfig
Tests secure login module configuration.

Namespace

Drupal\Tests\securelogin\Functional

Code

public function testSecureLoginBaseUrl() {

  // Disable redirect following.
  if (method_exists($this
    ->getSession()
    ->getDriver(), 'getClient')) {
    $this
      ->getSession()
      ->getDriver()
      ->getClient()
      ->followRedirects(FALSE);
  }
  $maximumMetaRefreshCount = $this->maximumMetaRefreshCount;
  $this->maximumMetaRefreshCount = 0;
  $this
    ->drupalGet($this
    ->httpUrl('user/login'));
  $this
    ->assertSession()
    ->statusCodeEquals(301);
  $this
    ->assertSame(0, strpos($this
    ->getSession()
    ->getResponseHeader('Location'), 'https://example.org/user/login'), 'Location header uses the configured secure base URL.');
  if (method_exists($this
    ->getSession()
    ->getDriver(), 'getClient')) {
    $this
      ->getSession()
      ->getDriver()
      ->getClient()
      ->followRedirects(TRUE);
  }
  $this->maximumMetaRefreshCount = $maximumMetaRefreshCount;
}