Skip to content

Commit

Permalink
Supprime le endpoint /parks/[id]/materials, non utilisé
Browse files Browse the repository at this point in the history
  • Loading branch information
Donov4n committed Jan 16, 2021
1 parent 5f5f346 commit 4c7a69b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 41 deletions.
1 change: 0 additions & 1 deletion server/src/App/ApiRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
26 changes: 0 additions & 26 deletions server/src/App/Controllers/ParkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
14 changes: 0 additions & 14 deletions server/tests/endpoints/ParksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit 4c7a69b

Please sign in to comment.