function HtaccessTest::assertFileAccess
Asserts that a file exists and requesting it returns a specific response.
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 modules/
system/ system.test - Iterates over protected files and calls assertNoFileAccess().
File
-
modules/
system/ system.test, line 3387
Class
- HtaccessTest
- Tests .htaccess is working correctly.
Code
protected function assertFileAccess($path, $response_code) {
$this->assertTrue(file_exists(drupal_realpath($path)), format_string('@filename exists.', array(
'@filename' => $path,
)));
$this->drupalGet(file_create_url($path), array(
'external' => TRUE,
));
$this->assertResponse($response_code, "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.