function FileSaveHtaccessLoggingTest::testHtaccessSave in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/File/FileSaveHtaccessLoggingTest.php \Drupal\system\Tests\File\FileSaveHtaccessLoggingTest::testHtaccessSave()
Tests file_save_htaccess().
File
- core/
modules/ system/ src/ Tests/ File/ FileSaveHtaccessLoggingTest.php, line 25 - Contains \Drupal\system\Tests\File\FileSaveHtaccessLoggingTest.
Class
- FileSaveHtaccessLoggingTest
- Tests the log message added by file_save_htacess().
Namespace
Drupal\system\Tests\FileCode
function testHtaccessSave() {
// Prepare test directories.
$private = $this->publicFilesDirectory . '/test/private';
// Verify that file_save_htaccess() returns FALSE if .htaccess cannot be
// written and writes a correctly formatted message to the error log. Set
// $private to TRUE so all possible .htaccess lines are written.
$this
->assertFalse(file_save_htaccess($private, TRUE));
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('admin/reports/dblog');
$this
->clickLink("Security warning: Couldn't write .htaccess file. Please…");
$lines = FileStorage::htaccessLines(TRUE);
foreach (array_filter(explode("\n", $lines)) as $line) {
$this
->assertEscaped($line);
}
}