Skip to content

Commit

Permalink
trying to fix permission tests
Browse files Browse the repository at this point in the history
  • Loading branch information
et-nik committed May 26, 2024
1 parent 18d96f3 commit bdbc257
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/Feature/Permissions/Controllers/API/UsersControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public function routesDataProvider()
return [
['get', 'api.users', []],
['post', 'api.users.store', []],
['get', 'api.users.servers', [$this->editedUser->id]],
['get', 'api.users.show', [$this->editedUser->id]],
['put', 'api.users.update', [$this->editedUser->id]],
['delete', 'api.users.destroy', [$this->editedUser->id]],
['get', 'api.users.servers', ['id' => $this->editedUser->id]],
['get', 'api.users.show', ['id' => $this->editedUser->id]],
['put', 'api.users.update', ['id' => $this->editedUser->id]],
['delete', 'api.users.destroy', ['id' => $this->editedUser->id]],
];
}

Expand All @@ -39,6 +39,12 @@ public function routesDataProvider()
*/
public function testForbidden(string $method, string $route, array $params = [])
{
// I hate f**king PHP. routesDataProvider gives me null in params
// I wish time to rewrite this to Golang
if ($method !== 'get') {
$params = ['id' => $this->editedUser->id];
}

$this->setCurrentUserRoles(['user']);

$response = $this->{$method}(route($route, $params), []);
Expand Down

0 comments on commit bdbc257

Please sign in to comment.