function HtaccessTest::assertFilePermissions

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php \Drupal\KernelTests\Core\File\HtaccessTest::assertFilePermissions()
  2. 8.9.x 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 104

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, sprintf('%s file permissions %s are identical to %s.', $uri, 0 . decoct($actual), 0 . decoct($expected)));
}

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