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.
40 lines
1.2 KiB
40 lines
1.2 KiB
<?php
|
|
|
|
namespace Tests\Feature\Collection;
|
|
|
|
use App\Models\Collection;
|
|
use App\Documents\UserDocument;
|
|
use Tests\Bootstrap;
|
|
use Illuminate\Support\Arr;
|
|
|
|
class CollectionStoreTest extends Bootstrap
|
|
{
|
|
public function test_collection_store_success()
|
|
{
|
|
$this->modelWithPolicy('collections', ['permission:collections.store'])
|
|
->loginAs(['collections.store'])
|
|
->postJson(route('api.collections.store'), $collection = $this->make(Collection::class))
|
|
->assertCreated();
|
|
}
|
|
|
|
/**
|
|
* @testWith
|
|
* ["name:gt"]
|
|
*/
|
|
public function test_collection_store_unprocessable($field)
|
|
{
|
|
$this->modelWithPolicy('collections', ['permission:collections.store'])
|
|
->loginAsAdmin()
|
|
->postJson(route("api.collections.store"), $collection = $this->make(collection::class, smash: $field, withDependency: true))
|
|
->assertUnprocessable();
|
|
|
|
}
|
|
|
|
public function test_collection_store_forbidden()
|
|
{
|
|
$this->modelWithPolicy('collections', ['permission:collections.store'])
|
|
->loginAs(['wrong.permission'])
|
|
->postJson(route("api.collections.store"), [])
|
|
->assertForbidden();
|
|
}
|
|
}
|