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(); } }