@@ -248,6 +248,43 @@ public function testCase2_CanFindEncryptedRangeAndReturnTheMaximum(string $type,
248
248
$ this ->assertMultipleDocumentsMatch ($ expectedDocuments , $ cursor );
249
249
}
250
250
251
+ /**
252
+ * @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst#case-3-can-find-encrypted-range-and-return-the-minimum
253
+ * @dataProvider provideTypeAndRangeOpts
254
+ */
255
+ public function testCase3_CanFindEncryptedRangeAndReturnTheMinimum (string $ type , array $ rangeOpts ): void
256
+ {
257
+ $ this ->setUpWithTypeAndRangeOpts ($ type , $ rangeOpts );
258
+
259
+ $ encryptOpts = [
260
+ 'keyId ' => $ this ->key1Id ,
261
+ 'algorithm ' => ClientEncryption::ALGORITHM_RANGE_PREVIEW ,
262
+ 'queryType ' => ClientEncryption::QUERY_TYPE_RANGE_PREVIEW ,
263
+ 'contentionFactor ' => 0 ,
264
+ 'rangeOpts ' => $ rangeOpts ,
265
+ ];
266
+
267
+ $ cast = self ::getCastCallableForType ($ type );
268
+ $ fieldName = 'encrypted ' . $ type ;
269
+
270
+ $ expr = [
271
+ '$and ' => [
272
+ [$ fieldName => ['$gte ' => $ cast (0 )]],
273
+ [$ fieldName => ['$lte ' => $ cast (6 )]],
274
+ ],
275
+ ];
276
+
277
+ $ encryptedExpr = $ this ->clientEncryption ->encryptExpression ($ expr , $ encryptOpts );
278
+ $ cursor = $ this ->collection ->find ($ encryptedExpr , ['sort ' => ['_id ' => 1 ]]);
279
+
280
+ $ expectedDocuments = [
281
+ ['_id ' => 0 , $ fieldName => $ cast (0 )],
282
+ ['_id ' => 1 , $ fieldName => $ cast (6 )],
283
+ ];
284
+
285
+ $ this ->assertMultipleDocumentsMatch ($ expectedDocuments , $ cursor );
286
+ }
287
+
251
288
private function assertMultipleDocumentsMatch (array $ expectedDocuments , Iterator $ actualDocuments ): void
252
289
{
253
290
$ mi = new MultipleIterator (MultipleIterator::MIT_NEED_ANY );
0 commit comments