function LegacyFileSystemTest::testSaveDataWithDeprecatedFileExists

Same name in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/File/LegacyFileSystemTest.php \Drupal\KernelTests\Core\File\LegacyFileSystemTest::testSaveDataWithDeprecatedFileExists()

@covers ::saveData

File

core/tests/Drupal/KernelTests/Core/File/LegacyFileSystemTest.php, line 56

Class

LegacyFileSystemTest
Tests the legacy file system functions.

Namespace

Drupal\KernelTests\Core\File

Code

public function testSaveDataWithDeprecatedFileExists() : void {
    $data = $this->randomMachineName(8);
    $uri = 'public://test.txt';
    touch($uri);
    $this->expectDeprecation('Passing the $fileExists argument as an integer to Drupal\\Core\\File\\FileSystem::saveData() is deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. Use \\Drupal\\Core\\File\\FileExists enum instead. See https://www.drupal.org/node/3426517');
    $newUri = $this->fileSystem
        ->saveData($data, $uri, FileSystemInterface::EXISTS_RENAME);
    $this->assertFileExists($newUri);
}

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