function LegacyFileTest::testSaveData

Tests file_save_data deprecation and that it works without a destination.

File

core/modules/file/tests/src/Kernel/LegacyFileTest.php, line 47

Class

LegacyFileTest
Tests deprecated file functions.

Namespace

Drupal\Tests\file\Kernel

Code

public function testSaveData() {
    $this->expectDeprecation('file_save_data is deprecated in drupal:9.3.0 and will be removed in drupal:10.0.0. Use \\Drupal\\file\\FileRepositoryInterface::writeData() instead. See https://www.drupal.org/node/3223520');
    $contents = $this->randomMachineName(8);
    $result = file_save_data($contents);
    $this->assertNotFalse($result, 'Unnamed file saved correctly.');
}

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