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.
56 lines
1.9 KiB
56 lines
1.9 KiB
<?php
|
|
|
|
namespace Tests\Feature\Collection;
|
|
|
|
use App\Models\Collection;
|
|
use Tests\Bootstrap;
|
|
|
|
class CollectionDeleteTest extends Bootstrap
|
|
{
|
|
public function test_collection_delete_success()
|
|
{
|
|
$this->modelWithPolicy('collections', ['permission:collections.delete'])
|
|
->loginAs(['collections.delete'])
|
|
->deleteJson(route("api.collections.destroy", $collection = $this->one(Collection::class)))
|
|
->assertOk();
|
|
|
|
$this->loginAsAdmin()
|
|
->getJson(route("api.collections.show", $collection))
|
|
->assertNotFound();
|
|
}
|
|
|
|
public function test_collection_restore_success()
|
|
{
|
|
$this->modelWithPolicy('collections', ['permission:collections.restore'])
|
|
->loginAsUser(['collections.restore'])
|
|
->deleteJson(route("api.collections.destroy", $collection = $this->trashed(Collection::class)))
|
|
->assertOk();
|
|
|
|
$this->loginAsAdmin()
|
|
->getJson(route("api.collections.show", $collection))
|
|
->assertOk();
|
|
}
|
|
|
|
public function test_collection_delete_forbidden()
|
|
{
|
|
$this->modelWithPolicy('collections', ['permission:collections.delete'])
|
|
->loginAs(['wrong.permission'])
|
|
->deleteJson(route("api.collections.destroy", $collection = $this->one(Collection::class)))
|
|
->assertForbidden();
|
|
}
|
|
|
|
public function test_collection_restore_forbidden()
|
|
{
|
|
$this->modelWithPolicy('collections', ['permission:collections.restore'])
|
|
->loginAs(['wrong.permission'])
|
|
->deleteJson(route("api.collections.destroy", $collection = $this->trashed(Collection::class)))
|
|
->assertForbidden();
|
|
}
|
|
|
|
public function test_collection_delete_notFound()
|
|
{
|
|
$this->loginAsAdmin()
|
|
->deleteJson(route("api.collections.destroy", 0))
|
|
->assertNotFound();
|
|
}
|
|
}
|