diff --git a/src/Auth/Oauth.php b/src/Auth/Oauth.php index c1c6281..81ca20a 100644 --- a/src/Auth/Oauth.php +++ b/src/Auth/Oauth.php @@ -49,7 +49,7 @@ public function registerUser(Request $request, Response $response) } /** - * This method creates user + * This method creates user. * * @param $user * @param $userParams diff --git a/src/Controller/EmojiController.php b/src/Controller/EmojiController.php index fc1235b..f71b521 100644 --- a/src/Controller/EmojiController.php +++ b/src/Controller/EmojiController.php @@ -89,13 +89,13 @@ public function createEmoji(Request $request, Response $response) if (is_array($requestParams)) { if (!$this->checkForDuplicateEmoji($requestParams['name'])) { // Validate the user input fields - $validateResponse = $this->validateUserInput(['name','char','category','keywords',], $requestParams); + $validateResponse = $this->validateUserInput(['name', 'char', 'category', 'keywords'], $requestParams); if (is_array($validateResponse)) { return $response->withJson($validateResponse, 400); } + return $this->runCreateEmoji($request, $response, $requestParams); - } return $response->withJson(['message' => 'Emoji cannot be duplicated'], 400); @@ -103,8 +103,8 @@ public function createEmoji(Request $request, Response $response) } /** + * This method creates emoji and keywords associated with it. * - * This method creates emoji and keywords associated with it * @param $emoji * @param $request * @param $response @@ -144,7 +144,7 @@ public function updateEmojiByPutVerb(Request $request, Response $response, $args $emoji = Emoji::find($args['id']); if (count($emoji) > 0) { // Validate the user input fields - $validateResponse = $this->validateUserInput(['name','char','category',], $updateParams); + $validateResponse = $this->validateUserInput(['name', 'char', 'category'], $updateParams); if (is_array($validateResponse)) { return $response->withJson($validateResponse, 400); } @@ -153,13 +153,13 @@ public function updateEmojiByPutVerb(Request $request, Response $response, $args } return $response->withJson([ - 'message' => 'Record cannot be updated because the id supplied is invalid' + 'message' => 'Record cannot be updated because the id supplied is invalid', ], 404); } } /** - * This method updates an emoji + * This method updates an emoji. * * @param $emoji * @param $response @@ -207,7 +207,7 @@ public function updateEmojiByPatchVerb(Request $request, Response $response, $ar } return $response->withJson([ - 'message' => 'No record to update because the id supplied is invalid' + 'message' => 'No record to update because the id supplied is invalid', ], 404); } } @@ -238,12 +238,12 @@ public function deleteEmoji(Request $request, Response $response, $args) } return $response->withJson([ - 'message' => 'Emoji cannot be deleted because you are not the creator' + 'message' => 'Emoji cannot be deleted because you are not the creator', ], 401); } return $response->withJson([ - 'message' => 'Emoji cannot be deleted because the id supplied is invalid' + 'message' => 'Emoji cannot be deleted because the id supplied is invalid', ], 404); } diff --git a/test/EmojiEndpointTest.php b/test/EmojiEndpointTest.php index d06ded9..54b8640 100644 --- a/test/EmojiEndpointTest.php +++ b/test/EmojiEndpointTest.php @@ -220,7 +220,7 @@ public function testThatInCorrectLoginCredentialWhereUsedToLogin() $this->app->getContainer()['request'] = $req; $response = $this->app->run(true); - + $this->assertSame($response->getStatusCode(), 400); } @@ -455,9 +455,9 @@ public function testDeleteEmoji() public function testuserLogoutWithToken() { $env = Environment::mock([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/auth/logout', - 'CONTENT_TYPE' => 'application/json', + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/auth/logout', + 'CONTENT_TYPE' => 'application/json', 'HTTP_AUTHORIZATION' => json_encode(['jwt' => $this->getCurrentToken()]), ]); @@ -472,9 +472,9 @@ public function testuserLogoutWithToken() public function testuserWantToLogoutWithoutCorrectQueryParams() { $env = Environment::mock([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/auth/signout', - 'CONTENT_TYPE' => 'application/json', + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/auth/signout', + 'CONTENT_TYPE' => 'application/json', 'HTTP_AUTHORIZATION' => json_encode(['jwt' => $this->getCurrentToken()]), ]);