You are here

public function RedirectStatusCodeTest::testRedirectStatusCode in Redirect 403 to User Login 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/RedirectStatusCodeTest.php \Drupal\Tests\r4032login\Functional\RedirectStatusCodeTest::testRedirectStatusCode()

Test the behavior of the "HTTP redirect code" option.

@dataProvider redirectStatusCodeDataProvider

Parameters

int $optionValue: The option value for the "HTTP redirect code" option.

int $expectedCode: Expected redirect code.

Throws

\GuzzleHttp\Exception\GuzzleException

File

tests/src/Functional/RedirectStatusCodeTest.php, line 31

Class

RedirectStatusCodeTest
Test the behavior of the "HTTP redirect code" option.

Namespace

Drupal\Tests\r4032login\Functional

Code

public function testRedirectStatusCode($optionValue, $expectedCode) {
  $config = $this
    ->config('r4032login.settings');
  $config
    ->set('default_redirect_code', $optionValue);
  $config
    ->save();
  $client = $this
    ->getHttpClient();
  $url = $this
    ->getAbsoluteUrl('/admin/config');
  $response = $client
    ->request('GET', $url, [
    'allow_redirects' => FALSE,
  ]);
  $this
    ->assertEquals($response
    ->getStatusCode(), $expectedCode);
}