feat(file-upload): Support saving multiple files at once.#1139
Merged
rthideaway merged 13 commits intodrupal-graphql:8.x-4.xfrom Dec 21, 2020
Merged
feat(file-upload): Support saving multiple files at once.#1139rthideaway merged 13 commits intodrupal-graphql:8.x-4.xfrom
rthideaway merged 13 commits intodrupal-graphql:8.x-4.xfrom
Conversation
klausi
requested changes
Dec 21, 2020
Contributor
klausi
left a comment
There was a problem hiding this comment.
Looks good, thanks! Can you also add a success and a fail test case?
| * @return \Drupal\file\FileInterface[] | ||
| * File entities. | ||
| */ | ||
| public function getFileEntities(): ?array { |
Contributor
There was a problem hiding this comment.
return type can be just array, this will never be NULL.
| } | ||
|
|
||
| /** | ||
| * Validates an uploaded files, saves them and returns a file upload response. |
| * @return \Drupal\graphql\GraphQL\Response\FileUploadResponse | ||
| * The file upload response containing file entities or list of violations. | ||
| */ | ||
| public function saveMultipleFileUploads(array $uploaded_files, array $settings): ResponseInterface { |
Contributor
There was a problem hiding this comment.
return type should be FileUploadResponse so that callers see the correct methods.
klausi
approved these changes
Dec 21, 2020
Contributor
klausi
left a comment
There was a problem hiding this comment.
Super, thanks! I just see 2 minor issues and then this can be merged.
PHPStan fail: you probably want assertSame()?
| $file_entities = $file_upload_response->getFileEntities(); | ||
| $this->assertEqual(count($file_entities), 3); | ||
| foreach ($file_entities as $file_entity) { | ||
| $this->assertInstanceOf('\Drupal\file\Entity\File', $file_entity); |
Contributor
There was a problem hiding this comment.
we can use File::class syntax to avoid strings.
| $this->assertEqual(count($file_entities), 3); | ||
| foreach ($file_entities as $file_entity) { | ||
| $this->assertInstanceOf('\Drupal\file\Entity\File', $file_entity); | ||
| } |
Contributor
There was a problem hiding this comment.
we should assert here that the 3 files exist at the target location, see for example testSuccess().
klausi
reviewed
Dec 21, 2020
| // There must be three file entities. | ||
| $file_entities = $file_upload_response->getFileEntities(); | ||
| $this->assertEqual(count($file_entities), 3); | ||
| $this->assertEquals(count($file_entities), 3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.