1+ <?php
2+ /**
3+ * @since Jun 2024
4+ * @author Haydar KULEKCI <haydarkulekci@gmail.com>
5+ */
6+
7+ namespace Integration \Endpoints \Collections ;
8+
9+ use Qdrant \Endpoints \Collections ;
10+ use Qdrant \Exception \InvalidArgumentException ;
11+ use Qdrant \Models \Request \CollectionConfig \CreateShardKey ;
12+ use Qdrant \Models \Request \CollectionConfig \DeleteShardKey ;
13+ use Qdrant \Models \Request \CreateIndex ;
14+ use Qdrant \Tests \Integration \AbstractIntegration ;
15+
16+ class ShardsTest extends AbstractIntegration
17+ {
18+ /**
19+ * @throws InvalidArgumentException
20+ */
21+ public function testCollectionCreateShards (): void
22+ {
23+ //TODO: We need to find a way to enable distributed mode in tests?
24+ $ this ->expectException (InvalidArgumentException::class);
25+ $ this ->expectExceptionMessage ('Bad request: Distributed mode disabled ' );
26+
27+ $ collection = new Collections ($ this ->client );
28+ $ this ->createCollections ('sample-collection ' );
29+ $ collection ->setCollectionName ('sample-collection ' );
30+
31+ $ shards = $ collection ->shards ();
32+ $ this ->assertEquals ('sample-collection ' , $ shards ->getCollectionName ());
33+
34+ $ shards ->create (new CreateShardKey (1 ));
35+ }
36+
37+ /**
38+ * @throws InvalidArgumentException
39+ */
40+ public function testCollectionDeleteShards (): void
41+ {
42+ //TODO: We need to find a way to enable distributed mode in tests?
43+ $ this ->expectException (InvalidArgumentException::class);
44+ $ this ->expectExceptionMessage ('Bad request: Distributed mode disabled ' );
45+
46+ $ collection = new Collections ($ this ->client );
47+ $ this ->createCollections ('sample-collection ' );
48+ $ collection ->setCollectionName ('sample-collection ' );
49+
50+ $ shards = $ collection ->shards ();
51+ $ this ->assertEquals ('sample-collection ' , $ shards ->getCollectionName ());
52+
53+ $ shards ->delete (new DeleteShardKey (1 ));
54+ }
55+
56+ protected function tearDown (): void
57+ {
58+ parent ::tearDown ();
59+
60+ $ this ->getCollections ('sample-collection ' )->delete ();
61+ }
62+ }
0 commit comments