modelWithPolicy('collections', ['permission:collections.store']) ->loginAs(['collections.store']) ->postJson(route('api.collections.store'), $collection = $this->make(Collection::class)) ->assertCreated(); } /** * @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_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(); } }