diff --git a/server/src/App/ApiRouter.php b/server/src/App/ApiRouter.php index eb73f5356..52e77a803 100644 --- a/server/src/App/ApiRouter.php +++ b/server/src/App/ApiRouter.php @@ -25,7 +25,6 @@ class ApiRouter '/companies/{id:[0-9]+}/persons[/]' => 'CompanyController:getPersons', '/parks[/]' => 'ParkController:getAll', '/parks/{id:[0-9]+}[/]' => 'ParkController:getOne', - '/parks/{id:[0-9]+}/materials[/]' => 'ParkController:getMaterials', '/materials[/]' => 'MaterialController:getAll', '/materials/{id:[0-9]+}[/]' => 'MaterialController:getOne', '/materials/{id:[0-9]+}/tags[/]' => 'MaterialController:getTags', diff --git a/server/src/App/Controllers/ParkController.php b/server/src/App/Controllers/ParkController.php index c39896659..3338a3f46 100644 --- a/server/src/App/Controllers/ParkController.php +++ b/server/src/App/Controllers/ParkController.php @@ -3,32 +3,6 @@ namespace Robert2\API\Controllers; -use Robert2\API\Errors; -use Slim\Http\Request; -use Slim\Http\Response; - class ParkController extends BaseController { - // —————————————————————————————————————————————————————— - // — - // — Model dedicated methods - // — - // —————————————————————————————————————————————————————— - - public function getMaterials(Request $request, Response $response) - { - $id = (int)$request->getAttribute('id'); - if (!$this->model->exists($id)) { - throw new Errors\NotFoundException; - } - - $Park = $this->model->find($id); - $materials = $Park->Materials()->paginate($this->itemsCount); - - $basePath = $request->getUri()->getPath(); - $materials->withPath($basePath); - - $results = $this->_formatPagination($materials); - return $response->withJson($results); - } } diff --git a/server/tests/endpoints/ParksTest.php b/server/tests/endpoints/ParksTest.php index c7524cad0..93ff9315c 100644 --- a/server/tests/endpoints/ParksTest.php +++ b/server/tests/endpoints/ParksTest.php @@ -96,18 +96,4 @@ public function testGetPark() 'deleted_at' => null, ]); } - - public function testGetMaterialsNotFound() - { - $this->client->get('/api/parks/999/materials'); - $this->assertStatusCode(ERROR_NOT_FOUND); - $this->assertNotFoundErrorMessage(); - } - - public function testGetMaterials() - { - $this->client->get('/api/parks/1/materials'); - $this->assertStatusCode(SUCCESS_OK); - $this->assertResponsePaginatedData(5, '/api/parks/1/materials'); - } }