@@ -107,20 +107,30 @@ public function assertFetchedPage(
107
107
bool $ strict = true
108
108
): self
109
109
{
110
- if (empty ($ links ) && empty ($ meta )) {
111
- throw new \InvalidArgumentException ('Expecting links or meta to ensure response is a page. ' );
112
- }
113
-
114
- $ this ->assertFetchedMany ($ expected , $ strict );
110
+ $ this ->assertPage ($ expected , $ links , $ meta , $ metaKey , $ strict );
115
111
116
- if ($ links ) {
117
- $ this ->assertLinks ($ links , $ strict );
118
- }
112
+ return $ this ;
113
+ }
119
114
120
- if ($ meta ) {
121
- $ meta = $ metaKey ? [$ metaKey => $ meta ] : $ meta ;
122
- $ this ->assertMeta ($ meta , $ strict );
123
- }
115
+ /**
116
+ * Assert the response is a JSON API page with expected resources in the specified order.
117
+ *
118
+ * @param $expected
119
+ * @param array|null $links
120
+ * @param array|null $meta
121
+ * @param string|null $metaKey
122
+ * @param bool $strict
123
+ * @return TestResponse
124
+ */
125
+ public function assertFetchedPageInOrder (
126
+ $ expected ,
127
+ ?array $ links ,
128
+ ?array $ meta ,
129
+ string $ metaKey = 'page ' ,
130
+ bool $ strict = true
131
+ ): self
132
+ {
133
+ $ this ->assertPage ($ expected , $ links , $ meta , $ metaKey , $ strict , true );
124
134
125
135
return $ this ;
126
136
}
@@ -449,4 +459,43 @@ protected function normalizeId($id)
449
459
return (string ) $ id ;
450
460
}
451
461
462
+ /**
463
+ * Assert the response is a JSON API page.
464
+ *
465
+ * @param $expected
466
+ * @param array|null $links
467
+ * @param array|null $meta
468
+ * @param string|null $metaKey
469
+ * @param bool $strict
470
+ * @param bool $order
471
+ * @return void
472
+ */
473
+ private function assertPage (
474
+ $ expected ,
475
+ ?array $ links ,
476
+ ?array $ meta ,
477
+ string $ metaKey = 'page ' ,
478
+ bool $ strict = true ,
479
+ bool $ order = false
480
+ ): void
481
+ {
482
+ if (empty ($ links ) && empty ($ meta )) {
483
+ throw new \InvalidArgumentException ('Expecting links or meta to ensure response is a page. ' );
484
+ }
485
+
486
+ if ($ order ) {
487
+ $ this ->assertFetchedManyInOrder ($ expected , $ strict );
488
+ } else {
489
+ $ this ->assertFetchedMany ($ expected , $ strict );
490
+ }
491
+
492
+ if ($ links ) {
493
+ $ this ->assertLinks ($ links , $ strict );
494
+ }
495
+
496
+ if ($ meta ) {
497
+ $ meta = $ metaKey ? [$ metaKey => $ meta ] : $ meta ;
498
+ $ this ->assertMeta ($ meta , $ strict );
499
+ }
500
+ }
452
501
}
0 commit comments