From bdbc257b6588e31b2b23915525389538ebceb9d7 Mon Sep 17 00:00:00 2001 From: et-nik Date: Sun, 26 May 2024 15:48:37 +0200 Subject: [PATCH] trying to fix permission tests --- .../Controllers/API/UsersControllerTest.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/Feature/Permissions/Controllers/API/UsersControllerTest.php b/tests/Feature/Permissions/Controllers/API/UsersControllerTest.php index 8e599b9c..282d43ad 100644 --- a/tests/Feature/Permissions/Controllers/API/UsersControllerTest.php +++ b/tests/Feature/Permissions/Controllers/API/UsersControllerTest.php @@ -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]], ]; } @@ -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), []);