function DuplicateInfoFileValidatorTest::createFileAtPath

Creates the file at the root directory.

Parameters

string $root_directory: The base directory in which the file will be created.

string $file_path: The path of the file to create.

1 call to DuplicateInfoFileValidatorTest::createFileAtPath()
DuplicateInfoFileValidatorTest::testDuplicateInfoFilesInStage in core/modules/package_manager/tests/src/Kernel/DuplicateInfoFileValidatorTest.php
Tests that duplicate info.yml in stage raise an error.

File

core/modules/package_manager/tests/src/Kernel/DuplicateInfoFileValidatorTest.php, line 231

Class

DuplicateInfoFileValidatorTest
@covers \Drupal\package_manager\Validator\DuplicateInfoFileValidator @group package_manager @internal

Namespace

Drupal\Tests\package_manager\Kernel

Code

private function createFileAtPath(string $root_directory, string $file_path) : void {
    $parts = explode(DIRECTORY_SEPARATOR, $file_path);
    $filename = array_pop($parts);
    $file_dir = str_replace($filename, '', $file_path);
    $fs = new Filesystem();
    if (!file_exists($file_dir)) {
        $fs->mkdir($root_directory . $file_dir);
    }
    file_put_contents($root_directory . $file_path, "name: SOME MODULE\ntype: module\n");
}

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