77namespace Qdrant \Tests \Unit \Models \Request \CollectionConfig ;
88
99use PHPUnit \Framework \TestCase ;
10+ use Qdrant \Exception \InvalidArgumentException ;
1011use Qdrant \Models \Request \CollectionConfig \HnswConfig ;
1112
1213class HnswConfigTest extends TestCase
@@ -27,6 +28,15 @@ public function testWithM(): void
2728 ], $ config ->toArray ());
2829 }
2930
31+ public function testWithInvalidM (): void
32+ {
33+ $ this ->expectException (InvalidArgumentException::class);
34+ $ this ->expectExceptionMessage ('m should be bigger than 0 ' );
35+ $ config = (new HnswConfig ())->setM (-1 );
36+
37+ $ this ->assertEquals ([], $ config ->toArray ());
38+ }
39+
3040 public function testWithEfConstruct (): void
3141 {
3242 $ config = (new HnswConfig ())->setEfConstruct (10 );
@@ -36,6 +46,15 @@ public function testWithEfConstruct(): void
3646 ], $ config ->toArray ());
3747 }
3848
49+ public function testWithInvalidEfConstruct (): void
50+ {
51+ $ this ->expectException (InvalidArgumentException::class);
52+ $ this ->expectExceptionMessage ('ef_construct should be bigger than 4 ' );
53+ $ config = (new HnswConfig ())->setEfConstruct (-1 );
54+
55+ $ this ->assertEquals ([], $ config ->toArray ());
56+ }
57+
3958 public function testWithFullScanThreshold (): void
4059 {
4160 $ config = (new HnswConfig ())->setFullScanThreshold (10 );
@@ -45,7 +64,16 @@ public function testWithFullScanThreshold(): void
4564 ], $ config ->toArray ());
4665 }
4766
48- public function testWithDeletedThreshold (): void
67+ public function testWithInvalidFullScanThreshold (): void
68+ {
69+ $ this ->expectException (InvalidArgumentException::class);
70+ $ this ->expectExceptionMessage ('full_scan_threshold should be bigger than 10 ' );
71+ $ config = (new HnswConfig ())->setFullScanThreshold (1 );
72+
73+ $ this ->assertEquals ([], $ config ->toArray ());
74+ }
75+
76+ public function testWithMaxIndexingThreads (): void
4977 {
5078 $ config = (new HnswConfig ())->setMaxIndexingThreads (9 );
5179
@@ -54,6 +82,15 @@ public function testWithDeletedThreshold(): void
5482 ], $ config ->toArray ());
5583 }
5684
85+ public function testWithInvalidMaxIndexingThreads (): void
86+ {
87+ $ this ->expectException (InvalidArgumentException::class);
88+ $ this ->expectExceptionMessage ('max_indexing_threads should be bigger than 0 ' );
89+ $ config = (new HnswConfig ())->setMaxIndexingThreads (-1 );
90+
91+ $ this ->assertEquals ([], $ config ->toArray ());
92+ }
93+
5794 public function testWithOnDisk (): void
5895 {
5996 $ config = (new HnswConfig ())->setOnDisk (true );
@@ -63,7 +100,7 @@ public function testWithOnDisk(): void
63100 ], $ config ->toArray ());
64101 }
65102
66- public function testWithDefaultSegmentNumber (): void
103+ public function testWithPayloadM (): void
67104 {
68105 $ config = (new HnswConfig ())->setPayloadM (10 );
69106
@@ -72,7 +109,16 @@ public function testWithDefaultSegmentNumber(): void
72109 ], $ config ->toArray ());
73110 }
74111
75- public function testWithFlushIntervalSec (): void
112+ public function testWithInvalidPayloadM (): void
113+ {
114+ $ this ->expectException (InvalidArgumentException::class);
115+ $ this ->expectExceptionMessage ('payload_m should be bigger than 0 ' );
116+ $ config = (new HnswConfig ())->setPayloadM (-1 );
117+
118+ $ this ->assertEquals ([], $ config ->toArray ());
119+ }
120+
121+ public function testWithMultipleParameters (): void
76122 {
77123 $ config = (new HnswConfig ())->setMaxIndexingThreads (10 )->setPayloadM (10 );
78124
0 commit comments