Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Dec 9, 2024
1 parent 9592ec5 commit 38679f2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FileUploadNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function normalize(array $files): array
break;
}

if (str_ends_with($k, '_0')) {
if (is_string($k) && str_ends_with($k, '_0')) {
$groups[] = substr($k, 0, -2);
}
}
Expand Down
48 changes: 48 additions & 0 deletions tests/FileUploadNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,54 @@ public static function normalizeProvider(): iterable
null,
];

yield 'File upload with indexed keys' => [
[
'file_0' => [
'name' => 'name.jpg',
'type' => 'image/jpeg',
'tmp_name' => 'path/to/name.jpg',
'error' => 0,
'size' => 333,
'uploaded' => true,
'uuid' => '660d272c-f4c3-11ed-a05b-0242ac120003',
],
'file_1' => [
'name' => 'name.jpg',
'type' => 'image/jpeg',
'tmp_name' => 'path/to/name.jpg',
'error' => 0,
'size' => 333,
'uploaded' => true,
'uuid' => '660d272c-f4c3-11ed-a05b-0242ac120003',
],
],
[
'file' => [
[
'name' => 'name.jpg',
'type' => 'image/jpeg',
'tmp_name' => 'path/to/name.jpg',
'error' => 0,
'size' => 333,
'uploaded' => true,
'uuid' => '660d272c-f4c3-11ed-a05b-0242ac120003',
],
[
'name' => 'name.jpg',
'type' => 'image/jpeg',
'tmp_name' => 'path/to/name.jpg',
'error' => 0,
'size' => 333,
'uploaded' => true,
'uuid' => '660d272c-f4c3-11ed-a05b-0242ac120003',
],
],
],
'/project-dir',
null,
null,
];

yield 'Array of it all' => [
[
'upload_field_already_correct' => [
Expand Down

0 comments on commit 38679f2

Please sign in to comment.