function FileTestBase::createDirectory

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/File/FileTestBase.php \Drupal\KernelTests\Core\File\FileTestBase::createDirectory()
  2. 10 core/tests/Drupal/KernelTests/Core/File/FileTestBase.php \Drupal\KernelTests\Core\File\FileTestBase::createDirectory()
  3. 11.x core/tests/Drupal/KernelTests/Core/File/FileTestBase.php \Drupal\KernelTests\Core\File\FileTestBase::createDirectory()

Create a directory and assert it exists.

Parameters

$path: Optional string with a directory path. If none is provided, a random name in the site's files directory will be used.

Return value

The path to the directory.

5 calls to FileTestBase::createDirectory()
FileCopyTest::testNonWritableDestination in core/modules/migrate/tests/src/Kernel/process/FileCopyTest.php
Tests that non-writable destination throw an exception.
FileDeleteRecursiveTest::testDirectory in core/tests/Drupal/KernelTests/Core/File/FileDeleteRecursiveTest.php
Try deleting a directory with some files.
FileDeleteRecursiveTest::testEmptyDirectory in core/tests/Drupal/KernelTests/Core/File/FileDeleteRecursiveTest.php
Try deleting an empty directory.
FileDeleteRecursiveTest::testSubDirectory in core/tests/Drupal/KernelTests/Core/File/FileDeleteRecursiveTest.php
Try deleting subdirectories with some files.
FileDeleteTest::testDirectory in core/tests/Drupal/KernelTests/Core/File/FileDeleteTest.php
Try deleting a directory.

File

core/tests/Drupal/KernelTests/Core/File/FileTestBase.php, line 160

Class

FileTestBase
Base class for file tests that adds some additional file specific assertions and helper functions.

Namespace

Drupal\KernelTests\Core\File

Code

public function createDirectory($path = NULL) {
    // A directory to operate on.
    if (!isset($path)) {
        $path = 'public://' . $this->randomMachineName();
    }
    $this->assertTrue(\Drupal::service('file_system')->mkdir($path));
    $this->assertDirectoryExists($path);
    return $path;
}

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