#29: add more tests
This commit is contained in:
parent
c4cd275c83
commit
9afa7fe431
8 changed files with 331 additions and 184 deletions
|
@ -15,28 +15,45 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
final class FoodOrderController extends AbstractController
|
||||
{
|
||||
#[Route(
|
||||
path: '/list/{page}',
|
||||
path: '/list',
|
||||
name: 'app_food_order_index',
|
||||
methods: ['GET']
|
||||
)]
|
||||
public function index(FoodOrderRepository $foodOrderRepository): Response
|
||||
{
|
||||
|
||||
return $this->render('food_order/index.html.twig', [
|
||||
'food_orders' => $foodOrderRepository->findLatestEntries(days: 3),
|
||||
'current_page' => 0,
|
||||
'next_page' => 0,
|
||||
'prev_page' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
path: '/list/archive/{page}',
|
||||
name: 'app_food_order_archive',
|
||||
requirements: [
|
||||
'page' => '\d+',
|
||||
],
|
||||
methods: ['GET']
|
||||
)]
|
||||
public function index(FoodOrderRepository $foodOrderRepository, int $page = 1): Response
|
||||
public function archive(FoodOrderRepository $foodOrderRepository, int $page = 1): Response
|
||||
{
|
||||
$days = 4;
|
||||
if ($page > 1) {
|
||||
$days = 0;
|
||||
}
|
||||
$nextPage = $page + 1;
|
||||
$prevPage = $page - 1;
|
||||
$itemsPerPage = 10;
|
||||
if($foodOrderRepository->count() < $page * $itemsPerPage) {
|
||||
$count = $foodOrderRepository->count();
|
||||
if($count < $page * $itemsPerPage) {
|
||||
$nextPage = $page;
|
||||
}
|
||||
|
||||
return $this->render('food_order/index.html.twig', [
|
||||
'food_orders' => $foodOrderRepository->findLatestEntries(page: $page, pagesize: $itemsPerPage, days: $days),
|
||||
'food_orders' => $foodOrderRepository->findLatestEntries(
|
||||
page: $page,
|
||||
pagesize: $itemsPerPage,
|
||||
days: 0
|
||||
),
|
||||
'current_page' => $page,
|
||||
'next_page' => $nextPage,
|
||||
'prev_page' => $prevPage,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue