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.
89 lines
2.8 KiB
89 lines
2.8 KiB
<?php
|
|
|
|
namespace Tests\Feature\Traits;
|
|
|
|
use Illuminate\Http\UploadedFile;
|
|
|
|
trait FileTraits
|
|
{
|
|
|
|
private function defaultArray()
|
|
{
|
|
return [
|
|
[
|
|
'alt_required' => false,
|
|
'description_required' => false,
|
|
'tmp_support' => true,
|
|
'max_width' => 2000,
|
|
'max_height' => 2000,
|
|
'min_width' => 1,
|
|
'min_height' => 1,
|
|
'min_file_size' => 0
|
|
],
|
|
[
|
|
"file" => UploadedFile::fake()->image('test.png', 400, 400),
|
|
"public" => 1
|
|
]
|
|
];
|
|
}
|
|
|
|
private function defaultArrayForUpdate()
|
|
{
|
|
return [
|
|
[
|
|
'alt_required' => false,
|
|
'description_required' => false,
|
|
'tmp_support' => true,
|
|
'max_width' => 2000,
|
|
'max_height' => 2000,
|
|
'min_width' => 1,
|
|
'min_height' => 1,
|
|
'min_file_size' => 0
|
|
]
|
|
];
|
|
}
|
|
|
|
private function changeDefaultArrayAndReturn($defaultArray, $key, $value): array
|
|
{
|
|
$defaultArray[$key[0]][$key[1]] = $value;
|
|
return $defaultArray;
|
|
}
|
|
|
|
public function storeValidationTestProvider()
|
|
{
|
|
|
|
$data = [
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'alt_required'], true),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'description_required'], true),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'max_width'], 2),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'max_height'], 2),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'min_width'], 1500),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'min_height'], 1500),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'min_file_size'], 1000),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'max_file_size'], 0),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'exts'], ['jpg']),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'mimetypes'], ['image/jpg']),
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
|
|
public function storeValidationWithUuidTestProvider()
|
|
{
|
|
|
|
$data = [
|
|
$this->changeDefaultArrayAndReturn($this->defaultArray(), [0, 'alt_required'], true),
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
public function updateValidationTestProvider()
|
|
{
|
|
|
|
$data = [
|
|
$this->changeDefaultArrayAndReturn($this->defaultArrayForUpdate(), [0, 'alt_required'], true),
|
|
$this->changeDefaultArrayAndReturn($this->defaultArrayForUpdate(), [0, 'description_required'], true),
|
|
];
|
|
return $data;
|
|
}
|
|
}
|