Skip to content

Commit 98d3b08

Browse files
committed
tests: use route key rather than key in cursor pagination test
1 parent 9a19ebd commit 98d3b08

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

tests/lib/Acceptance/Pagination/CursorPaginationTest.php

+48-48
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ public function testDefaultPagination(): void
9494

9595
$meta = [
9696
'from' => $this->encodeCursor(
97-
["id" => (string) $posts[3]->getKey()],
97+
["id" => (string) $posts[3]->getRouteKey()],
9898
pointsToNextItems: false,
9999
),
100100
'hasMore' => false,
101101
'perPage' => 10,
102102
'to' => $this->encodeCursor(
103-
["id" => (string) $posts[0]->getKey()],
103+
["id" => (string) $posts[0]->getRouteKey()],
104104
pointsToNextItems: true,
105105
),
106106
];
@@ -238,13 +238,13 @@ public function testWithoutCursor(): void
238238

239239
$meta = [
240240
'from' => $this->encodeCursor(
241-
["id" => (string) $posts[3]->getKey()],
241+
["id" => (string) $posts[3]->getRouteKey()],
242242
pointsToNextItems: false,
243243
),
244244
'hasMore' => true,
245245
'perPage' => 3,
246246
'to' => $this->encodeCursor(
247-
["id" => (string) $posts[1]->getKey()],
247+
["id" => (string) $posts[1]->getRouteKey()],
248248
pointsToNextItems: true,
249249
),
250250
];
@@ -259,7 +259,7 @@ public function testWithoutCursor(): void
259259
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
260260
'page' => [
261261
'after' => $this->encodeCursor(
262-
["id" => (string) $posts[1]->getKey()],
262+
["id" => (string) $posts[1]->getRouteKey()],
263263
pointsToNextItems: true,
264264
),
265265
'limit' => '3',
@@ -286,13 +286,13 @@ public function testWithAscending(): void
286286

287287
$meta = [
288288
'from' => $this->encodeCursor(
289-
["id" => (string) $posts[0]->getKey()],
289+
["id" => (string) $posts[0]->getRouteKey()],
290290
pointsToNextItems: false,
291291
),
292292
'hasMore' => true,
293293
'perPage' => 3,
294294
'to' => $this->encodeCursor(
295-
["id" => (string) $posts[2]->getKey()],
295+
["id" => (string) $posts[2]->getRouteKey()],
296296
pointsToNextItems: true,
297297
),
298298
];
@@ -307,7 +307,7 @@ public function testWithAscending(): void
307307
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
308308
'page' => [
309309
'after' => $this->encodeCursor(
310-
["id" => (string) $posts[2]->getKey()],
310+
["id" => (string) $posts[2]->getRouteKey()],
311311
pointsToNextItems: true,
312312
),
313313
'limit' => '3',
@@ -334,13 +334,13 @@ public function testAfter(): void
334334

335335
$meta = [
336336
'from' => $this->encodeCursor(
337-
["id" => (string) $posts[0]->getKey()],
337+
["id" => (string) $posts[0]->getRouteKey()],
338338
pointsToNextItems: false,
339339
),
340340
'hasMore' => false,
341341
'perPage' => 3,
342342
'to' => $this->encodeCursor(
343-
["id" => (string) $posts[0]->getKey()],
343+
["id" => (string) $posts[0]->getRouteKey()],
344344
pointsToNextItems: true,
345345
),
346346
];
@@ -355,7 +355,7 @@ public function testAfter(): void
355355
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
356356
'page' => [
357357
'before' => $this->encodeCursor(
358-
["id" => (string) $posts[0]->getKey()],
358+
["id" => (string) $posts[0]->getRouteKey()],
359359
pointsToNextItems: false,
360360
),
361361
'limit' => '3',
@@ -366,7 +366,7 @@ public function testAfter(): void
366366

367367
$page = $this->posts->repository()->queryAll()->paginate([
368368
'after' => $this->encodeCursor(
369-
["id" => (string) $posts[1]->getKey()],
369+
["id" => (string) $posts[1]->getRouteKey()],
370370
pointsToNextItems: true,
371371
),
372372
'limit' => '3',
@@ -390,12 +390,12 @@ public function testAfterWithIdEncoding(): void
390390

391391
$meta = [
392392
'from' => $this->encodeCursor([
393-
"id" => 'TEST-' . $posts[6]->getKey(),
393+
"id" => 'TEST-' . $posts[6]->getRouteKey(),
394394
], pointsToNextItems: false),
395395
'hasMore' => true,
396396
'perPage' => 3,
397397
'to' => $this->encodeCursor([
398-
"id" => 'TEST-' . $posts[4]->getKey(),
398+
"id" => 'TEST-' . $posts[4]->getRouteKey(),
399399
], pointsToNextItems: true),
400400
];
401401

@@ -409,7 +409,7 @@ public function testAfterWithIdEncoding(): void
409409
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
410410
'page' => [
411411
'after' => $this->encodeCursor([
412-
"id" => "TEST-" . $posts[4]->getKey(),
412+
"id" => "TEST-" . $posts[4]->getRouteKey(),
413413
], pointsToNextItems: true),
414414
'limit' => '3',
415415
]
@@ -419,7 +419,7 @@ public function testAfterWithIdEncoding(): void
419419
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
420420
'page' => [
421421
'before' => $this->encodeCursor([
422-
"id" => "TEST-" . $posts[6]->getKey(),
422+
"id" => "TEST-" . $posts[6]->getRouteKey(),
423423
], pointsToNextItems: false),
424424
'limit' => '3',
425425
],
@@ -429,7 +429,7 @@ public function testAfterWithIdEncoding(): void
429429

430430
$page = $this->posts->repository()->queryAll()->paginate([
431431
'after' => $this->encodeCursor([
432-
"id" => 'TEST-' . $posts[7]->getKey(),
432+
"id" => 'TEST-' . $posts[7]->getRouteKey(),
433433
], pointsToNextItems: true),
434434
'limit' => 3,
435435
]);
@@ -449,12 +449,12 @@ public function testBefore(): void
449449

450450
$meta = [
451451
'from' => $this->encodeCursor([
452-
"id" => (string) $posts[3]->getKey(),
452+
"id" => (string) $posts[3]->getRouteKey(),
453453
], pointsToNextItems: false),
454454
'hasMore' => true,
455455
'perPage' => 3,
456456
'to' => $this->encodeCursor([
457-
"id" => (string) $posts[1]->getKey(),
457+
"id" => (string) $posts[1]->getRouteKey(),
458458
], pointsToNextItems: true),
459459
];
460460

@@ -468,7 +468,7 @@ public function testBefore(): void
468468
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
469469
'page' => [
470470
'before' => $this->encodeCursor([
471-
"id" => (string) $posts[3]->getKey(),
471+
"id" => (string) $posts[3]->getRouteKey(),
472472
], pointsToNextItems: false),
473473
'limit' => '3',
474474
]
@@ -478,7 +478,7 @@ public function testBefore(): void
478478

479479
$page = $this->posts->repository()->queryAll()->paginate([
480480
'before' => $this->encodeCursor([
481-
"id" => (string) $posts[0]->getKey(),
481+
"id" => (string) $posts[0]->getRouteKey(),
482482
], pointsToNextItems: false),
483483
'limit' => '3',
484484
]);
@@ -501,12 +501,12 @@ public function testBeforeWithIdEncoding(): void
501501

502502
$meta = [
503503
'from' => $this->encodeCursor([
504-
"id" => 'TEST-' . $posts[6]->getKey(),
504+
"id" => 'TEST-' . $posts[6]->getRouteKey(),
505505
], pointsToNextItems: false),
506506
'hasMore' => true,
507507
'perPage' => 3,
508508
'to' => $this->encodeCursor([
509-
"id" => 'TEST-' . $posts[4]->getKey(),
509+
"id" => 'TEST-' . $posts[4]->getRouteKey(),
510510
], pointsToNextItems: true),
511511
];
512512

@@ -520,7 +520,7 @@ public function testBeforeWithIdEncoding(): void
520520
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
521521
'page' => [
522522
'before' => $this->encodeCursor([
523-
"id" => "TEST-" . $posts[6]->getKey(),
523+
"id" => "TEST-" . $posts[6]->getRouteKey(),
524524
], pointsToNextItems: false),
525525
'limit' => '3',
526526
],
@@ -530,7 +530,7 @@ public function testBeforeWithIdEncoding(): void
530530

531531
$page = $this->posts->repository()->queryAll()->paginate([
532532
'before' => $this->encodeCursor([
533-
"id" => 'TEST-' . $posts[3]->getKey(),
533+
"id" => 'TEST-' . $posts[3]->getRouteKey(),
534534
], pointsToNextItems: false),
535535
'limit' => 3,
536536
]);
@@ -549,12 +549,12 @@ public function testItUsesModelDefaultPerPage(): void
549549

550550
$meta = [
551551
'from' => $this->encodeCursor([
552-
"id" => (string) $posts->last()->getKey(),
552+
"id" => (string) $posts->last()->getRouteKey(),
553553
], pointsToNextItems: false),
554554
'hasMore' => true,
555555
'perPage' => $expected,
556556
'to' => $this->encodeCursor([
557-
"id" => (string) $posts[1]->getKey(),
557+
"id" => (string) $posts[1]->getRouteKey(),
558558
], pointsToNextItems: true),
559559
];
560560

@@ -568,7 +568,7 @@ public function testItUsesModelDefaultPerPage(): void
568568
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
569569
'page' => [
570570
'after' => $this->encodeCursor([
571-
"id" => (string) $posts[1]->getKey(),
571+
"id" => (string) $posts[1]->getRouteKey(),
572572
], pointsToNextItems: true),
573573
'limit' => $expected,
574574
],
@@ -596,12 +596,12 @@ public function testItUsesDefaultPerPage(): void
596596

597597
$meta = [
598598
'from' => $this->encodeCursor([
599-
"id" => (string) $posts->last()->getKey(),
599+
"id" => (string) $posts->last()->getRouteKey(),
600600
], pointsToNextItems: false),
601601
'hasMore' => true,
602602
'perPage' => $expected,
603603
'to' => $this->encodeCursor([
604-
"id" => (string) $posts[1]->getKey(),
604+
"id" => (string) $posts[1]->getRouteKey(),
605605
], pointsToNextItems: true),
606606
];
607607

@@ -615,7 +615,7 @@ public function testItUsesDefaultPerPage(): void
615615
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
616616
'page' => [
617617
'after' => $this->encodeCursor([
618-
"id" => (string) $posts[1]->getKey(),
618+
"id" => (string) $posts[1]->getRouteKey(),
619619
], pointsToNextItems: true),
620620
'limit' => $expected,
621621
],
@@ -835,7 +835,7 @@ public function testCustomPageKeys(): void
835835
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
836836
'page' => [
837837
'next' => $this->encodeCursor(
838-
["id" => (string) $posts[1]->getKey()],
838+
["id" => (string) $posts[1]->getRouteKey()],
839839
pointsToNextItems: true,
840840
),
841841
'perPage' => '3',
@@ -860,7 +860,7 @@ public function testCustomPageKeys(): void
860860
'page' => [
861861
'perPage' => '3',
862862
'prev' => $this->encodeCursor(
863-
["id" => (string) $posts[0]->getKey()],
863+
["id" => (string) $posts[0]->getRouteKey()],
864864
pointsToNextItems: false,
865865
),
866866
],
@@ -870,7 +870,7 @@ public function testCustomPageKeys(): void
870870

871871
$page = $this->posts->repository()->queryAll()->paginate([
872872
'next' => $this->encodeCursor(
873-
["id" => (string) $posts[1]->getKey()],
873+
["id" => (string) $posts[1]->getRouteKey()],
874874
pointsToNextItems: true,
875875
),
876876
'perPage' => '3',
@@ -890,12 +890,12 @@ public function testSnakeCaseMetaAndCustomMetaKey(): void
890890

891891
$meta = [
892892
'from' => $this->encodeCursor([
893-
"id" => (string) $posts[3]->getKey(),
893+
"id" => (string) $posts[3]->getRouteKey(),
894894
], pointsToNextItems: false),
895895
'has_more' => true,
896896
'per_page' => 3,
897897
'to' => $this->encodeCursor([
898-
"id" => (string) $posts[1]->getKey(),
898+
"id" => (string) $posts[1]->getRouteKey(),
899899
], pointsToNextItems: true),
900900
];
901901

@@ -916,12 +916,12 @@ public function testDashCaseMeta(): void
916916

917917
$meta = [
918918
'from' => $this->encodeCursor([
919-
"id" => (string) $posts[3]->getKey(),
919+
"id" => (string) $posts[3]->getRouteKey(),
920920
], pointsToNextItems: false),
921921
'has-more' => true,
922922
'per-page' => 3,
923923
'to' => $this->encodeCursor([
924-
"id" => (string) $posts[1]->getKey(),
924+
"id" => (string) $posts[1]->getRouteKey(),
925925
], pointsToNextItems: true),
926926
];
927927

@@ -942,12 +942,12 @@ public function testMetaNotNested(): void
942942

943943
$meta = [
944944
'from' => $this->encodeCursor([
945-
"id" => (string) $posts[3]->getKey(),
945+
"id" => (string) $posts[3]->getRouteKey(),
946946
], pointsToNextItems: false),
947947
'hasMore' => true,
948948
'perPage' => 3,
949949
'to' => $this->encodeCursor([
950-
"id" => (string) $posts[1]->getKey(),
950+
"id" => (string) $posts[1]->getRouteKey(),
951951
], pointsToNextItems: true),
952952
];
953953

@@ -976,7 +976,7 @@ public function testItCanRemoveMeta(): void
976976
'href' => 'http://localhost/api/v1/posts?' . Arr::query([
977977
'page' => [
978978
'after' => $this->encodeCursor([
979-
"id" => (string) $posts[1]->getKey(),
979+
"id" => (string) $posts[1]->getRouteKey(),
980980
], pointsToNextItems: true),
981981
'limit' => '3',
982982
],
@@ -1018,7 +1018,7 @@ public function testUrlsIncludeOtherQueryParameters(): void
10181018
'include' => 'author',
10191019
'page' => [
10201020
'after' => $this->encodeCursor([
1021-
"id" => (string) $posts[1]->getKey(),
1021+
"id" => (string) $posts[1]->getRouteKey(),
10221022
], pointsToNextItems: true),
10231023
'limit' => '3',
10241024
],
@@ -1051,12 +1051,12 @@ public function testWithTotal(): void
10511051

10521052
$meta = [
10531053
'from' => $this->encodeCursor([
1054-
"id" => (string) $posts[3]->getKey(),
1054+
"id" => (string) $posts[3]->getRouteKey(),
10551055
], pointsToNextItems: false),
10561056
'hasMore' => true,
10571057
'perPage' => 3,
10581058
'to' => $this->encodeCursor([
1059-
"id" => (string) $posts[1]->getKey(),
1059+
"id" => (string) $posts[1]->getRouteKey(),
10601060
], pointsToNextItems: true),
10611061
'total' => 4,
10621062
];
@@ -1074,7 +1074,7 @@ public function testWithTotal(): void
10741074
->queryAll()
10751075
->paginate([
10761076
'after' => $this->encodeCursor([
1077-
"id" => (string) $posts[1]->getKey(),
1077+
"id" => (string) $posts[1]->getRouteKey(),
10781078
], pointsToNextItems: true),
10791079
'limit' => 3,
10801080
]);
@@ -1097,12 +1097,12 @@ public function testWithTotalOnFirstPage(): void
10971097

10981098
$meta = [
10991099
'from' => $this->encodeCursor([
1100-
"id" => (string) $posts[3]->getKey(),
1100+
"id" => (string) $posts[3]->getRouteKey(),
11011101
], pointsToNextItems: false),
11021102
'hasMore' => true,
11031103
'perPage' => 3,
11041104
'to' => $this->encodeCursor([
1105-
"id" => (string) $posts[1]->getKey(),
1105+
"id" => (string) $posts[1]->getRouteKey(),
11061106
], pointsToNextItems: true),
11071107
'total' => 4,
11081108
];
@@ -1120,7 +1120,7 @@ public function testWithTotalOnFirstPage(): void
11201120
->queryAll()
11211121
->paginate([
11221122
'after' => $this->encodeCursor([
1123-
"id" => (string) $posts[1]->getKey(),
1123+
"id" => (string) $posts[1]->getRouteKey(),
11241124
], pointsToNextItems: true),
11251125
'limit' => 3,
11261126
]);

0 commit comments

Comments
 (0)