function SecurepagesTest::_testXHR in Secure Pages 8
Test detection of XHR requests.
1 call to SecurepagesTest::_testXHR()
- SecurepagesTest::testSecurePages in src/
Tests/ SecurepagesTest.php - Runs all the tests in a sequence to avoid multiple re-installs.
File
- src/
Tests/ SecurepagesTest.php, line 291 - Contains \Drupal\securepages\Tests\SecurepagesTest.
Class
- SecurepagesTest
- Test Secure Pages redirects.
Namespace
Drupal\securepages\TestsCode
function _testXHR() {
// Without XHR header.
$this
->drupalGet('user', [
'https' => FALSE,
]);
$this
->assertResponse(200);
$this
->assertUrl(Url::fromRoute('user.login', [], [
'https' => TRUE,
'absolute' => TRUE,
]));
// With XHR header.
$this
->drupalGet('user', [
'https' => FALSE,
], [
'X-Requested-With: XMLHttpRequest',
]);
$this
->assertResponse(200);
$this
->assertUrl(Url::fromRoute('user.login', [], [
'https' => FALSE,
'absolute' => TRUE,
]));
}