Skip to content

Commit

Permalink
Removing hook_file_validate test module.
Browse files Browse the repository at this point in the history
  • Loading branch information
apathak18 committed Jul 25, 2024
1 parent b9ade93 commit 3d0741f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 32 deletions.
12 changes: 7 additions & 5 deletions src/GraphQL/Utility/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class FileUpload {
use StringTranslationTrait;

/**
* The file storage where we will create new file entities from.
* The entity storage for the 'file' entity type.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
* @var \Drupal\file\FileStorageInterface
*/
protected $fileStorage;

Expand Down Expand Up @@ -137,7 +137,9 @@ public function __construct(
ImageFactory $image_factory,
FileValidatorInterface $file_validator,
) {
$this->fileStorage = $entityTypeManager->getStorage('file');
/** @var \Drupal\file\FileStorageInterface $file_storage */
$file_storage = $entityTypeManager->getStorage('file');
$this->fileStorage = $file_storage;
$this->currentUser = $currentUser;
$this->mimeTypeGuesser = $mimeTypeGuesser;
$this->fileSystem = $fileSystem;
Expand Down Expand Up @@ -268,7 +270,7 @@ public function saveFileUpload(UploadedFile $uploaded_file, array $settings): Fi

try {
// Begin building file entity.
/** @var \Drupal\Core\Entity\EntityInterface $file */
/** @var \Drupal\file\FileInterface $file */
$file = $this->fileStorage->create([]);
$file->setOwnerId($this->currentUser->id());
$file->setFilename($prepared_filename);
Expand Down Expand Up @@ -515,7 +517,7 @@ protected function prepareFilename(string $filename, array &$validators): string

$passes_validation = FALSE;
if (!empty($validators['FileExtension']['extensions'])) {
/** @var \Drupal\Core\Entity\EntityInterface $file */
/** @var \Drupal\file\FileInterface $file */
$file = $this->fileStorage->create([]);
$file->setFilename($filename);
$passes_validation = empty($this->fileValidator->validate($file, $validators['FileExtension']['extensions']));
Expand Down

This file was deleted.

17 changes: 0 additions & 17 deletions tests/modules/graphql_file_validate/graphql_file_validate.module

This file was deleted.

5 changes: 0 additions & 5 deletions tests/src/Kernel/Framework/UploadFileServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
*/
class UploadFileServiceTest extends GraphQLTestBase {

/**
* {@inheritdoc}
*/
protected static $modules = ['file', 'graphql_file_validate'];

/**
* The FileUpload object we want to test, gets prepared in setUp().
*
Expand Down

0 comments on commit 3d0741f

Please sign in to comment.