function StreamFileUploaderTest::testWriteStreamToFileSuccess

Same name in other branches
  1. 11.x core/modules/file/tests/src/Kernel/Upload/StreamFileUploaderTest.php \Drupal\Tests\file\Kernel\Upload\StreamFileUploaderTest::testWriteStreamToFileSuccess()

@covers ::writeStreamToFile

File

core/modules/file/tests/src/Kernel/Upload/StreamFileUploaderTest.php, line 26

Class

StreamFileUploaderTest
Tests the stream file uploader.

Namespace

Drupal\Tests\file\Kernel\Upload

Code

public function testWriteStreamToFileSuccess() : void {
    vfsStream::newFile('foo.txt')->at($this->vfsRoot)
        ->withContent('bar');
    $fileWriter = $this->container
        ->get('file.input_stream_file_writer');
    $filename = $fileWriter->writeStreamToFile(vfsStream::url('root/foo.txt'));
    $this->assertStringStartsWith('temporary://', $filename);
    $this->assertStringEqualsFile($filename, 'bar');
}

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