function FileSecurityTest::testWriteWebConfigForceOverwrite

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/FileSecurity/FileSecurityTest.php \Drupal\Tests\Component\FileSecurity\FileSecurityTest::testWriteWebConfigForceOverwrite()
  2. 8.9.x core/tests/Drupal/Tests/Component/FileSecurity/FileSecurityTest.php \Drupal\Tests\Component\FileSecurity\FileSecurityTest::testWriteWebConfigForceOverwrite()

@covers ::writeWebConfig

File

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

Class

FileSecurityTest
Tests the file security component.

Namespace

Drupal\Tests\Component\FileSecurity

Code

public function testWriteWebConfigForceOverwrite() : void {
    vfsStream::setup('root');
    $web_config_file = vfsStream::url('root') . '/web.config';
    file_put_contents($web_config_file, "foo");
    $this->assertTrue(FileSecurity::writeWebConfig(vfsStream::url('root'), TRUE));
    $this->assertFileExists($web_config_file);
    $this->assertEquals('0444', substr(sprintf('%o', fileperms($web_config_file)), -4));
    $this->assertStringNotContainsString("foo", $web_config_file);
}

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