1919use Symfony \AI \Store \Document \Metadata ;
2020use Symfony \AI \Store \Document \VectorDocument ;
2121use Symfony \AI \Store \Exception \InvalidArgumentException ;
22+ use Symfony \AI \Store \Exception \UnsupportedQueryTypeException ;
2223use Symfony \AI \Store \Query \HybridQuery ;
24+ use Symfony \AI \Store \Query \QueryInterface ;
2325use Symfony \AI \Store \Query \TextQuery ;
2426use Symfony \AI \Store \Query \VectorQuery ;
2527use Symfony \Component \Cache \Adapter \ArrayAdapter ;
@@ -178,7 +180,7 @@ public function testStoreCanSearchWithFilter()
178180 ]);
179181
180182 $ result = iterator_to_array ($ store ->query (new VectorQuery (new Vector ([0.0 , 0.1 , 0.6 ])), [
181- 'filter ' => static fn (VectorDocument $ doc ) => 'products ' === $ doc ->getMetadata ()['category ' ],
183+ 'filter ' => static fn (VectorDocument $ doc ): bool => 'products ' === $ doc ->getMetadata ()['category ' ],
182184 ]));
183185
184186 $ this ->assertCount (2 , $ result );
@@ -197,7 +199,7 @@ public function testStoreCanSearchWithFilterAndMaxItems()
197199 ]);
198200
199201 $ result = iterator_to_array ($ store ->query (new VectorQuery (new Vector ([0.0 , 0.1 , 0.6 ])), [
200- 'filter ' => static fn (VectorDocument $ doc ) => 'products ' === $ doc ->getMetadata ()['category ' ],
202+ 'filter ' => static fn (VectorDocument $ doc ): bool => 'products ' === $ doc ->getMetadata ()['category ' ],
201203 'maxItems ' => 2 ,
202204 ]));
203205
@@ -216,7 +218,7 @@ public function testStoreCanSearchWithComplexFilter()
216218 ]);
217219
218220 $ result = iterator_to_array ($ store ->query (new VectorQuery (new Vector ([0.0 , 0.1 , 0.6 ])), [
219- 'filter ' => static fn (VectorDocument $ doc ) => $ doc ->getMetadata ()['price ' ] <= 150 && $ doc ->getMetadata ()['stock ' ] > 0 ,
221+ 'filter ' => static fn (VectorDocument $ doc ): bool => $ doc ->getMetadata ()['price ' ] <= 150 && $ doc ->getMetadata ()['stock ' ] > 0 ,
220222 ]));
221223
222224 $ this ->assertCount (2 , $ result );
@@ -232,7 +234,7 @@ public function testStoreCanSearchWithNestedMetadataFilter()
232234 ]);
233235
234236 $ result = iterator_to_array ($ store ->query (new VectorQuery (new Vector ([0.0 , 0.1 , 0.6 ])), [
235- 'filter ' => static fn (VectorDocument $ doc ) => 'S ' === $ doc ->getMetadata ()['options ' ]['size ' ],
237+ 'filter ' => static fn (VectorDocument $ doc ): bool => 'S ' === $ doc ->getMetadata ()['options ' ]['size ' ],
236238 ]));
237239
238240 $ this ->assertCount (2 , $ result );
@@ -251,7 +253,7 @@ public function testStoreCanSearchWithInArrayFilter()
251253
252254 $ allowedBrands = ['Nike ' , 'Adidas ' , 'Puma ' ];
253255 $ result = iterator_to_array ($ store ->query (new VectorQuery (new Vector ([0.0 , 0.1 , 0.6 ])), [
254- 'filter ' => static fn (VectorDocument $ doc ) => \in_array ($ doc ->getMetadata ()['brand ' ] ?? '' , $ allowedBrands , true ),
256+ 'filter ' => static fn (VectorDocument $ doc ): bool => \in_array ($ doc ->getMetadata ()['brand ' ] ?? '' , $ allowedBrands , true ),
255257 ]));
256258
257259 $ this ->assertCount (2 , $ result );
@@ -394,6 +396,7 @@ public function testStoreCanSearchUsingTextQuery()
394396 $ result = iterator_to_array ($ store ->query (new TextQuery ('quick brown ' )));
395397
396398 $ this ->assertCount (1 , $ result );
399+ $ this ->assertNotNull ($ result [0 ]->getMetadata ()->getText ());
397400 $ this ->assertStringContainsString ('quick brown ' , $ result [0 ]->getMetadata ()->getText ());
398401 }
399402
@@ -458,7 +461,7 @@ public function testHybridQueryThrowsExceptionForInvalidSemanticRatio()
458461 {
459462 $ this ->expectException (InvalidArgumentException::class);
460463 $ this ->expectExceptionMessage ('Semantic ratio must be between 0.0 and 1.0 ' );
461-
464+ $ this -> expectExceptionCode ( 0 );
462465 new HybridQuery (new Vector ([0.1 , 0.2 , 0.3 ]), 'test ' , 1.5 );
463466 }
464467
@@ -467,12 +470,12 @@ public function testStoreThrowsExceptionForUnsupportedQueryType()
467470 $ store = new Store (new ArrayAdapter ());
468471
469472 // Create a mock query type that Cache store doesn't support
470- $ unsupportedQuery = new class implements \ Symfony \ AI \ Store \ Query \ QueryInterface {
473+ $ unsupportedQuery = new class implements QueryInterface {
471474 };
472475
473- $ this ->expectException (\ Symfony \ AI \ Store \ Exception \ UnsupportedQueryTypeException::class);
476+ $ this ->expectException (UnsupportedQueryTypeException::class);
474477 $ this ->expectExceptionMessageMatches ('/not supported/ ' );
475-
478+ $ this -> expectExceptionCode ( 0 );
476479 $ store ->query ($ unsupportedQuery );
477480 }
478481
0 commit comments