You are here

protected function UploadFileServiceTest::getUploadedFile in GraphQL 8.4

Helper method to prepare the UploadedFile depending on core version.

Drupal core uses different Symfony versions where we have a different UploadedFile constructor signature.

10 calls to UploadFileServiceTest::getUploadedFile()
UploadFileServiceTest::testExtensionRenaming in tests/src/Kernel/Framework/UploadFileServiceTest.php
Tests that the uploaded file extension is renamed to txt.
UploadFileServiceTest::testExtensionValidation in tests/src/Kernel/Framework/UploadFileServiceTest.php
Tests that the uploaded file extension is validated.
UploadFileServiceTest::testFileTooLarge in tests/src/Kernel/Framework/UploadFileServiceTest.php
Tests that a too large file returns a violation.
UploadFileServiceTest::testLockReleased in tests/src/Kernel/Framework/UploadFileServiceTest.php
Tests that the file lock is released on validation errors.
UploadFileServiceTest::testMissingSettings in tests/src/Kernel/Framework/UploadFileServiceTest.php
Tests that missing settings keys throw an exception.

... See full list

File

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

Class

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

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

protected function getUploadedFile(int $error_status, int $size = 0, string $dest_filename = 'test.txt', string $source_filename = 'graphql_upload_test.txt') : UploadedFile {
  $source_filepath = $this
    ->getSourceTestFilePath($source_filename);
  [
    $version,
  ] = explode('.', \Drupal::VERSION, 2);
  switch ($version) {
    case 8:
      return new UploadedFile($source_filepath, $dest_filename, 'text/plain', $size, $error_status, TRUE);
  }
  return new UploadedFile($source_filepath, $dest_filename, 'text/plain', $error_status, TRUE);
}