You are here

protected function Domain301RedirectFunctionalTestTrait::getRedirect in Domain 301 Redirect 8

Perform a get request that doesn't follow a redirect.

Parameters

string $url: The test url.

Return value

array The status code and headers.

3 calls to Domain301RedirectFunctionalTestTrait::getRedirect()
Domain301RedirectTest::testDomainRedirect in tests/src/Functional/Domain301RedirectTest.php
Test redirecting to various domains.
Domain301RedirectTest::testRedirectCacheability in tests/src/Functional/Domain301RedirectTest.php
Test the cacheability of the redirect response.
RedirectManagerTest::testCheckDomain in tests/src/Functional/RedirectManagerTest.php
Check that the the redirect domain resolves to this site.

File

tests/src/Traits/Domain301RedirectFunctionalTestTrait.php, line 45

Class

Domain301RedirectFunctionalTestTrait
Common functions used by domain_301_redirect tests.

Namespace

Drupal\Tests\domain_301_redirect\Traits

Code

protected function getRedirect($url) {
  $client = $this
    ->getSession()
    ->getDriver()
    ->getClient()
    ->getClient();
  $response = $client
    ->get($url, [
    // Don't follow the redirect, just return the response.
    'allow_redirects' => FALSE,
  ]);
  $statusCode = $response
    ->getStatusCode();
  $headers = $response
    ->getHeaders();
  return [
    $statusCode,
    $headers,
  ];
}