function HtaccessTest::assertFileAccess
Same name in other branches
- 7.x modules/system/system.test \HtaccessTest::assertFileAccess()
- 9 core/modules/system/tests/src/Functional/System/HtaccessTest.php \Drupal\Tests\system\Functional\System\HtaccessTest::assertFileAccess()
- 8.9.x core/modules/system/tests/src/Functional/System/HtaccessTest.php \Drupal\Tests\system\Functional\System\HtaccessTest::assertFileAccess()
- 10 core/modules/system/tests/src/Functional/System/HtaccessTest.php \Drupal\Tests\system\Functional\System\HtaccessTest::assertFileAccess()
Asserts that a file exists and requesting it returns a specific response.
@internal
Parameters
string $path: Path to file. Without leading slash.
int $response_code: The expected response code. For example: 200, 403 or 404.
1 call to HtaccessTest::assertFileAccess()
- HtaccessTest::testFileAccess in core/
modules/ system/ tests/ src/ Functional/ System/ HtaccessTest.php - Iterates over protected files and calls assertNoFileAccess().
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ HtaccessTest.php, line 148
Class
- HtaccessTest
- Tests .htaccess is working correctly.
Namespace
Drupal\Tests\system\Functional\SystemCode
protected function assertFileAccess(string $path, int $response_code) : void {
$this->assertFileExists(\Drupal::root() . '/' . $path);
$this->drupalGet($path);
$this->assertEquals($response_code, $this->getSession()
->getStatusCode(), "Response code to {$path} should be {$response_code}");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.