You are here

public function UploadFileServiceTest::testFileTooLarge in GraphQL 8.4

Tests that a too large file returns a violation.

File

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

Class

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

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

public function testFileTooLarge() : void {

  // Create a Symfony dummy uploaded file in test mode.
  $uploadFile = $this
    ->getUploadedFile(UPLOAD_ERR_INI_SIZE);
  $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 it exceeds %d %s, the maximum allowed size for uploads.', $violations[0]['message']);
}