You are here

public function FileSecurityTest::testWriteWebConfigForceOverwrite in Drupal 9

Same name and namespace in other branches
  1. 8 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 78

Class

FileSecurityTest
Tests the file security component.

Namespace

Drupal\Tests\Component\FileSecurity

Code

public function testWriteWebConfigForceOverwrite() {
  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);
}