|
4 | 4 |
|
5 | 5 | use Closure;
|
6 | 6 | use MongoDB\BSON\Binary;
|
| 7 | +use MongoDB\BSON\Document; |
7 | 8 | use MongoDB\BSON\Int64;
|
8 | 9 | use MongoDB\Client;
|
9 | 10 | use MongoDB\Collection;
|
@@ -116,36 +117,6 @@ class ClientSideEncryptionSpecTest extends FunctionalTestCase
|
116 | 117 | 'fle2v2-Range-DecimalPrecision-InsertFind: FLE2 Range DecimalPrecision. Insert and Find.' => 'Bundled libmongocrypt does not support Decimal128 (PHPC-2207)',
|
117 | 118 | 'fle2v2-Range-DecimalPrecision-Update: FLE2 Range DecimalPrecision. Update.' => 'Bundled libmongocrypt does not support Decimal128 (PHPC-2207)',
|
118 | 119 | 'fle2v2-Range-Decimal-Update: FLE2 Range Decimal. Update.' => 'Bundled libmongocrypt does not support Decimal128 (PHPC-2207)',
|
119 |
| - 'fle2v2-Range-Long-Aggregate: FLE2 Range Long. Aggregate.' => 'PHP encodes integers as 32-bit if range allows', |
120 |
| - 'fle2v2-Range-Long-Correctness: Find with $gt' => 'PHP encodes integers as 32-bit if range allows', |
121 |
| - 'fle2v2-Range-Long-Correctness: Find with $gte' => 'PHP encodes integers as 32-bit if range allows', |
122 |
| - 'fle2v2-Range-Long-Correctness: Find with $gt with no results' => 'PHP encodes integers as 32-bit if range allows', |
123 |
| - 'fle2v2-Range-Long-Correctness: Find with $lt' => 'PHP encodes integers as 32-bit if range allows', |
124 |
| - 'fle2v2-Range-Long-Correctness: Find with $lte' => 'PHP encodes integers as 32-bit if range allows', |
125 |
| - 'fle2v2-Range-Long-Correctness: Find with $lt below min' => 'PHP encodes integers as 32-bit if range allows', |
126 |
| - 'fle2v2-Range-Long-Correctness: Find with $gt above max' => 'PHP encodes integers as 32-bit if range allows', |
127 |
| - 'fle2v2-Range-Long-Correctness: Find with $gt and $lt' => 'PHP encodes integers as 32-bit if range allows', |
128 |
| - 'fle2v2-Range-Long-Correctness: Find with equality' => 'PHP encodes integers as 32-bit if range allows', |
129 |
| - 'fle2v2-Range-Long-Correctness: Find with full range' => 'PHP encodes integers as 32-bit if range allows', |
130 |
| - 'fle2v2-Range-Long-Correctness: Find with $in' => 'PHP encodes integers as 32-bit if range allows', |
131 |
| - 'fle2v2-Range-Long-Correctness: Insert out of range' => 'PHP encodes integers as 32-bit if range allows', |
132 |
| - 'fle2v2-Range-Long-Correctness: Insert min and max' => 'PHP encodes integers as 32-bit if range allows', |
133 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with $gte' => 'PHP encodes integers as 32-bit if range allows', |
134 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with $gt with no results' => 'PHP encodes integers as 32-bit if range allows', |
135 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with $lt' => 'PHP encodes integers as 32-bit if range allows', |
136 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with $lte' => 'PHP encodes integers as 32-bit if range allows', |
137 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with $lt below min' => 'PHP encodes integers as 32-bit if range allows', |
138 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with $gt above max' => 'PHP encodes integers as 32-bit if range allows', |
139 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with $gt and $lt' => 'PHP encodes integers as 32-bit if range allows', |
140 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with equality' => 'PHP encodes integers as 32-bit if range allows', |
141 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with full range' => 'PHP encodes integers as 32-bit if range allows', |
142 |
| - 'fle2v2-Range-Long-Correctness: Aggregate with $in' => 'PHP encodes integers as 32-bit if range allows', |
143 |
| - 'fle2v2-Range-Long-Correctness: Wrong type: Insert Double' => 'PHP encodes integers as 32-bit if range allows', |
144 |
| - 'fle2v2-Range-Long-Correctness: Wrong type: Find Double' => 'PHP encodes integers as 32-bit if range allows', |
145 |
| - 'fle2v2-Range-Long-Delete: FLE2 Range Long. Delete.' => 'PHP encodes integers as 32-bit if range allows', |
146 |
| - 'fle2v2-Range-Long-FindOneAndUpdate: FLE2 Range Long. FindOneAndUpdate.' => 'PHP encodes integers as 32-bit if range allows', |
147 |
| - 'fle2v2-Range-Long-InsertFind: FLE2 Range Long. Insert and Find.' => 'PHP encodes integers as 32-bit if range allows', |
148 |
| - 'fle2v2-Range-Long-Update: FLE2 Range Long. Update.' => 'PHP encodes integers as 32-bit if range allows', |
149 | 120 | 'timeoutMS: timeoutMS applied to listCollections to get collection schema' => 'Not yet implemented (PHPC-1760)',
|
150 | 121 | 'timeoutMS: remaining timeoutMS applied to find to get keyvault data' => 'Not yet implemented (PHPC-1760)',
|
151 | 122 | ];
|
@@ -257,8 +228,21 @@ public function provideTests()
|
257 | 228 | foreach (glob(__DIR__ . '/client-side-encryption/tests/*.json') as $filename) {
|
258 | 229 | $group = basename($filename, '.json');
|
259 | 230 |
|
| 231 | + /* Some tests need to differentiate int32 and int64 BSON types. |
| 232 | + * Decode certain field paths as BSON to preserve type information |
| 233 | + * that would otherwise be lost by round-tripping through PHP. */ |
| 234 | + $typeMap = [ |
| 235 | + 'fieldPaths' => [ |
| 236 | + 'encrypted_fields.fields' => 'bson', |
| 237 | + 'tests.$.operations.$.arguments.document' => 'bson', |
| 238 | + 'tests.$.operations.$.arguments.pipeline.$' => 'bson', |
| 239 | + 'tests.$.operations.$.arguments.filter' => 'bson', |
| 240 | + 'tests.$.operations.$.arguments.update' => 'bson', |
| 241 | + ], |
| 242 | + ]; |
| 243 | + |
260 | 244 | try {
|
261 |
| - $json = $this->decodeJson(file_get_contents($filename)); |
| 245 | + $json = Document::fromJSON(file_get_contents($filename))->toPHP($typeMap); |
262 | 246 | } catch (Throwable $e) {
|
263 | 247 | $testArgs[$group] = [
|
264 | 248 | (object) ['skipReason' => sprintf('Exception loading file "%s": %s', $filename, $e->getMessage())],
|
|
0 commit comments