3 namespace Drupal\Tests\system\Functional\File;
5 use Drupal\Component\PhpStorage\FileStorage;
6 use Drupal\Tests\BrowserTestBase;
9 * Tests the log message added by file_save_htacess().
13 class FileSaveHtaccessLoggingTest extends BrowserTestBase {
15 protected static $modules = ['dblog'];
18 * Tests file_save_htaccess().
20 public function testHtaccessSave() {
21 // Prepare test directories.
22 $private = $this->publicFilesDirectory . '/test/private';
24 // Verify that file_save_htaccess() returns FALSE if .htaccess cannot be
25 // written and writes a correctly formatted message to the error log. Set
26 // $private to TRUE so all possible .htaccess lines are written.
27 $this->assertFalse(file_save_htaccess($private, TRUE));
28 $this->drupalLogin($this->rootUser);
29 $this->drupalGet('admin/reports/dblog');
30 $this->clickLink("Security warning: Couldn't write .htaccess file. Pleaseā¦");
32 $lines = FileStorage::htaccessLines(TRUE);
33 foreach (array_filter(explode("\n", $lines)) as $line) {
34 $this->assertEscaped($line);