File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
tests/Integration/Endpoints Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,19 @@ public function info(): Response
6464 );
6565 }
6666
67+ /**
68+ * # Collection exists
69+ * Checks whether the specified collection exists.
70+ *
71+ * @throws InvalidArgumentException
72+ */
73+ public function exists (): Response
74+ {
75+ return $ this ->client ->execute (
76+ $ this ->createRequest ('GET ' , '/collections/ ' . $ this ->getCollectionName (). '/exists ' )
77+ );
78+ }
79+
6780 /**
6881 * # Delete collection
6982 * Drop collection and all associated data
@@ -121,4 +134,4 @@ public function cluster(): Cluster
121134 {
122135 return (new Cluster ($ this ->client ))->setCollectionName ($ this ->collectionName );
123136 }
124- }
137+ }
Original file line number Diff line number Diff line change @@ -54,6 +54,24 @@ public function testCollections(): void
5454 $ this ->assertEquals ('ok ' , $ response ['status ' ]);
5555 }
5656
57+ /**
58+ * @throws InvalidArgumentException
59+ */
60+ public function testCollectionExits (): void
61+ {
62+ $ collections = new Collections ($ this ->client );
63+ $ collections ->setCollectionName ('sample-collection ' );
64+
65+ $ response = $ collections ->create (self ::sampleCollectionOption ());
66+ $ this ->assertEquals ('ok ' , $ response ['status ' ]);
67+
68+ $ response = $ collections ->exists ();
69+ $ this ->assertEquals (true , $ response ['result ' ]['exists ' ]);
70+
71+ $ response = $ collections ->setCollectionName ('sample-collection-that-not-exists ' )->exists ();
72+ $ this ->assertEquals (false , $ response ['result ' ]['exists ' ]);
73+ }
74+
5775 public function testCollectionsCluster (): void
5876 {
5977 $ collections = new Collections ($ this ->client );
@@ -185,4 +203,4 @@ protected function tearDown(): void
185203 $ collections ->setCollectionName ('sample-collection ' )->delete ();
186204 $ collections ->setCollectionName ('other-collection ' )->delete ();
187205 }
188- }
206+ }
You can’t perform that action at this time.
0 commit comments