function FileSaveUploadTest::setUp

Same name in other branches
  1. 7.x modules/simpletest/tests/file.test \FileSaveUploadTest::setUp()
  2. 10 core/modules/file/tests/src/Kernel/FileSaveUploadTest.php \Drupal\Tests\file\Kernel\FileSaveUploadTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/file/tests/src/Kernel/FileSaveUploadTest.php, line 36

Class

FileSaveUploadTest
Tests file_save_upload().

Namespace

Drupal\Tests\file\Kernel

Code

protected function setUp() : void {
    parent::setUp();
    $filename = 'test.bbb';
    vfsStream::newFile($filename)->at($this->vfsRoot)
        ->withContent('test');
    $request = new Request();
    $request->files
        ->set('files', [
        'file' => new UploadedFile(path: vfsStream::url("root/{$filename}"), originalName: $filename, mimeType: 'text/plain', error: \UPLOAD_ERR_OK, test: TRUE),
    ]);
    $request->setSession(new Session(new MockArraySessionStorage()));
    $requestStack = new RequestStack();
    $requestStack->push($request);
    $this->container
        ->set('request_stack', $requestStack);
}

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