You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1 KiB

2 years ago
  1. <?php
  2. namespace Tests\Feature\Traits;
  3. use Illuminate\Http\UploadedFile;
  4. trait FileTraits
  5. {
  6. private function defaultArray()
  7. {
  8. return [
  9. [
  10. 'alt_required' => false,
  11. 'description_required' => false,
  12. 'tmp_support' => true,
  13. 'max_width' => 2000,
  14. 'max_height' => 2000,
  15. 'min_width' => 1,
  16. 'min_height' => 1,
  17. 'min_file_size' => 0
  18. ],
  19. [
  20. "file" => UploadedFile::fake()->image('test.png', 400, 400),
  21. "public" => 1
  22. ]
  23. ];
  24. }
  25. private function changeDefaultArrayAndReturn($defaultArray, $key, $value): array
  26. {
  27. $defaultArray[$key[0]][$key[1]] = $value;
  28. return $defaultArray;
  29. }
  30. public function storeValidationTestProvider()
  31. {
  32. $data = [
  33. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'alt_required'], true),
  34. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'description_required'], true),
  35. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'max_width'], 2),
  36. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'max_height'], 2),
  37. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'min_width'], 1500),
  38. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'min_height'], 1500),
  39. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'min_file_size'], 1000),
  40. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'max_file_size'], 0),
  41. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'exts'], ['jpg']),
  42. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'mimetypes'], ['image/jpg']),
  43. ];
  44. return $data;
  45. }
  46. public function storeValidationWithUuidTestProvider()
  47. {
  48. $data = [
  49. $this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'alt_required'], true),
  50. ];
  51. return $data;
  52. }
  53. }