function TestBase::filePreDeleteCallback

Ensures test files are deletable.

Some tests chmod generated files to be read only. During TestBase::restoreEnvironment() and other cleanup operations, these files need to get deleted too.

See also

\Drupal\Core\File\FileSystemInterface::deleteRecursive()

File

core/modules/simpletest/src/TestBase.php, line 1378

Class

TestBase
Base class for Drupal tests.

Namespace

Drupal\simpletest

Code

public static function filePreDeleteCallback($path) {
    // When the webserver runs with the same system user as the test runner, we
    // can make read-only files writable again. If not, chmod will fail while
    // the file deletion still works if file permissions have been configured
    // correctly. Thus, we ignore any problems while running chmod.
    @chmod($path, 0700);
}

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