66namespace Qdrant \Tests \Unit \Models \Request ;
77
88use PHPUnit \Framework \TestCase ;
9+ use Qdrant \Models \Request \CollectionConfig \HnswConfig ;
10+ use Qdrant \Models \Request \CollectionConfig \OptimizersConfigDiff ;
11+ use Qdrant \Models \Request \CollectionConfig \WalConfig ;
912use Qdrant \Models \Request \CreateCollection ;
1013use Qdrant \Models \Request \VectorParams ;
1114
@@ -16,7 +19,6 @@ public function testCreateCollectionWithVector(): void
1619 $ collection = new CreateCollection ();
1720 $ collection ->addVector (new VectorParams (1024 , VectorParams::DISTANCE_COSINE ), 'image ' );
1821
19-
2022 $ this ->assertEquals (
2123 [
2224 'vectors ' => [
@@ -140,4 +142,79 @@ public function testCreateCollectionWithOnDiskPayload(): void
140142 $ collection ->toArray ()
141143 );
142144 }
145+
146+ public function testCreateCollectionWithOptimizersConfigDiff (): void
147+ {
148+ $ collection = new CreateCollection ();
149+ $ collection ->addVector (new VectorParams (1024 , VectorParams::DISTANCE_COSINE ));
150+ $ diff = (new OptimizersConfigDiff ())
151+ ->setMaxSegmentSize (1 )
152+ ->setDefaultSegmentNumber (1 );
153+
154+ $ collection ->setOptimizersConfigDiff ($ diff );
155+
156+ $ this ->assertEquals (
157+ [
158+ 'vectors ' => [
159+ 'size ' => '1024 ' ,
160+ 'distance ' => 'Cosine '
161+ ],
162+ 'optimizers_config ' => [
163+ 'max_segment_size ' => 1 ,
164+ 'default_segment_number ' => 1 ,
165+ ]
166+ ],
167+ $ collection ->toArray ()
168+ );
169+ }
170+
171+ public function testCreateCollectionWithHnswConfig (): void
172+ {
173+ $ collection = new CreateCollection ();
174+ $ collection ->addVector (new VectorParams (1024 , VectorParams::DISTANCE_COSINE ));
175+ $ diff = (new HnswConfig ())
176+ ->setM (1 )
177+ ->setPayloadM (1 );
178+
179+ $ collection ->setHnswConfig ($ diff );
180+
181+ $ this ->assertEquals (
182+ [
183+ 'vectors ' => [
184+ 'size ' => '1024 ' ,
185+ 'distance ' => 'Cosine '
186+ ],
187+ 'hnsw_config ' => [
188+ 'm ' => 1 ,
189+ 'payload_m ' => 1 ,
190+ ]
191+ ],
192+ $ collection ->toArray ()
193+ );
194+ }
195+
196+ public function testCreateCollectionWithWalConfig (): void
197+ {
198+ $ collection = new CreateCollection ();
199+ $ collection ->addVector (new VectorParams (1024 , VectorParams::DISTANCE_COSINE ));
200+ $ diff = (new WalConfig ())
201+ ->setWalSegmentsAhead (1 )
202+ ->setWalCapacityMb (1 );
203+
204+ $ collection ->setWalConfig ($ diff );
205+
206+ $ this ->assertEquals (
207+ [
208+ 'vectors ' => [
209+ 'size ' => '1024 ' ,
210+ 'distance ' => 'Cosine '
211+ ],
212+ 'wal_config ' => [
213+ 'wal_segments_ahead ' => 1 ,
214+ 'wal_capacity_mb ' => 1 ,
215+ ]
216+ ],
217+ $ collection ->toArray ()
218+ );
219+ }
143220}
0 commit comments