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.
 
 
 
 

67 lines
2.0 KiB

<?php
namespace Tests\Feature\Collection;
use App\Models\Collection;
use Tests\Bootstrap;
use App\Models\User;
use Illuminate\Support\Arr;
class CollectionUpdateTest extends Bootstrap
{
public function test_collection_update_success()
{
$this->modelWithPolicy('collections', ['permission:collections.update'])
->loginAs(['collections.update'])
->putJson(
route("api.collections.update", $collection = $this->one(Collection::class)),
$update = $this->make(Collection::class, withDependency: true)
)
->assertOk();
}
/**
* @testWith
* ["name:gtString"]
* ["name:numeric"]
* ["name:null"]
* ["path:gtString"]
* ["path:numeric"]
* ["public:string"]
* ["disk:numeric"]
* ["disk:null"]
* ["disk:gtString"]
* ["count:null"]
* ["count:string"]
* ["count:gt:100000"]
*
*/
public function test_collection_update_unprocessable($field)
{
$this->modelWithPolicy('collections', ['permission:collections.update'])
->loginAs(['collections.update'])->putJson(
route("api.collections.update", $collection = $this->one(Collection::class)),
$update = $this->make(collection::class, smash: $field, withDependency: true)
)
->assertUnprocessable();
}
public function test_collection_update_forbidden()
{
$this->modelWithPolicy('collections', ['permission:collections.update'])
->loginAs(['wrong.permission'])
->putJson(
route("api.collections.update", $collection = $this->one(Collection::class)),
[]
)
->assertForbidden();
}
public function test_collection_update_not_found()
{
$this->loginAsUser(['collections.update'])
->putJson(route("api.collections.update", 0), [])
->assertNotFound();
}
}