Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
3874b0c8
Commit
3874b0c8
authored
Mar 13, 2015
by
alexpott
Browse files
Issue
#2332029
by Eric115: Add test coverage for .htaccess rules
parent
b6ee00e2
Changes
15
Hide whitespace changes
Inline
Side-by-side
core/modules/system/src/Tests/System/HtaccessTest.php
View file @
3874b0c8
...
...
@@ -15,21 +15,51 @@
* @group system
*/
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
()
{
// Try accessing the core services YAML file.
$this
->
assertNoFileAccess
(
'core/core.services.yml'
);
// Try accessing a core module YAML file.
$this
->
assertNoFileAccess
(
'core/modules/system/system.services.yml'
);
public
function
testFileAccess
()
{
foreach
(
$this
->
getProtectedFiles
()
as
$file
)
{
$this
->
assertNoFileAccess
(
$file
);
}
}
/**
* Asserts that a file exists but not accessible via HTTP.
*
* @param $path
* @param
string
$path
* Path to file. Without leading slash.
*/
protected
function
assertNoFileAccess
(
$path
)
{
...
...
core/modules/system/tests/fixtures/HtaccessTest/access_test.engine
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.inc
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.install
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.make
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.module
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.po
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.profile
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.sh
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.sql
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.theme
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.tpl.php
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.twig
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.xtmpl
0 → 100644
View file @
3874b0c8
core/modules/system/tests/fixtures/HtaccessTest/access_test.yml
0 → 100644
View file @
3874b0c8
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment