function FileSecurityTest::testWriteHtaccessForceOverwrite

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/FileSecurity/FileSecurityTest.php \Drupal\Tests\Component\FileSecurity\FileSecurityTest::testWriteHtaccessForceOverwrite()
  2. 10 core/tests/Drupal/Tests/Component/FileSecurity/FileSecurityTest.php \Drupal\Tests\Component\FileSecurity\FileSecurityTest::testWriteHtaccessForceOverwrite()
  3. 11.x core/tests/Drupal/Tests/Component/FileSecurity/FileSecurityTest.php \Drupal\Tests\Component\FileSecurity\FileSecurityTest::testWriteHtaccessForceOverwrite()

@covers ::writeHtaccess

File

core/tests/Drupal/Tests/Component/FileSecurity/FileSecurityTest.php, line 46

Class

FileSecurityTest
Tests the file security component.

Namespace

Drupal\Tests\Component\FileSecurity

Code

public function testWriteHtaccessForceOverwrite() {
    vfsStream::setup('root');
    $htaccess_file = vfsStream::url('root') . '/.htaccess';
    file_put_contents($htaccess_file, "foo");
    $this->assertTrue(FileSecurity::writeHtaccess(vfsStream::url('root'), TRUE, TRUE));
    $htaccess_contents = file_get_contents($htaccess_file);
    $this->assertStringContainsString("Require all denied", $htaccess_contents);
    $this->assertStringNotContainsString("foo", $htaccess_contents);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.