diff --git a/config.m4 b/config.m4 index 891c2fb41..419fcebe3 100644 --- a/config.m4 +++ b/config.m4 @@ -385,7 +385,7 @@ if test "$PHP_MONGODB" != "no"; then PHP_MONGODB_JSONSL_SOURCES="jsonsl.c" dnl Generated with: find src/libmongoc/src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 7- | sort -dz | tr '\000' ' ' - PHP_MONGODB_MONGOC_SOURCES="mongoc-aggregate.c mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-client-side-encryption.c mongoc-cluster-aws.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypt.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-change-stream.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-gridfs-bucket.c mongoc-gridfs-bucket-file.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-handshake.c mongoc-host-list.c mongoc-http.c mongoc-index.c mongoc-init.c mongoc-interrupt.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-ocsp-cache.c mongoc-openssl.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-api.c mongoc-server-description.c mongoc-server-monitor.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-gridfs-download.c mongoc-stream-gridfs-upload.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-timeout.c mongoc-topology-background-monitoring.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c" + PHP_MONGODB_MONGOC_SOURCES="mongoc-aggregate.c mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-client-side-encryption.c mongoc-cluster-aws.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypt.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-change-stream.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-gridfs-bucket.c mongoc-gridfs-bucket-file.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-handshake.c mongoc-host-list.c mongoc-http.c mongoc-index.c mongoc-init.c mongoc-interrupt.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-ocsp-cache.c mongoc-openssl.c mongoc-optional.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-api.c mongoc-server-description.c mongoc-server-monitor.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-gridfs-download.c mongoc-stream-gridfs-upload.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-timeout.c mongoc-topology-background-monitoring.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c" dnl Generated with: find src/libmongoc/src/zlib-1.2.11 -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' ' PHP_MONGODB_ZLIB_SOURCES="adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c" diff --git a/config.w32 b/config.w32 index e462c8b4f..0e24e8fef 100644 --- a/config.w32 +++ b/config.w32 @@ -115,7 +115,7 @@ if (PHP_MONGODB != "no") { var PHP_MONGODB_JSONSL_SOURCES="jsonsl.c"; // Generated with: find src/libmongoc/src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 7- | sort -dz | tr '\000' ' ' - var PHP_MONGODB_MONGOC_SOURCES="mongoc-aggregate.c mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-client-side-encryption.c mongoc-cluster-aws.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypt.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-change-stream.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-gridfs-bucket.c mongoc-gridfs-bucket-file.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-handshake.c mongoc-host-list.c mongoc-http.c mongoc-index.c mongoc-init.c mongoc-interrupt.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-ocsp-cache.c mongoc-openssl.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-api.c mongoc-server-description.c mongoc-server-monitor.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-gridfs-download.c mongoc-stream-gridfs-upload.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-timeout.c mongoc-topology-background-monitoring.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c"; + var PHP_MONGODB_MONGOC_SOURCES="mongoc-aggregate.c mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-change-stream.c mongoc-client.c mongoc-client-pool.c mongoc-client-session.c mongoc-client-side-encryption.c mongoc-cluster-aws.c mongoc-cluster.c mongoc-cluster-cyrus.c mongoc-cluster-sasl.c mongoc-cluster-sspi.c mongoc-cmd.c mongoc-collection.c mongoc-compression.c mongoc-counters.c mongoc-crypt.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-change-stream.c mongoc-cursor-cmd.c mongoc-cursor-cmd-deprecated.c mongoc-cursor-find.c mongoc-cursor-find-cmd.c mongoc-cursor-find-opquery.c mongoc-cursor-legacy.c mongoc-cyrus.c mongoc-database.c mongoc-error.c mongoc-find-and-modify.c mongoc-gridfs-bucket.c mongoc-gridfs-bucket-file.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-handshake.c mongoc-host-list.c mongoc-http.c mongoc-index.c mongoc-init.c mongoc-interrupt.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-ocsp-cache.c mongoc-openssl.c mongoc-optional.c mongoc-opts.c mongoc-opts-helpers.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-api.c mongoc-server-description.c mongoc-server-monitor.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-sspi.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-gridfs-download.c mongoc-stream-gridfs-upload.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-timeout.c mongoc-topology-background-monitoring.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-command-legacy.c mongoc-write-concern.c"; EXTENSION("mongodb", "php_phongo.c phongo_compat.c", null, PHP_MONGODB_CFLAGS); MONGODB_ADD_SOURCES("/src", "bson.c bson-encode.c"); diff --git a/scripts/convert-bson-corpus-tests.php b/scripts/convert-bson-corpus-tests.php index e68f3067e..ed7f5e4bc 100644 --- a/scripts/convert-bson-corpus-tests.php +++ b/scripts/convert-bson-corpus-tests.php @@ -238,6 +238,7 @@ function getParamsForParseError(array $test, array $case) switch ($test['bson_type']) { case '0x00': // Top-level document + case '0x05': // Binary $code = "throws(function() {\n"; $code .= sprintf(" fromJSON(%s);\n", var_export($case['string'], true)); $code .= "}, 'MongoDB\Driver\Exception\UnexpectedValueException');"; diff --git a/src/LIBMONGOC_VERSION_CURRENT b/src/LIBMONGOC_VERSION_CURRENT index 230181a3f..9712dfd18 100644 --- a/src/LIBMONGOC_VERSION_CURRENT +++ b/src/LIBMONGOC_VERSION_CURRENT @@ -1 +1 @@ -1.18.0-20210317+git7b143c65af +1.18.0-20210326+git203e6b9e26 diff --git a/src/libmongoc b/src/libmongoc index 7b143c65a..203e6b9e2 160000 --- a/src/libmongoc +++ b/src/libmongoc @@ -1 +1 @@ -Subproject commit 7b143c65af27658fcb6e1480cdebf8bba3d37fe6 +Subproject commit 203e6b9e26bfce6ca76f1d087470c3840318afdd diff --git a/tests/bson-corpus/binary-parseError-001.phpt b/tests/bson-corpus/binary-parseError-001.phpt new file mode 100644 index 000000000..c73b941d6 --- /dev/null +++ b/tests/bson-corpus/binary-parseError-001.phpt @@ -0,0 +1,21 @@ +--TEST-- +Binary type: $uuid wrong type +--DESCRIPTION-- +Generated by scripts/convert-bson-corpus-tests.php + +DO NOT EDIT THIS FILE +--FILE-- + +===DONE=== + +--EXPECT-- +OK: Got MongoDB\Driver\Exception\UnexpectedValueException +===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-parseError-002.phpt b/tests/bson-corpus/binary-parseError-002.phpt new file mode 100644 index 000000000..5d3c4e819 --- /dev/null +++ b/tests/bson-corpus/binary-parseError-002.phpt @@ -0,0 +1,21 @@ +--TEST-- +Binary type: $uuid invalid value--too short +--DESCRIPTION-- +Generated by scripts/convert-bson-corpus-tests.php + +DO NOT EDIT THIS FILE +--FILE-- + +===DONE=== + +--EXPECT-- +OK: Got MongoDB\Driver\Exception\UnexpectedValueException +===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-parseError-003.phpt b/tests/bson-corpus/binary-parseError-003.phpt new file mode 100644 index 000000000..56df69b03 --- /dev/null +++ b/tests/bson-corpus/binary-parseError-003.phpt @@ -0,0 +1,21 @@ +--TEST-- +Binary type: $uuid invalid value--too long +--DESCRIPTION-- +Generated by scripts/convert-bson-corpus-tests.php + +DO NOT EDIT THIS FILE +--FILE-- + +===DONE=== + +--EXPECT-- +OK: Got MongoDB\Driver\Exception\UnexpectedValueException +===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-parseError-004.phpt b/tests/bson-corpus/binary-parseError-004.phpt new file mode 100644 index 000000000..c087a5f24 --- /dev/null +++ b/tests/bson-corpus/binary-parseError-004.phpt @@ -0,0 +1,21 @@ +--TEST-- +Binary type: $uuid invalid value--misplaced hyphens +--DESCRIPTION-- +Generated by scripts/convert-bson-corpus-tests.php + +DO NOT EDIT THIS FILE +--FILE-- + +===DONE=== + +--EXPECT-- +OK: Got MongoDB\Driver\Exception\UnexpectedValueException +===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-parseError-005.phpt b/tests/bson-corpus/binary-parseError-005.phpt new file mode 100644 index 000000000..a9d1c7439 --- /dev/null +++ b/tests/bson-corpus/binary-parseError-005.phpt @@ -0,0 +1,21 @@ +--TEST-- +Binary type: $uuid invalid value--too many hyphens +--DESCRIPTION-- +Generated by scripts/convert-bson-corpus-tests.php + +DO NOT EDIT THIS FILE +--FILE-- + +===DONE=== + +--EXPECT-- +OK: Got MongoDB\Driver\Exception\UnexpectedValueException +===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-valid-008.phpt b/tests/bson-corpus/binary-valid-008.phpt index 5e660819d..60435d720 100644 --- a/tests/bson-corpus/binary-valid-008.phpt +++ b/tests/bson-corpus/binary-valid-008.phpt @@ -1,5 +1,5 @@ --TEST-- -Binary type: subtype 0x05 +Binary type: subtype 0x04 UUID --DESCRIPTION-- Generated by scripts/convert-bson-corpus-tests.php @@ -9,8 +9,9 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/tools.php'; -$canonicalBson = hex2bin('1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400'); -$canonicalExtJson = '{"x" : { "$binary" : {"base64" : "c//SZESzTGmQ6OfR38A11A==", "subType" : "05"}}}'; +$canonicalBson = hex2bin('1D000000057800100000000473FFD26444B34C6990E8E7D1DFC035D400'); +$canonicalExtJson = '{"x" : { "$binary" : {"base64" : "c//SZESzTGmQ6OfR38A11A==", "subType" : "04"}}}'; +$degenerateExtJson = '{"x" : { "$uuid" : "73ffd264-44b3-4c69-90e8-e7d1dfc035d4"}}'; // Canonical BSON -> Native -> Canonical BSON echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n"; @@ -21,11 +22,15 @@ echo json_canonicalize(toCanonicalExtendedJSON($canonicalBson)), "\n"; // Canonical extJSON -> Canonical BSON echo bin2hex(fromJSON($canonicalExtJson)), "\n"; +// Degenerate extJSON -> Canonical BSON +echo bin2hex(fromJSON($degenerateExtJson)), "\n"; + ?> ===DONE=== --EXPECT-- -1d000000057800100000000573ffd26444b34c6990e8e7d1dfc035d400 -{"x":{"$binary":{"base64":"c\/\/SZESzTGmQ6OfR38A11A==","subType":"05"}}} -1d000000057800100000000573ffd26444b34c6990e8e7d1dfc035d400 +1d000000057800100000000473ffd26444b34c6990e8e7d1dfc035d400 +{"x":{"$binary":{"base64":"c\/\/SZESzTGmQ6OfR38A11A==","subType":"04"}}} +1d000000057800100000000473ffd26444b34c6990e8e7d1dfc035d400 +1d000000057800100000000473ffd26444b34c6990e8e7d1dfc035d400 ===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-valid-009.phpt b/tests/bson-corpus/binary-valid-009.phpt index 34f9004fb..5e660819d 100644 --- a/tests/bson-corpus/binary-valid-009.phpt +++ b/tests/bson-corpus/binary-valid-009.phpt @@ -1,5 +1,5 @@ --TEST-- -Binary type: subtype 0x80 +Binary type: subtype 0x05 --DESCRIPTION-- Generated by scripts/convert-bson-corpus-tests.php @@ -9,8 +9,8 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/tools.php'; -$canonicalBson = hex2bin('0F0000000578000200000080FFFF00'); -$canonicalExtJson = '{"x" : { "$binary" : {"base64" : "//8=", "subType" : "80"}}}'; +$canonicalBson = hex2bin('1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400'); +$canonicalExtJson = '{"x" : { "$binary" : {"base64" : "c//SZESzTGmQ6OfR38A11A==", "subType" : "05"}}}'; // Canonical BSON -> Native -> Canonical BSON echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n"; @@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n"; ===DONE=== --EXPECT-- -0f0000000578000200000080ffff00 -{"x":{"$binary":{"base64":"\/\/8=","subType":"80"}}} -0f0000000578000200000080ffff00 +1d000000057800100000000573ffd26444b34c6990e8e7d1dfc035d400 +{"x":{"$binary":{"base64":"c\/\/SZESzTGmQ6OfR38A11A==","subType":"05"}}} +1d000000057800100000000573ffd26444b34c6990e8e7d1dfc035d400 ===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-valid-010.phpt b/tests/bson-corpus/binary-valid-010.phpt index 123b2607a..34f9004fb 100644 --- a/tests/bson-corpus/binary-valid-010.phpt +++ b/tests/bson-corpus/binary-valid-010.phpt @@ -1,5 +1,5 @@ --TEST-- -Binary type: $type query operator (conflicts with legacy $binary form with $type field) +Binary type: subtype 0x80 --DESCRIPTION-- Generated by scripts/convert-bson-corpus-tests.php @@ -9,8 +9,8 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/tools.php'; -$canonicalBson = hex2bin('1F000000037800170000000224747970650007000000737472696E67000000'); -$canonicalExtJson = '{"x" : { "$type" : "string"}}'; +$canonicalBson = hex2bin('0F0000000578000200000080FFFF00'); +$canonicalExtJson = '{"x" : { "$binary" : {"base64" : "//8=", "subType" : "80"}}}'; // Canonical BSON -> Native -> Canonical BSON echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n"; @@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n"; ===DONE=== --EXPECT-- -1f000000037800170000000224747970650007000000737472696e67000000 -{"x":{"$type":"string"}} -1f000000037800170000000224747970650007000000737472696e67000000 +0f0000000578000200000080ffff00 +{"x":{"$binary":{"base64":"\/\/8=","subType":"80"}}} +0f0000000578000200000080ffff00 ===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-valid-011.phpt b/tests/bson-corpus/binary-valid-011.phpt index a60283202..123b2607a 100644 --- a/tests/bson-corpus/binary-valid-011.phpt +++ b/tests/bson-corpus/binary-valid-011.phpt @@ -9,8 +9,8 @@ DO NOT EDIT THIS FILE require_once __DIR__ . '/../utils/tools.php'; -$canonicalBson = hex2bin('180000000378001000000010247479706500020000000000'); -$canonicalExtJson = '{"x" : { "$type" : {"$numberInt": "2"}}}'; +$canonicalBson = hex2bin('1F000000037800170000000224747970650007000000737472696E67000000'); +$canonicalExtJson = '{"x" : { "$type" : "string"}}'; // Canonical BSON -> Native -> Canonical BSON echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n"; @@ -25,7 +25,7 @@ echo bin2hex(fromJSON($canonicalExtJson)), "\n"; ===DONE=== --EXPECT-- -180000000378001000000010247479706500020000000000 -{"x":{"$type":{"$numberInt":"2"}}} -180000000378001000000010247479706500020000000000 +1f000000037800170000000224747970650007000000737472696e67000000 +{"x":{"$type":"string"}} +1f000000037800170000000224747970650007000000737472696e67000000 ===DONE=== \ No newline at end of file diff --git a/tests/bson-corpus/binary-valid-012.phpt b/tests/bson-corpus/binary-valid-012.phpt new file mode 100644 index 000000000..a60283202 --- /dev/null +++ b/tests/bson-corpus/binary-valid-012.phpt @@ -0,0 +1,31 @@ +--TEST-- +Binary type: $type query operator (conflicts with legacy $binary form with $type field) +--DESCRIPTION-- +Generated by scripts/convert-bson-corpus-tests.php + +DO NOT EDIT THIS FILE +--FILE-- + Native -> Canonical BSON +echo bin2hex(fromPHP(toPHP($canonicalBson))), "\n"; + +// Canonical BSON -> Canonical extJSON +echo json_canonicalize(toCanonicalExtendedJSON($canonicalBson)), "\n"; + +// Canonical extJSON -> Canonical BSON +echo bin2hex(fromJSON($canonicalExtJson)), "\n"; + +?> +===DONE=== + +--EXPECT-- +180000000378001000000010247479706500020000000000 +{"x":{"$type":{"$numberInt":"2"}}} +180000000378001000000010247479706500020000000000 +===DONE=== \ No newline at end of file