55namespace Tests \Endpoints ;
66
77use MeiliSearch \Client ;
8+ use MeiliSearch \Contracts \IndexesQuery ;
89use MeiliSearch \Endpoints \Indexes ;
910use MeiliSearch \Exceptions \ApiException ;
1011use Tests \TestCase ;
@@ -15,7 +16,7 @@ public function testClientIndexMethodsAlwaysReturnArray(): void
1516 {
1617 $ index = $ this ->createEmptyIndex ('index ' );
1718 /* @phpstan-ignore-next-line */
18- $ this ->assertIsArray ($ this ->client ->getAllIndexes ());
19+ $ this ->assertIsIterable ($ this ->client ->getAllIndexes ());
1920 /* @phpstan-ignore-next-line */
2021 $ this ->assertIsArray ($ this ->client ->getAllRawIndexes ()['results ' ]);
2122 /* @phpstan-ignore-next-line */
@@ -38,6 +39,13 @@ public function testGetAllIndexesWhenEmpty(): void
3839 $ this ->assertEmpty ($ response );
3940 }
4041
42+ public function testGetAllIndexesWithPagination (): void
43+ {
44+ $ response = $ this ->client ->getAllIndexes ((new IndexesQuery ())->setLimit (1 )->setOffset (99999 ));
45+
46+ $ this ->assertEmpty ($ response );
47+ }
48+
4149 public function testGetAllRawIndexesWhenEmpty (): void
4250 {
4351 $ response = $ this ->client ->getAllRawIndexes ()['results ' ];
@@ -90,27 +98,24 @@ public function testGetAllIndexes(): void
9098 {
9199 $ indexA = 'indexA ' ;
92100 $ indexB = 'indexB ' ;
93- $ this ->createEmptyIndex ($ indexA );
94- $ this ->createEmptyIndex ($ indexB );
95-
96- $ response = $ this ->client ->getAllIndexes ();
97-
98- $ this ->assertCount (2 , $ response );
101+ $ response = $ this ->client ->createIndex ($ indexA );
102+ $ this ->client ->waitForTask ($ response ['taskUid ' ]);
103+ $ response = $ this ->client ->createIndex ($ indexB );
104+ $ this ->client ->waitForTask ($ response ['taskUid ' ]);
99105
100- $ taskUids = array_map (function ($ index ): ?string {
101- return $ index ->getUid ();
102- }, $ response );
106+ $ indexes = $ this ->client ->getAllIndexes ();
103107
104- $ this ->assertContains ($ indexA , $ taskUids );
105- $ this ->assertContains ($ indexB , $ taskUids );
108+ $ this ->assertCount (2 , $ indexes );
106109 }
107110
108111 public function testGetAllRawIndexes (): void
109112 {
110113 $ indexA = 'indexA ' ;
111114 $ indexB = 'indexB ' ;
112- $ this ->createEmptyIndex ($ indexA );
113- $ this ->createEmptyIndex ($ indexB );
115+ $ response = $ this ->client ->createIndex ($ indexA );
116+ $ this ->client ->waitForTask ($ response ['taskUid ' ]);
117+ $ response = $ this ->client ->createIndex ($ indexB );
118+ $ this ->client ->waitForTask ($ response ['taskUid ' ]);
114119
115120 $ res = $ this ->client ->getAllRawIndexes ()['results ' ];
116121
0 commit comments