function HtaccessTest::assertFilePermissions

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php \Drupal\KernelTests\Core\File\HtaccessTest::assertFilePermissions()
  2. 10 core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php \Drupal\KernelTests\Core\File\HtaccessTest::assertFilePermissions()
  3. 11.x core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php \Drupal\KernelTests\Core\File\HtaccessTest::assertFilePermissions()

Asserts expected file permissions for a given file.

@internal

Parameters

string $uri: The URI of the file to check.

int $expected: The expected file permissions; e.g., 0444.

1 call to HtaccessTest::assertFilePermissions()
HtaccessTest::testHtaccessSave in core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php
@covers ::write

File

core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php, line 103

Class

HtaccessTest
Tests .htaccess file saving.

Namespace

Drupal\KernelTests\Core\File

Code

protected function assertFilePermissions(string $uri, int $expected) : void {
    $actual = fileperms($uri) & 0777;
    $this->assertSame($actual, $expected, new FormattableMarkup('@uri file permissions @actual are identical to @expected.', [
        '@uri' => $uri,
        '@actual' => 0 . decoct($actual),
        '@expected' => 0 . decoct($expected),
    ]));
}

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