1+ <?php
2+ /**
3+ * @since Mar 2023
4+ * @author Haydar KULEKCI <haydarkulekci@gmail.com>
5+ */
6+ namespace Qdrant \Tests \Unit \Models \Request ;
7+
8+ use PHPUnit \Framework \TestCase ;
9+ use Qdrant \Models \Request \CollectionConfig \BinaryQuantization ;
10+ use Qdrant \Models \Request \CollectionConfig \CollectionParams ;
11+ use Qdrant \Models \Request \CollectionConfig \HnswConfig ;
12+ use Qdrant \Models \Request \CollectionConfig \OptimizersConfig ;
13+ use Qdrant \Models \Request \CollectionConfig \WalConfig ;
14+ use Qdrant \Models \Request \CreateCollection ;
15+ use Qdrant \Models \Request \UpdateCollection ;
16+ use Qdrant \Models \Request \VectorParams ;
17+
18+ class UpdateCollectionTest extends TestCase
19+ {
20+ public function testUpdateCollectionWithVector (): void
21+ {
22+ $ collection = new UpdateCollection ();
23+ $ this ->assertEquals ([], $ collection ->toArray ());
24+ }
25+
26+ public function testUpdateCollectionWithOptimizersConfig (): void
27+ {
28+ $ collection = new UpdateCollection ();
29+ $ collection ->setOptimizersConfig (
30+ (new OptimizersConfig ())->setVacuumMinVectorNumber (1 )
31+ ->setDeletedThreshold (1.0 )
32+ );
33+
34+ $ this ->assertEquals (
35+ [
36+ 'optimizers_config ' => [
37+ 'deleted_threshold ' => 1.0 ,
38+ 'vacuum_min_vector_number ' => 1
39+ ]
40+ ],
41+ $ collection ->toArray ()
42+ );
43+ }
44+
45+ public function testUpdateCollectionWithHnswConfig (): void
46+ {
47+ $ collection = new UpdateCollection ();
48+ $ collection ->setHnswConfig ((new HnswConfig ())->setM (1 )->setEfConstruct (5 ));
49+
50+ $ this ->assertEquals (
51+ [
52+ 'hnsw_config ' => [
53+ 'm ' => 1 ,
54+ 'ef_construct ' => 5
55+ ],
56+ ],
57+ $ collection ->toArray ()
58+ );
59+ }
60+
61+ public function testUpdateCollectionWithQuantizationConfig (): void
62+ {
63+ $ collection = new UpdateCollection ();
64+ $ collection ->setQuantizationConfig (
65+ (new BinaryQuantization (true ))
66+ );
67+
68+ $ this ->assertEquals (
69+ [
70+ 'quantization_config ' => [
71+ 'binary ' => [
72+ 'always_ram ' => true
73+ ],
74+ ],
75+ ],
76+ $ collection ->toArray ()
77+ );
78+ }
79+
80+ public function testUpdateCollectionWithCollectionParams (): void
81+ {
82+ $ collection = new UpdateCollection ();
83+ $ collection ->setCollectionParams (
84+ (new CollectionParams ())->setReplicationFactor (1 )
85+ );
86+
87+ $ this ->assertEquals (
88+ [
89+ 'params ' => [
90+ 'replication_factor ' => 1
91+ ],
92+ ],
93+ $ collection ->toArray ()
94+ );
95+ }
96+ }
0 commit comments