From fa17b1e50d89fc528c8e8f43ddb0f611a1d2b902 Mon Sep 17 00:00:00 2001 From: Nathan Boiron Date: Fri, 5 Jul 2024 23:22:16 +0200 Subject: [PATCH] Ajout d'un header pour savoir s'il y a une page suivante MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ce header permet de conditioner la présence d'un bouton pour voir la page suivante des articles. --- sources/AppBundle/Controller/Planete/ArticlesController.php | 1 + tests/behat/features/Api/PlanetePHPApi.feature | 2 ++ 2 files changed, 3 insertions(+) diff --git a/sources/AppBundle/Controller/Planete/ArticlesController.php b/sources/AppBundle/Controller/Planete/ArticlesController.php index 02c22f61b..9a6345849 100644 --- a/sources/AppBundle/Controller/Planete/ArticlesController.php +++ b/sources/AppBundle/Controller/Planete/ArticlesController.php @@ -54,6 +54,7 @@ public function __invoke(Request $request): Response 'Content-Type' => 'application/json', 'X-Pagination-Total' => $totalCount, 'X-Pagination-Per-Page' => $perPage, + 'X-Pagination-Has-Next-Page' => $totalCount > $page * $perPage, ] ); } diff --git a/tests/behat/features/Api/PlanetePHPApi.feature b/tests/behat/features/Api/PlanetePHPApi.feature index d98a39d1d..f21a8f3bb 100644 --- a/tests/behat/features/Api/PlanetePHPApi.feature +++ b/tests/behat/features/Api/PlanetePHPApi.feature @@ -6,6 +6,7 @@ Feature: PlanetePHP API routes And the response header "Content-Type" should equal "application/json" And the response header "X-Pagination-Total" should equal 22 And the response header "X-Pagination-Per-Page" should equal 20 + And the response header "X-Pagination-Has-Next-Page" should match '#^1$#' And the json response has the key "title" with value "Un titre" And the json response has the key "url" with value "https:\/\/afup.org\/url.html" And the json response has the key "author" with value "Un super auteur" @@ -17,6 +18,7 @@ Feature: PlanetePHP API routes And the response header "Content-Type" should equal "application/json" And the response header "X-Pagination-Total" should equal 22 And the response header "X-Pagination-Per-Page" should equal 20 + And the response header "X-Pagination-Has-Next-Page" should match '#^$#' And the json response has the key "title" with value "Un titre 18" And the json response has the key "url" with value "https:\/\/afup.org\/url-18.html" And the json response has the key "author" with value "Un super auteur 18"