diff --git a/src/Features/Traits/Common.php b/src/Features/Traits/Common.php new file mode 100644 index 0000000..280e340 --- /dev/null +++ b/src/Features/Traits/Common.php @@ -0,0 +1,57 @@ +seedModelInTheDatabase("Role", $roleTable); + $userArray = [ + ["name", $role], + ["email", "userWithRole@example.com"], + ["password", "password123!@#"], + ]; + $userTable = new TableNode($userArray); + $this->seedModelInTheDatabase("User", $userTable); + + $this->assignRoleTo($role, "User", "userWithRole@example.com", "email"); + + $this->userIsAuthenticatedInSessionAs($role, "name"); + } + + /** + * @Given admin user is getting OK response from :url + * @Given admin user is getting :status status code response from :url + * @Given user with :role role is getting OK response from :url + * @Given user with :role role is getting :status response from :url + * @Given user with :role role is getting OK response from :url using :method method + * @Given user with :role role is getting :status response from :url using :method method + */ + public function adminUserIsGettingResponse(string $url, string $method = "GET", int $status = Response::HTTP_OK, string $role = "admin"): void + { + $this->sessionHasUserWithRole($role); + $this->aUserIsRequesting($url, $method); + $this->aRequestIsSent(); + $this->aResponseShouldHaveStatus($status); + } +}