function FileSaveUploadTest::setUp

Same name in other branches
  1. 7.x modules/simpletest/tests/file.test \FileSaveUploadTest::setUp()
  2. 11.x 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 34

Class

FileSaveUploadTest
Tests file_save_upload().

Namespace

Drupal\Tests\file\Kernel

Code

protected function setUp() : void {
    \file_put_contents('test.bbb', 'test');
    parent::setUp();
    $request = new Request();
    $request->files
        ->set('files', [
        'file' => new UploadedFile(path: 'test.bbb', originalName: 'test.bbb', mimeType: 'text/plain', error: \UPLOAD_ERR_OK, test: TRUE),
    ]);
    $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.