function FileSystemDeprecationTest::testUnlink

Tests deprecation of the drupal_unlink() function.

@expectedDeprecation drupal_unlink() is deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::unlink(). See https://www.drupal.org/node/2418133.

File

core/tests/Drupal/KernelTests/Core/File/FileSystemDeprecationTest.php, line 171

Class

FileSystemDeprecationTest
Tests deprecations in <a href="/api/drupal/core%21includes%21file.inc/8.9.x" title="API for handling file uploads and server file management." class="local">file.inc</a>.

Namespace

Drupal\KernelTests\Core\File

Code

public function testUnlink() {
    vfsStream::setup('dir');
    vfsStream::create([
        'test.txt' => 'asdf',
    ]);
    $uri = 'vfs://dir/test.txt';
    $this->assertFileExists($uri);
    drupal_unlink($uri);
    $this->assertFileNotExists($uri);
}

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