Commit 3874b0c8 authored by alexpott's avatar alexpott
Browse files

Issue #2332029 by Eric115: Add test coverage for .htaccess rules

parent b6ee00e2
...@@ -15,21 +15,51 @@ ...@@ -15,21 +15,51 @@
* @group system * @group system
*/ */
class HtaccessTest extends WebTestBase { class HtaccessTest extends WebTestBase {
/**
* Get an array of file paths for access testing.
*
* @return array
* An array of file paths to be access-tested.
*/
protected function getProtectedFiles() {
$path = drupal_get_path('module', 'system') . '/tests/fixtures/HtaccessTest';
$file_exts = [
'engine',
'inc',
'install',
'make',
'module',
'profile',
'po',
'sh',
'sql',
'theme',
'twig',
'tpl.php',
'xtmpl',
'yml',
];
foreach ($file_exts as $file_ext) {
$file_paths[] = "$path/access_test.$file_ext";
}
return $file_paths;
}
/** /**
* Tests accessing files with .yml extensions at various locations. * Iterates over protected files and calls assertNoFileAccess().
*/ */
public function testYamlFileAccess() { public function testFileAccess() {
// Try accessing the core services YAML file. foreach ($this->getProtectedFiles() as $file) {
$this->assertNoFileAccess('core/core.services.yml'); $this->assertNoFileAccess($file);
// Try accessing a core module YAML file. }
$this->assertNoFileAccess('core/modules/system/system.services.yml');
} }
/** /**
* Asserts that a file exists but not accessible via HTTP. * Asserts that a file exists but not accessible via HTTP.
* *
* @param $path * @param string $path
* Path to file. Without leading slash. * Path to file. Without leading slash.
*/ */
protected function assertNoFileAccess($path) { protected function assertNoFileAccess($path) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment