diff --git a/core/Test/ActionsControllerTest.php b/core/Test/ActionsControllerTest.php index c8a6b04c1c0f67c1991a81c30ab4cc856f1e2b09..4393207e3b7f7afbe3f5f11cfd6a1de73e2a0658 100755 --- a/core/Test/ActionsControllerTest.php +++ b/core/Test/ActionsControllerTest.php @@ -98,9 +98,9 @@ class ActionsControllerTest extends TestCase // FAIL READ $actionController = new \Action\controllers\ActionController(); - $response = $actionController->getById($request, new \Slim\Http\Response(), []); + $response = $actionController->getById($request, new \Slim\Http\Response(), ['id' => 'gaz']); $responseBody = json_decode((string)$response->getBody()); - $this->assertSame('id is empty', $responseBody->errors); + $this->assertSame('Id is not a numeric', $responseBody->errors); } @@ -198,7 +198,7 @@ class ActionsControllerTest extends TestCase public function testGetInitAction() { - // DELETE + // InitAction $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); $request = \Slim\Http\Request::createFromEnvironment($environment); diff --git a/src/app/action/controllers/ActionController.php b/src/app/action/controllers/ActionController.php index 77b0202bc976c49449a507305e2dc3802a2f83fb..83e4c5e4c29059158216900712f01e6595c8cb47 100644 --- a/src/app/action/controllers/ActionController.php +++ b/src/app/action/controllers/ActionController.php @@ -33,6 +33,11 @@ class ActionController public function getById(Request $request, Response $response, $aArgs) { + if (!Validator::intVal()->validate($aArgs['id'])) { + return $response + ->withStatus(500) + ->withJson(['errors' => 'Id is not a numeric']); + } $obj['action'] = ActionModel::getById(['id' => $aArgs['id']]); if(!empty($obj['action'])){