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.
55 lines
1.7 KiB
55 lines
1.7 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:gt"]
|
|
*/
|
|
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();
|
|
}
|
|
}
|