You are here

public function UploadFileServiceTest::testSuccess in GraphQL 8.4

Ensure that a correct file upload works.

File

tests/src/Kernel/Framework/UploadFileServiceTest.php, line 61

Class

UploadFileServiceTest
Tests file uploads that should be mapped to a field in a resolver.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testSuccess() : void {

  // Create a Symfony dummy uploaded file in test mode.
  $uploadFile = $this
    ->getUploadedFile(UPLOAD_ERR_OK);
  $file_upload_response = $this->uploadService
    ->saveFileUpload($uploadFile, [
    'uri_scheme' => 'public',
    'file_directory' => 'test',
  ]);
  $file_entity = $file_upload_response
    ->getFileEntity();
  $this
    ->assertSame('public://test/test.txt', $file_entity
    ->getFileUri());
  $this
    ->assertFileExists($file_entity
    ->getFileUri());
}