|
|
@ -27,7 +27,7 @@ class FileStoreTest extends Bootstrap |
|
|
|
"description" => 'lfjdsklfslfsdlfasdfsfhgsfgsdf', |
|
|
|
"public" => 1 |
|
|
|
]; |
|
|
|
$collection = Collection::factory()->create([ |
|
|
|
$collection = Collection::factory()->createQuietly([ |
|
|
|
'tmp_support' => false |
|
|
|
]); |
|
|
|
|
|
|
@ -66,7 +66,7 @@ class FileStoreTest extends Bootstrap |
|
|
|
|
|
|
|
public function test_file_is_not_isset_forbidden() |
|
|
|
{ |
|
|
|
$collection = Collection::factory()->create([ |
|
|
|
$collection = Collection::factory()->createQuietly([ |
|
|
|
'tmp_support' => true |
|
|
|
]); |
|
|
|
$data = [ |
|
|
@ -105,23 +105,35 @@ class FileStoreTest extends Bootstrap |
|
|
|
*/ |
|
|
|
public function test_store_dynamic_validation_unprocessable($collectionFields, $dataFields) |
|
|
|
{ |
|
|
|
$collection = Collection::factory()->create($collectionFields); |
|
|
|
$collection = Collection::factory()->createQuietly($collectionFields); |
|
|
|
$response = $this->loginAs()->postJson(route('api.files.store', ['collection_name' => $collection->name]), $dataFields); |
|
|
|
$response->assertUnprocessable(); |
|
|
|
} |
|
|
|
|
|
|
|
// /**
|
|
|
|
// * @testWith
|
|
|
|
// * ['email:gt']
|
|
|
|
// * ['email:gt']
|
|
|
|
// * ['email:gt']
|
|
|
|
// * ['email:gt']
|
|
|
|
// * ['email:gt']
|
|
|
|
// */
|
|
|
|
// public function test_store_static_validation_unprocessable($key)
|
|
|
|
// {
|
|
|
|
// File::factory()->smash($key);
|
|
|
|
// }
|
|
|
|
public function test_store_static_validation_unprocessable() |
|
|
|
{ |
|
|
|
$collection = Collection::factory()->createQuietly([ |
|
|
|
'alt_required' => false, |
|
|
|
'description_required' => true, |
|
|
|
'tmp_support' => true, |
|
|
|
'max_width' => 2000, |
|
|
|
'max_height' => 2000, |
|
|
|
'min_width' => 1, |
|
|
|
'min_height' => 1, |
|
|
|
'min_file_size' => 0 |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
$data = [ |
|
|
|
"file" => UploadedFile::fake()->image('lol.png'), |
|
|
|
"description" => Str::random(1000) |
|
|
|
]; |
|
|
|
|
|
|
|
$this->modelWithPolicy('collections', ['permission:collections.store']) |
|
|
|
->loginAsAdmin() |
|
|
|
->postJson(route("api.files.store", ['collection_name' => $collection->name]), $data) |
|
|
|
->assertUnprocessable(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -221,22 +233,14 @@ class FileStoreTest extends Bootstrap |
|
|
|
'min_file_size' => 0, |
|
|
|
'count' => 1 |
|
|
|
]); |
|
|
|
$uuid = app()->uuid; |
|
|
|
$file = File::factory()->createQuietly([ |
|
|
|
'uuid' => $uuid, |
|
|
|
'server_path' => '/' . date('y') . '/' . date('m') . '/', |
|
|
|
'user_id' => auth()->id(), |
|
|
|
'collection_id' => $collection->id |
|
|
|
]); |
|
|
|
$imageProcessor = new ImageProcessor; |
|
|
|
$imageProcessor->createFakeImage(storage_path('stub') . '/image.png', Storage::disk($collection->disk)->path($file->server_path . $uuid . '.' . $collection->ext)); |
|
|
|
|
|
|
|
|
|
|
|
$data = [ |
|
|
|
"file" => $file->uuid, |
|
|
|
"file" => UploadedFile::fake()->image('lol.png'), |
|
|
|
"public" => 1 |
|
|
|
]; |
|
|
|
|
|
|
|
$response = $this->loginAs()->postJson(route('api.files.store', ['collection_name' => $collection->name]), $data); |
|
|
|
$response = $this->loginAs()->postJson(route('api.files.store', ['collection_name' => $collection->name, 'model_id' => 100]), $data); |
|
|
|
$response->assertCreated(); |
|
|
|
} |
|
|
|
|
|
|
@ -268,8 +272,7 @@ class FileStoreTest extends Bootstrap |
|
|
|
"public" => 1 |
|
|
|
]; |
|
|
|
|
|
|
|
$response = $this->loginAs()->postJson(route('api.files.store', ['collection_name' => $collection->name]), $data); |
|
|
|
$response = $this->loginAs()->postJson(route('api.files.store', ['collection_name' => $collection->name, 'model_id' => 100]), $data); |
|
|
|
$response->assertCreated(); |
|
|
|
} |
|
|
|
|
|
|
|
} |