function WritableFileSystemValidatorTest::setUpPermissions
Sets the permissions of the test project's directories.
Parameters
int $root_permissions: The permissions for the project root.
int $web_root_permissions: The permissions for the web root.
int $vendor_permissions: The permissions for the vendor directory.
string $relative_web_root: The web root path, relative to the project root, or an empty string if the web root and project root are the same.
2 calls to WritableFileSystemValidatorTest::setUpPermissions()
- WritableFileSystemValidatorTest::testWritable in core/
modules/ package_manager/ tests/ src/ Kernel/ WritableFileSystemValidatorTest.php - Tests the file system permissions validator.
- WritableFileSystemValidatorTest::testWritableDuringPreApply in core/
modules/ package_manager/ tests/ src/ Kernel/ WritableFileSystemValidatorTest.php - Tests the file system permissions validator during pre-apply.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ WritableFileSystemValidatorTest.php, line 183
Class
- WritableFileSystemValidatorTest
- Unit tests the file system permissions validator.
Namespace
Drupal\Tests\package_manager\KernelCode
private function setUpPermissions(int $root_permissions, int $web_root_permissions, int $vendor_permissions, string $relative_web_root) : void {
/** @var \Drupal\package_manager_bypass\MockPathLocator $path_locator */
$path_locator = $this->container
->get(PathLocator::class);
$project_root = $web_root = $path_locator->getProjectRoot();
$vendor_dir = $path_locator->getVendorDirectory();
// Create the web root directory, if necessary.
if (!empty($relative_web_root)) {
$web_root .= '/' . $relative_web_root;
mkdir($web_root);
}
$path_locator->setPaths($project_root, $vendor_dir, $relative_web_root, $path_locator->getStagingRoot());
// We need to set the vendor directory and web root permissions first
// because they may be located inside the project root.
$this->assertTrue(chmod($vendor_dir, $vendor_permissions));
if ($project_root !== $web_root) {
$this->assertTrue(chmod($web_root, $web_root_permissions));
}
$this->assertTrue(chmod($project_root, $root_permissions));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.