@@ -48,6 +48,35 @@ public function testGetBooks(): void
48
48
$ this ->assertArrayNotHasKey ('errors ' , $ data );
49
49
}
50
50
51
+ public function testGetBooksWithSimplePagination (): void
52
+ {
53
+ BookFactory::new ()->has (AuthorFactory::new ())->count (9 )->create ();
54
+ $ response = $ this ->postJson ('/api/graphql ' , ['query ' => '{
55
+ simplePaginationBooks(page: 1) {
56
+ collection {
57
+ id
58
+ },
59
+ paginationInfo {
60
+ itemsPerPage,
61
+ currentPage,
62
+ lastPage,
63
+ totalCount,
64
+ hasNextPage
65
+ }
66
+ }
67
+ } ' ], ['accept ' => ['application/json ' ]]);
68
+ $ response ->assertStatus (200 );
69
+ $ data = $ response ->json ();
70
+ $ this ->assertArrayHasKey ('data ' , $ data );
71
+ $ this ->assertCount (3 , $ data ['data ' ]['simplePaginationBooks ' ]['collection ' ]);
72
+ $ this ->assertEquals (3 , $ data ['data ' ]['simplePaginationBooks ' ]['paginationInfo ' ]['itemsPerPage ' ]);
73
+ $ this ->assertEquals (1 , $ data ['data ' ]['simplePaginationBooks ' ]['paginationInfo ' ]['currentPage ' ]);
74
+ $ this ->assertEquals (3 , $ data ['data ' ]['simplePaginationBooks ' ]['paginationInfo ' ]['lastPage ' ]);
75
+ $ this ->assertEquals (9 , $ data ['data ' ]['simplePaginationBooks ' ]['paginationInfo ' ]['totalCount ' ]);
76
+ $ this ->assertTrue ($ data ['data ' ]['simplePaginationBooks ' ]['paginationInfo ' ]['hasNextPage ' ]);
77
+ $ this ->assertArrayNotHasKey ('errors ' , $ data );
78
+ }
79
+
51
80
public function testGetBooksWithPaginationAndOrder (): void
52
81
{
53
82
BookFactory::new ()->has (AuthorFactory::new ())->count (10 )->create ();
0 commit comments