public function put_ValidHandler_RegisterEndpoint() { // arrange $expectedEndpoint = new Endpoint(self::VALID_ENDPOINT_PATH, $this->VALID_ENDPOINT_DEPENDENCIES, $this->VALID_ENDPOINT_HANDLER); $module = new Module(self::VALID_MODULE_NAME); // act $module->put(self::VALID_ENDPOINT_PATH, $this->VALID_ENDPOINT_DEPENDENCIES, $this->VALID_ENDPOINT_HANDLER); // assert Assert::areSame($module->endpoints, ['GET' => [], 'POST' => [], 'PUT' => [self::VALID_ENDPOINT_PATH => $expectedEndpoint], 'DELETE' => []]); }
* "id": 1, * "username": "******", * "password": "******", * "email": "*****@*****.**", * "notes": "", * "deleted": false, * "created_at": "2016-01-22 00:24:08", * "updated_at": "2016-01-22 00:24:08" * } * * @apiError (Error 404) UserNotFoundError When the user id isn't found. * * @apiErrorExample Error Response Example * HTTP/1.1 404 Not Found * { * "error": "UserNotFoundError" * "reason: "The user id was not found." * } */ $user->get('', ['userService'], function (Request $request, Response $response, $id, IUserService $userService) { try { $response->json($userService->find($id)); } catch (UserNotFoundException $e) { $response->status = 404; $response->json(['error' => 'UserNotFoundError', 'reason' => 'The user id was not found.']); } }); $user->put('', ['userService'], function (Request $request, Response $response, $id, IUserService $userService) { }); $user->delete('', ['userService'], function (Request $request, Response $response, $id, IUserService $userService) { });