function HtaccessTest::testFileAccess

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/System/HtaccessTest.php \Drupal\Tests\system\Functional\System\HtaccessTest::testFileAccess()
  2. 8.9.x core/modules/system/tests/src/Functional/System/HtaccessTest.php \Drupal\Tests\system\Functional\System\HtaccessTest::testFileAccess()
  3. 10 core/modules/system/tests/src/Functional/System/HtaccessTest.php \Drupal\Tests\system\Functional\System\HtaccessTest::testFileAccess()
  4. 11.x core/modules/system/tests/src/Functional/System/HtaccessTest.php \Drupal\Tests\system\Functional\System\HtaccessTest::testFileAccess()

Iterates over protected files and calls assertNoFileAccess().

File

modules/system/system.test, line 3357

Class

HtaccessTest
Tests .htaccess is working correctly.

Code

function testFileAccess() {
    foreach ($this->getProtectedFiles() as $file => $response_code) {
        file_put_contents($file, '# test content');
        $this->assertFileAccess($file, $response_code);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.