Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / src / Functional / File / FileSaveHtaccessLoggingTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\File;
4
5 use Drupal\Component\PhpStorage\FileStorage;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Tests the log message added by file_save_htaccess().
10  *
11  * @group File
12  */
13 class FileSaveHtaccessLoggingTest extends BrowserTestBase {
14
15   protected static $modules = ['dblog'];
16
17   /**
18    * Tests file_save_htaccess().
19    */
20   public function testHtaccessSave() {
21     // Prepare test directories.
22     $private = $this->publicFilesDirectory . '/test/private';
23
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ā€¦");
31
32     $lines = FileStorage::htaccessLines(TRUE);
33     foreach (array_filter(explode("\n", $lines)) as $line) {
34       $this->assertEscaped($line);
35     }
36   }
37
38 }