You are here

public function UploadFileServiceTest::testPartialFile in GraphQL 8.4

Tests that a partial file returns a violation.

File

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

Class

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

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testPartialFile() : void {

  // Create a Symfony dummy uploaded file in test mode.
  $uploadFile = $this
    ->getUploadedFile(UPLOAD_ERR_PARTIAL);
  $file_upload_response = $this->uploadService
    ->saveFileUpload($uploadFile, [
    'uri_scheme' => 'public',
    'file_directory' => 'test',
  ]);
  $violations = $file_upload_response
    ->getViolations();
  $this
    ->assertStringMatchesFormat('The file "test.txt" could not be saved because the upload did not complete.', $violations[0]['message']);
}