Verified Commit f03fb0f6 authored by Jess's avatar Jess
Browse files

Issue #3455183 by kim.pepper, mstrelan, mondrake: FileSaveUploadTest should...

Issue #3455183 by kim.pepper, mstrelan, mondrake: FileSaveUploadTest should not write to the app root

(cherry picked from commit 62f9af40)
parent 793cbe86
Loading
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@

use Drupal\Core\Messenger\MessengerInterface;
use Drupal\KernelTests\KernelTestBase;
use org\bovigo\vfs\vfsStream;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -34,12 +35,16 @@ class FileSaveUploadTest extends KernelTestBase {
   */
  protected function setUp(): void {
    parent::setUp();
    \file_put_contents('test.bbb', 'test');
    $filename = 'test.bbb';
    vfsStream::newFile($filename)
      ->at($this->vfsRoot)
      ->withContent('test');

    $request = new Request();
    $request->files->set('files', [
      'file' => new UploadedFile(
        path: 'test.bbb',
        originalName: 'test.bbb',
        path: vfsStream::url("root/$filename"),
        originalName: $filename,
        mimeType: 'text/plain',
        error: \UPLOAD_ERR_OK,
        test: TRUE
@@ -52,14 +57,6 @@ protected function setUp(): void {
    $this->container->set('request_stack', $requestStack);
  }

  /**
   * {@inheritdoc}
   */
  protected function tearDown(): void {
    \unlink('test.bbb');
    parent::tearDown();
  }

  /**
   * Tests file_save_upload() with empty extensions.
   */