diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md index 9bbbc1e5f..1f0134cdb 100644 --- a/UPGRADE-2.0.md +++ b/UPGRADE-2.0.md @@ -4,3 +4,5 @@ UPGRADE FROM 1.x to 2.0 * The `getServer()` method has been removed from the CommandFailedEvent, CommandStartedEvent, and CommandSucceededEvent event classes. The `getHost()` and `getPort()` methods have been added in its place. + * The BSON functions in the `MongoDB\BSON` namespace have been removed in favor + of the `MongoDB\BSON\Document` class. diff --git a/config.m4 b/config.m4 index 6c9d5a238..92cff6793 100644 --- a/config.m4 +++ b/config.m4 @@ -165,7 +165,6 @@ if test "$PHP_MONGODB" != "no"; then src/BSON/Unserializable.c \ src/BSON/UTCDateTime.c \ src/BSON/UTCDateTimeInterface.c \ - src/BSON/functions.c \ src/MongoDB/BulkWrite.c \ src/MongoDB/ClientEncryption.c \ src/MongoDB/Command.c \ diff --git a/config.w32 b/config.w32 index bb45d134c..40762d812 100644 --- a/config.w32 +++ b/config.w32 @@ -115,7 +115,7 @@ if (PHP_MONGODB != "no") { EXTENSION("mongodb", "php_phongo.c", null, PHP_MONGODB_CFLAGS); MONGODB_ADD_SOURCES("/src", "phongo_apm.c phongo_bson.c phongo_bson_encode.c phongo_client.c phongo_compat.c phongo_error.c phongo_execute.c phongo_ini.c phongo_log.c phongo_util.c"); - MONGODB_ADD_SOURCES("/src/BSON", "Binary.c BinaryInterface.c Document.c Iterator.c DBPointer.c Decimal128.c Decimal128Interface.c Int64.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c PackedArray.c Persistable.c Regex.c RegexInterface.c Serializable.c Symbol.c Timestamp.c TimestampInterface.c Type.c Undefined.c Unserializable.c UTCDateTime.c UTCDateTimeInterface.c functions.c"); + MONGODB_ADD_SOURCES("/src/BSON", "Binary.c BinaryInterface.c Document.c Iterator.c DBPointer.c Decimal128.c Decimal128Interface.c Int64.c Javascript.c JavascriptInterface.c MaxKey.c MaxKeyInterface.c MinKey.c MinKeyInterface.c ObjectId.c ObjectIdInterface.c PackedArray.c Persistable.c Regex.c RegexInterface.c Serializable.c Symbol.c Timestamp.c TimestampInterface.c Type.c Undefined.c Unserializable.c UTCDateTime.c UTCDateTimeInterface.c"); MONGODB_ADD_SOURCES("/src/MongoDB", "BulkWrite.c ClientEncryption.c Command.c Cursor.c CursorId.c CursorInterface.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c ServerApi.c ServerDescription.c Session.c TopologyDescription.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c"); MONGODB_ADD_SOURCES("/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c CommandException.c ConnectionException.c ConnectionTimeoutException.c EncryptionException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c ServerException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c"); MONGODB_ADD_SOURCES("/src/MongoDB/Monitoring", "CommandFailedEvent.c CommandStartedEvent.c CommandSubscriber.c CommandSucceededEvent.c LogSubscriber.c SDAMSubscriber.c Subscriber.c ServerChangedEvent.c ServerClosedEvent.c ServerHeartbeatFailedEvent.c ServerHeartbeatStartedEvent.c ServerHeartbeatSucceededEvent.c ServerOpeningEvent.c TopologyChangedEvent.c TopologyClosedEvent.c TopologyOpeningEvent.c functions.c"); diff --git a/src/BSON/functions.c b/src/BSON/functions.c deleted file mode 100644 index 72914c7c9..000000000 --- a/src/BSON/functions.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2014-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "bson/bson.h" - -#include - -#include "php_phongo.h" -#include "phongo_bson_encode.h" -#include "phongo_error.h" - -/* Returns the BSON representation of a PHP value */ -PHP_FUNCTION(MongoDB_BSON_fromPHP) -{ - zval* data; - bson_t* bson; - - PHONGO_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY_OR_OBJECT(data) - PHONGO_PARSE_PARAMETERS_END(); - - bson = bson_new(); - php_phongo_zval_to_bson(data, PHONGO_BSON_NONE, bson, NULL); - - RETVAL_STRINGL((const char*) bson_get_data(bson), bson->len); - bson_destroy(bson); -} - -/* Returns the PHP representation of a BSON value, optionally converting it into a custom class */ -PHP_FUNCTION(MongoDB_BSON_toPHP) -{ - char* data; - size_t data_len; - zval* typemap = NULL; - php_phongo_bson_state state; - - PHONGO_BSON_INIT_STATE(state); - - PHONGO_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STRING(data, data_len) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(typemap) - PHONGO_PARSE_PARAMETERS_END(); - - if (!php_phongo_bson_typemap_to_state(typemap, &state.map)) { - return; - } - - if (!php_phongo_bson_data_to_zval_ex((const unsigned char*) data, data_len, &state)) { - zval_ptr_dtor(&state.zchild); - php_phongo_bson_typemap_dtor(&state.map); - RETURN_NULL(); - } - - php_phongo_bson_typemap_dtor(&state.map); - - RETURN_ZVAL(&state.zchild, 0, 1); -} - -/* Returns the BSON representation of a JSON value */ -PHP_FUNCTION(MongoDB_BSON_fromJSON) -{ - char* json; - size_t json_len; - bson_t bson = BSON_INITIALIZER; - bson_error_t error = { 0 }; - - PHONGO_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(json, json_len) - PHONGO_PARSE_PARAMETERS_END(); - - if (bson_init_from_json(&bson, (const char*) json, json_len, &error)) { - RETVAL_STRINGL((const char*) bson_get_data(&bson), bson.len); - bson_destroy(&bson); - } else { - phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "%s", error.domain == BSON_ERROR_JSON ? error.message : "Error parsing JSON"); - } -} - -static void phongo_bson_to_json(INTERNAL_FUNCTION_PARAMETERS, php_phongo_json_mode_t mode) -{ - char* data; - size_t data_len; - const bson_t* bson; - bool eof = false; - bson_reader_t* reader; - - PHONGO_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(data, data_len) - PHONGO_PARSE_PARAMETERS_END(); - - reader = bson_reader_new_from_data((const unsigned char*) data, data_len); - bson = bson_reader_read(reader, NULL); - - if (!bson) { - phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Could not read document from BSON reader"); - bson_reader_destroy(reader); - return; - } - - if (!php_phongo_bson_to_json(return_value, bson, mode)) { - phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Could not convert BSON document to a JSON string"); - bson_reader_destroy(reader); - return; - } - - if (bson_reader_read(reader, &eof) || !eof) { - phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE, "Reading document did not exhaust input buffer"); - } - - bson_reader_destroy(reader); -} - -/* Returns the legacy extended JSON representation of a BSON value */ -PHP_FUNCTION(MongoDB_BSON_toJSON) -{ - phongo_bson_to_json(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHONGO_JSON_MODE_LEGACY); -} - -/* Returns the canonical extended JSON representation of a BSON value */ -PHP_FUNCTION(MongoDB_BSON_toCanonicalExtendedJSON) -{ - phongo_bson_to_json(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHONGO_JSON_MODE_CANONICAL); -} - -/* Returns the relaxed extended JSON representation of a BSON value */ -PHP_FUNCTION(MongoDB_BSON_toRelaxedExtendedJSON) -{ - phongo_bson_to_json(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHONGO_JSON_MODE_RELAXED); -} diff --git a/src/functions.stub.php b/src/functions.stub.php index 2ecff0cfe..aea7cdf80 100644 --- a/src/functions.stub.php +++ b/src/functions.stub.php @@ -2,26 +2,6 @@ /** @generate-function-entries */ -namespace MongoDB\BSON { - /** @deprecated use MongoDB\BSON\Document::fromJSON instead */ - function fromJSON(string $json): string {} - - /** @deprecated use MongoDB\BSON\Document::fromPHP instead */ - function fromPHP(array|object $value): string {} - - /** @deprecated use MongoDB\BSON\Document::toCanonicalExtendedJSON instead */ - function toCanonicalExtendedJSON(string $bson): string {} - - /** @deprecated */ - function toJSON(string $bson): string {} - - /** @deprecated use MongoDB\BSON\Document::toPHP instead */ - function toPHP(string $bson, ?array $typemap = null): array|object {} - - /** @deprecated use MongoDB\BSON\Document::toRelaxedExtendedJSON instead */ - function toRelaxedExtendedJSON(string $bson): string {} -} - namespace MongoDB\Driver\Monitoring { function addSubscriber(Subscriber $subscriber): void {} diff --git a/src/functions_arginfo.h b/src/functions_arginfo.h index bf1fc03cc..f483aadcd 100644 --- a/src/functions_arginfo.h +++ b/src/functions_arginfo.h @@ -1,26 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4d9c8b8131126ce2e67fe1659205aaf7eee8c14e */ - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_MongoDB_BSON_fromJSON, 0, 1, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, json, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_MongoDB_BSON_fromPHP, 0, 1, IS_STRING, 0) - ZEND_ARG_TYPE_MASK(0, value, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_MongoDB_BSON_toCanonicalExtendedJSON, 0, 1, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, bson, IS_STRING, 0) -ZEND_END_ARG_INFO() - -#define arginfo_MongoDB_BSON_toJSON arginfo_MongoDB_BSON_toCanonicalExtendedJSON - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_MongoDB_BSON_toPHP, 0, 1, MAY_BE_ARRAY|MAY_BE_OBJECT) - ZEND_ARG_TYPE_INFO(0, bson, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, typemap, IS_ARRAY, 1, "null") -ZEND_END_ARG_INFO() - -#define arginfo_MongoDB_BSON_toRelaxedExtendedJSON arginfo_MongoDB_BSON_toCanonicalExtendedJSON + * Stub hash: fac870fef1ab3d172fb2f2227a3a30fd76406b38 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_MongoDB_Driver_Monitoring_addSubscriber, 0, 1, IS_VOID, 0) ZEND_ARG_OBJ_INFO(0, subscriber, MongoDB\\Driver\\Monitoring\\Subscriber, 0) @@ -35,24 +14,12 @@ ZEND_END_ARG_INFO() #define arginfo_MongoDB_Driver_Monitoring_removeSubscriber arginfo_MongoDB_Driver_Monitoring_addSubscriber -ZEND_FUNCTION(MongoDB_BSON_fromJSON); -ZEND_FUNCTION(MongoDB_BSON_fromPHP); -ZEND_FUNCTION(MongoDB_BSON_toCanonicalExtendedJSON); -ZEND_FUNCTION(MongoDB_BSON_toJSON); -ZEND_FUNCTION(MongoDB_BSON_toPHP); -ZEND_FUNCTION(MongoDB_BSON_toRelaxedExtendedJSON); ZEND_FUNCTION(MongoDB_Driver_Monitoring_addSubscriber); ZEND_FUNCTION(MongoDB_Driver_Monitoring_mongoc_log); ZEND_FUNCTION(MongoDB_Driver_Monitoring_removeSubscriber); static const zend_function_entry ext_functions[] = { - ZEND_NS_DEP_FALIAS("MongoDB\\BSON", fromJSON, MongoDB_BSON_fromJSON, arginfo_MongoDB_BSON_fromJSON) - ZEND_NS_DEP_FALIAS("MongoDB\\BSON", fromPHP, MongoDB_BSON_fromPHP, arginfo_MongoDB_BSON_fromPHP) - ZEND_NS_DEP_FALIAS("MongoDB\\BSON", toCanonicalExtendedJSON, MongoDB_BSON_toCanonicalExtendedJSON, arginfo_MongoDB_BSON_toCanonicalExtendedJSON) - ZEND_NS_DEP_FALIAS("MongoDB\\BSON", toJSON, MongoDB_BSON_toJSON, arginfo_MongoDB_BSON_toJSON) - ZEND_NS_DEP_FALIAS("MongoDB\\BSON", toPHP, MongoDB_BSON_toPHP, arginfo_MongoDB_BSON_toPHP) - ZEND_NS_DEP_FALIAS("MongoDB\\BSON", toRelaxedExtendedJSON, MongoDB_BSON_toRelaxedExtendedJSON, arginfo_MongoDB_BSON_toRelaxedExtendedJSON) ZEND_NS_FALIAS("MongoDB\\Driver\\Monitoring", addSubscriber, MongoDB_Driver_Monitoring_addSubscriber, arginfo_MongoDB_Driver_Monitoring_addSubscriber) ZEND_NS_FALIAS("MongoDB\\Driver\\Monitoring", mongoc_log, MongoDB_Driver_Monitoring_mongoc_log, arginfo_MongoDB_Driver_Monitoring_mongoc_log) ZEND_NS_FALIAS("MongoDB\\Driver\\Monitoring", removeSubscriber, MongoDB_Driver_Monitoring_removeSubscriber, arginfo_MongoDB_Driver_Monitoring_removeSubscriber) diff --git a/tests/bson/bson-fromJSON-001.phpt b/tests/bson/bson-fromJSON-001.phpt deleted file mode 100644 index b9c151146..000000000 --- a/tests/bson/bson-fromJSON-001.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -MongoDB\BSON\fromJSON(): Decoding JSON ---FILE-- - -===DONE=== - ---EXPECTF-- -Test {} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 05 00 00 00 00 [.....] -Test { "foo": "bar" } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 12 00 00 00 02 66 6f 6f 00 04 00 00 00 62 61 72 [.....foo.....bar] - 10 : 00 00 [..] -Test { "foo": [ 1, 2, 3 ]} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 24 00 00 00 04 66 6f 6f 00 1a 00 00 00 10 30 00 [$....foo......0.] - 10 : 01 00 00 00 10 31 00 02 00 00 00 10 32 00 03 00 [.....1......2...] - 20 : 00 00 00 00 [....] -Test { "foo": { "bar": 1 }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 18 00 00 00 03 66 6f 6f 00 0e 00 00 00 10 62 61 [.....foo......ba] - 10 : 72 00 01 00 00 00 00 00 [r.......] -===DONE=== diff --git a/tests/bson/bson-fromJSON-002.phpt b/tests/bson/bson-fromJSON-002.phpt deleted file mode 100644 index e8681a270..000000000 --- a/tests/bson/bson-fromJSON-002.phpt +++ /dev/null @@ -1,72 +0,0 @@ ---TEST-- -MongoDB\BSON\fromJSON(): Decoding extended JSON types ---FILE-- - -===DONE=== - ---EXPECTF-- -Test { "_id": { "$oid": "56315a7c6118fd1b920270b1" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 16 00 00 00 07 5f 69 64 00 56 31 5a 7c 61 18 fd [....._id.V1Z|a..] - 10 : 1b 92 02 70 b1 00 [...p..] -Test { "binary": { "$binary": "Zm9v", "$type": "00" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 15 00 00 00 05 62 69 6e 61 72 79 00 03 00 00 00 [.....binary.....] - 10 : 00 66 6f 6f 00 [.foo.] -Test { "date": { "$date": "2015-10-28T00:00:00Z" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 13 00 00 00 09 64 61 74 65 00 00 80 be ab 50 01 [.....date.....P.] - 10 : 00 00 00 [...] -Test { "timestamp": { "$timestamp": { "t": 1446084619, "i": 0 }}} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 18 00 00 00 11 74 69 6d 65 73 74 61 6d 70 00 00 [.....timestamp..] - 10 : 00 00 00 0b 80 31 56 00 [.....1V.] -Test { "regex": { "$regex": "pattern", "$options": "i" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 16 00 00 00 0b 72 65 67 65 78 00 70 61 74 74 65 [.....regex.patte] - 10 : 72 6e 00 69 00 00 [rn.i..] -Test { "undef": { "$undefined": true }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 0c 00 00 00 06 75 6e 64 65 66 00 00 [.....undef..] -Test { "minkey": { "$minKey": 1 }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 0d 00 00 00 ff 6d 69 6e 6b 65 79 00 00 [.....minkey..] -Test { "maxkey": { "$maxKey": 1 }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 0d 00 00 00 7f 6d 61 78 6b 65 79 00 00 [.....maxkey..] -Test { "long": { "$numberLong": "1234" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 13 00 00 00 12 6c 6f 6e 67 00 d2 04 00 00 00 00 [.....long.......] - 10 : 00 00 00 [...] -===DONE=== diff --git a/tests/bson/bson-fromJSON-003.phpt b/tests/bson/bson-fromJSON-003.phpt deleted file mode 100644 index 25e56e7f8..000000000 --- a/tests/bson/bson-fromJSON-003.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -MongoDB\BSON\fromJSON(): Decoding JSON with duplicate field names ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - 0 : 1f 00 00 00 02 66 6f 6f 00 04 00 00 00 62 61 72 [.....foo.....bar] - 10 : 00 02 66 6f 6f 00 04 00 00 00 62 61 7a 00 00 [..foo.....baz..] -===DONE=== diff --git a/tests/bson/bson-fromJSON_error-001.phpt b/tests/bson/bson-fromJSON_error-001.phpt deleted file mode 100644 index 0b989c44b..000000000 --- a/tests/bson/bson-fromJSON_error-001.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -MongoDB\BSON\fromJSON(): invalid JSON ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -===DONE=== diff --git a/tests/bson/bson-fromPHP-001.phpt b/tests/bson/bson-fromPHP-001.phpt deleted file mode 100644 index af2105d5f..000000000 --- a/tests/bson/bson-fromPHP-001.phpt +++ /dev/null @@ -1,194 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): bsonSerialize() allows arrays, stdClass instances, BSON arrays, and BSON documents ---FILE-- -data = $data; - } - - #[\ReturnTypeWillChange] - public function bsonSerialize() - { - return $this->data; - } -} - -class MyPersistableDocument extends MyDocument implements MongoDB\BSON\Persistable -{ - public function bsonUnserialize(array $data): void - { - $this->data = $data; - } -} - -$tests = array( - array(1, 2, 3), - array('foo' => 'bar'), - (object) array(1, 2, 3), - (object) array('foo' => 'bar'), - /* PackedArray cannot be serialized as a root document. Additionally, it - * will fail return type validation for Persistable::bsonSerialize(). */ - MongoDB\BSON\PackedArray::fromPHP([1, 2, 3]), - MongoDB\BSON\Document::fromPHP(['foo' => 'bar']), -); - -echo "Testing top-level objects\n"; - -foreach ($tests as $test) { - try { - echo MongoDB\BSON\toJson(MongoDB\BSON\fromPHP(new MyDocument($test))), "\n"; - } catch (Exception $e) { - printf("%s: %s\n", get_class($e), $e->getMessage()); - } - try { - echo MongoDB\BSON\toJson(MongoDB\BSON\fromPHP(new MyPersistableDocument($test))), "\n"; - } catch (Exception $e) { - printf("%s: %s\n", get_class($e), $e->getMessage()); - } -} - -echo "\nTesting nested objects\n"; - -foreach ($tests as $test) { - try { - echo MongoDB\BSON\toJson(MongoDB\BSON\fromPHP(new MyDocument(['nested' => new MyDocument($test)]))), "\n"; - } catch (Exception $e) { - printf("%s: %s\n", get_class($e), $e->getMessage()); - } - try { - echo MongoDB\BSON\toJson(MongoDB\BSON\fromPHP(new MyDocument(['nested' => new MyPersistableDocument($test)]))), "\n"; - } catch (Exception $e) { - printf("%s: %s\n", get_class($e), $e->getMessage()); - } -} - -?> -===DONE=== - ---EXPECTF-- -Testing top-level objects - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "0" : 1, "1" : 2, "2" : 3 } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "0" : 1, "1" : 2, "2" : 3 } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "foo" : "bar" } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "foo" : "bar" } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "0" : 1, "1" : 2, "2" : 3 } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "0" : 1, "1" : 2, "2" : 3 } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "foo" : "bar" } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "foo" : "bar" } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -MongoDB\Driver\Exception\UnexpectedValueException: MongoDB\BSON\PackedArray cannot be serialized as a root document - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -MongoDB\Driver\Exception\UnexpectedValueException: Expected MyPersistableDocument::bsonSerialize() to return an array, stdClass, or MongoDB\BSON\Document, MongoDB\BSON\PackedArray given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "foo" : "bar" } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "foo" : "bar" } - -Testing nested objects - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : [ 1, 2, 3 ] } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "0" : 1, "1" : 2, "2" : 3 } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "foo" : "bar" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "foo" : "bar" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "0" : 1, "1" : 2, "2" : 3 } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "0" : 1, "1" : 2, "2" : 3 } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "foo" : "bar" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "foo" : "bar" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : [ 1, 2, 3 ] } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -MongoDB\Driver\Exception\UnexpectedValueException: Expected MyPersistableDocument::bsonSerialize() to return an array, stdClass, or MongoDB\BSON\Document, MongoDB\BSON\PackedArray given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "foo" : "bar" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nested" : { "__pclass" : { "$binary" : "TXlQZXJzaXN0YWJsZURvY3VtZW50", "$type" : "80" }, "foo" : "bar" } } -===DONE=== diff --git a/tests/bson/bson-fromPHP-002.phpt b/tests/bson/bson-fromPHP-002.phpt deleted file mode 100644 index 2526f7764..000000000 --- a/tests/bson/bson-fromPHP-002.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): Encoding non-Persistable objects as a document ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "baz" : 3 } - 0 : 0e 00 00 00 10 62 61 7a 00 03 00 00 00 00 [.....baz......] -===DONE=== diff --git a/tests/bson/bson-fromPHP-003.phpt b/tests/bson/bson-fromPHP-003.phpt deleted file mode 100644 index 85fc850b2..000000000 --- a/tests/bson/bson-fromPHP-003.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): Encoding non-Persistable objects as a document field value ---FILE-- - new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'))), - array(new MyDocument), - array('x' => new MyDocument), -); - -foreach ($tests as $document) { - $s = MongoDB\BSON\fromPHP($document); - echo "Test " . MongoDB\BSON\toJSON($s) . "\n"; - hex_dump($s); -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "0" : { "$date" : 1416445411987 } } - 0 : 10 00 00 00 09 30 00 93 c2 b9 ca 49 01 00 00 00 [.....0.....I....] - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : { "$date" : 1416445411987 } } - 0 : 10 00 00 00 09 78 00 93 c2 b9 ca 49 01 00 00 00 [.....x.....I....] - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "0" : { "baz" : 3 } } - 0 : 16 00 00 00 03 30 00 0e 00 00 00 10 62 61 7a 00 [.....0......baz.] - 10 : 03 00 00 00 00 00 [......] - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : { "baz" : 3 } } - 0 : 16 00 00 00 03 78 00 0e 00 00 00 10 62 61 7a 00 [.....x......baz.] - 10 : 03 00 00 00 00 00 [......] -===DONE=== diff --git a/tests/bson/bson-fromPHP-005.phpt b/tests/bson/bson-fromPHP-005.phpt deleted file mode 100644 index e9d8ad2cd..000000000 --- a/tests/bson/bson-fromPHP-005.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): PHP document with public property whose name is an empty string ---FILE-- - 1], - (object) ['' => 1], -]; - -foreach ($tests as $document) { - $s = MongoDB\BSON\fromPHP($document); - echo "Test " . MongoDB\BSON\toJSON($s) . "\n"; - hex_dump($s); -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "" : 1 } - 0 : 0b 00 00 00 10 00 01 00 00 00 00 [...........] - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "" : 1 } - 0 : 0b 00 00 00 10 00 01 00 00 00 00 [...........] -===DONE=== diff --git a/tests/bson/bson-fromPHP-006.phpt b/tests/bson/bson-fromPHP-006.phpt deleted file mode 100644 index 68d81dda0..000000000 --- a/tests/bson/bson-fromPHP-006.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): PHP documents with null bytes in field name ---FILE-- - 1])); - -echo "\nTesting object with multiple null bytes in field name\n"; -hex_dump(MongoDB\BSON\fromPHP((object) ["\0\0\0" => 1])); - -?> -===DONE=== - ---EXPECTF-- -Testing object with one leading null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - 0 : 05 00 00 00 00 [.....] - -Testing object with multiple null bytes in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - 0 : 05 00 00 00 00 [.....] -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-001.phpt b/tests/bson/bson-fromPHP_error-001.phpt deleted file mode 100644 index c4d720954..000000000 --- a/tests/bson/bson-fromPHP_error-001.phpt +++ /dev/null @@ -1,83 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): bsonSerialize() must return an array or stdClass ---FILE-- -data = $data; - } - - #[\ReturnTypeWillChange] - public function bsonSerialize() - { - return $this->data; - } -} - -$invalidValues = array(null, 123, 'foo', true, new MyDocument); - -echo "Testing top-level objects\n"; - -foreach ($invalidValues as $invalidValue) { - try { - hex_dump(MongoDB\BSON\fromPHP(new MyDocument($invalidValue))); - } catch (MongoDB\Driver\Exception\UnexpectedValueException $e) { - echo $e->getMessage(), "\n"; - } -} - -echo "\nTesting nested objects\n"; - -foreach ($invalidValues as $invalidValue) { - try { - hex_dump(MongoDB\BSON\fromPHP(new MyDocument(array('nested' => new MyDocument($invalidValue))))); - } catch (MongoDB\Driver\Exception\UnexpectedValueException $e) { - echo $e->getMessage(), "\n"; - } -} - -?> -===DONE=== - ---EXPECTF-- -Testing top-level objects - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, null given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, int given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, string given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, bool given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, MyDocument given - -Testing nested objects - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, null given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, int given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, string given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, bool given - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Expected MyDocument::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, MyDocument given -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-002.phpt b/tests/bson/bson-fromPHP_error-002.phpt deleted file mode 100644 index b5671070d..000000000 --- a/tests/bson/bson-fromPHP_error-002.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): Encoding unknown Type objects as a document field value ---FILE-- - new UnknownType()), -); - -foreach ($tests as $document) { - echo throws(function() use ($document) { - MongoDB\BSON\fromPHP($document); - }, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Unexpected MongoDB\BSON\Type instance: UnknownType - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Unexpected MongoDB\BSON\Type instance: UnknownType -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-003.phpt b/tests/bson/bson-fromPHP_error-003.phpt deleted file mode 100644 index 195dccf0a..000000000 --- a/tests/bson/bson-fromPHP_error-003.phpt +++ /dev/null @@ -1,66 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): Encoding non-Serializable Type objects as a root element ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance UnknownType cannot be serialized as a root element - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance MongoDB\BSON\Binary cannot be serialized as a root element - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance MongoDB\BSON\Javascript cannot be serialized as a root element - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance MongoDB\BSON\MinKey cannot be serialized as a root element - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance MongoDB\BSON\MaxKey cannot be serialized as a root element - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance MongoDB\BSON\ObjectId cannot be serialized as a root element - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance MongoDB\BSON\Regex cannot be serialized as a root element - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance MongoDB\BSON\Timestamp cannot be serialized as a root element - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\Type instance MongoDB\BSON\UTCDateTime cannot be serialized as a root element -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-004.phpt b/tests/bson/bson-fromPHP_error-004.phpt deleted file mode 100644 index 86270e4af..000000000 --- a/tests/bson/bson-fromPHP_error-004.phpt +++ /dev/null @@ -1,95 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): PHP documents with circular references ---FILE-- - 1, 'y' => []]; - $document['y'][] = &$document['y']; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting packed array with circular reference at 3rd position\n"; - -echo throws(function() { - $document = ['x' => 1, 'y' => [1, 2, 3]]; - $document['y'][] = &$document['y']; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting associative array with circular reference\n"; - -echo throws(function() { - $document = ['x' => 1, 'y' => []]; - $document['y']['z'] = &$document['y']; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting associative array and nested array with circular reference\n"; - -echo throws(function() { - $document = ['x' => 1, 'y' => []]; - $document['y'][0]['z'] = &$document['y']; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting object with circular reference\n"; - -echo throws(function() { - $document = (object) ['x' => 1, 'y' => (object) []]; - $document->y->z = &$document->y; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting nested object with circular reference\n"; - -echo throws(function() { - $document = (object) ['x' => 1, 'y' => (object) ['z' => (object) []]]; - $document->y->z->a = &$document->y; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -?> -===DONE=== - ---EXPECTF-- -Testing packed array with circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.0" - -Testing packed array with circular reference at 3rd position - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.3" - -Testing associative array with circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.z" - -Testing associative array and nested array with circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.0.z" - -Testing object with circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.z" - -Testing nested object with circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.z.a" -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-005.phpt b/tests/bson/bson-fromPHP_error-005.phpt deleted file mode 100644 index cdbd530a6..000000000 --- a/tests/bson/bson-fromPHP_error-005.phpt +++ /dev/null @@ -1,55 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): Serializable with circular references ---FILE-- - $this]; - } -} - -echo "\nTesting Serializable with direct circular reference\n"; - -echo throws(function() { - MongoDB\BSON\fromPHP(new MyRecursiveSerializable); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting Serializable with indirect circular reference\n"; - -echo throws(function() { - MongoDB\BSON\fromPHP(new MyIndirectlyRecursiveSerializable); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -?> -===DONE=== - ---EXPECTF-- -Testing Serializable with direct circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Expected MyRecursiveSerializable::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, MyRecursiveSerializable given - -Testing Serializable with indirect circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "parent.parent" -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-006.phpt b/tests/bson/bson-fromPHP_error-006.phpt deleted file mode 100644 index 3a449dd1a..000000000 --- a/tests/bson/bson-fromPHP_error-006.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): PHP documents with null bytes in field name ---DESCRIPTION-- -BSON Corpus spec prose test #1 ---FILE-- - 1]); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting array with one trailing null byte in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(["a\0" => 1]); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting array with multiple null bytes in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(["\0\0\0" => 1]); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting object with one trailing null byte in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP((object) ["a\0" => 1]); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting nested array with one trailing null byte in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(['a' => ["b\0" => 1]]); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -?> -===DONE=== - ---EXPECTF-- -Testing array with one leading null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "". - -Testing array with one trailing null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "a". - -Testing array with multiple null bytes in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "". - -Testing object with one trailing null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "a". - -Testing nested array with one trailing null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "b". -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-007.phpt b/tests/bson/bson-fromPHP_error-007.phpt deleted file mode 100644 index a60b16bc2..000000000 --- a/tests/bson/bson-fromPHP_error-007.phpt +++ /dev/null @@ -1,98 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): Serializable returns document with null bytes in field name ---FILE-- -data = $data; - } - - #[\ReturnTypeWillChange] - public function bsonSerialize() - { - return $this->data; - } -} - -echo "\nTesting array with one leading null byte in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(new MySerializable(["\0" => 1])); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting array with one trailing null byte in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(new MySerializable(["a\0" => 1])); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting array with multiple null bytes in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(new MySerializable(["\0\0\0" => 1])); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -/* Per PHPC-884, field names with a leading null byte are ignored when encoding - * a document from an object's property hash table, since PHP uses leading bytes - * to denote protected and private properties. However, in this case the object - * was returned from Serializable::bsonSerialize() and we skip the check for - * protected and private properties. */ -echo "\nTesting object with one leading null byte in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(new MySerializable((object) ["\0" => 1])); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting object with one trailing null byte in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(new MySerializable((object) ["a\0" => 1])); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting object with multiple null bytes in field name\n"; -echo throws(function() { - MongoDB\BSON\fromPHP(new MySerializable((object) ["\0\0\0" => 1])); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -?> -===DONE=== - ---EXPECTF-- -Testing array with one leading null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "". - -Testing array with one trailing null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "a". - -Testing array with multiple null bytes in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "". - -Testing object with one leading null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "". - -Testing object with one trailing null byte in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "a". - -Testing object with multiple null bytes in field name - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -BSON keys cannot contain null bytes. Unexpected null byte after "". -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-008.phpt b/tests/bson/bson-fromPHP_error-008.phpt deleted file mode 100644 index c9cdfabfd..000000000 --- a/tests/bson/bson-fromPHP_error-008.phpt +++ /dev/null @@ -1,53 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): PHP documents with circular references ---FILE-- - 1, 'y' => [1, 2, 3]]; - $document['y'][] = &$document['y']; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting associative array with circular reference\n"; - -echo throws(function() { - $document = ['x' => 1, 'y' => []]; - $document['y'][0]['z'] = &$document['y']; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -echo "\nTesting object with circular reference\n"; - -echo throws(function() { - $document = (object) ['x' => 1, 'y' => (object) []]; - $document->y->z = &$document->y; - MongoDB\BSON\fromPHP($document); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -?> -===DONE=== - ---EXPECTF-- -Testing packed array with circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.3" - -Testing associative array with circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.0.z" - -Testing object with circular reference - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected recursion for field path "y.z" -===DONE=== diff --git a/tests/bson/bson-fromPHP_error-009.phpt b/tests/bson/bson-fromPHP_error-009.phpt deleted file mode 100644 index 1cd242419..000000000 --- a/tests/bson/bson-fromPHP_error-009.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): PackedArray cannot be serialized as root document ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -MongoDB\BSON\PackedArray cannot be serialized as a root document -===DONE=== diff --git a/tests/bson/bson-int64-001.phpt b/tests/bson/bson-int64-001.phpt index 1ad00a7a3..c265b1027 100644 --- a/tests/bson/bson-int64-001.phpt +++ b/tests/bson/bson-int64-001.phpt @@ -17,11 +17,11 @@ $tests = [ ]; foreach($tests as $test) { - $bson = MongoDB\BSON\fromPHP($test); - $testRoundtripped = MongoDB\BSON\toPHP($bson); - $bsonRoundtripped = MongoDB\BSON\fromPHP($testRoundtripped); - $json = MongoDB\BSON\toJSON($bson); - $jsonRoundtripped = MongoDB\BSON\toJSON($bsonRoundtripped); + $bson = MongoDB\BSON\Document::fromPHP($test); + $testRoundtripped = $bson->toPHP(); + $bsonRoundtripped = MongoDB\BSON\Document::fromPHP($testRoundtripped); + $json = $bson->toRelaxedExtendedJSON(); + $jsonRoundtripped = $bsonRoundtripped->toRelaxedExtendedJSON(); var_dump($test->int64 instanceof MongoDB\BSON\Int64); var_dump($testRoundtripped->int64 instanceof MongoDB\BSON\Int64); @@ -35,63 +35,24 @@ foreach($tests as $test) { ===DONE=== --EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s bool(true) bool(true) string(33) "{ "int64" : 9223372036854775807 }" string(33) "{ "int64" : 9223372036854775807 }" bool(true) - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s bool(true) bool(true) string(34) "{ "int64" : -9223372036854775808 }" string(34) "{ "int64" : -9223372036854775808 }" bool(true) - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s bool(true) bool(true) string(24) "{ "int64" : 2147483648 }" string(24) "{ "int64" : 2147483648 }" bool(true) - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s bool(true) bool(true) string(25) "{ "int64" : -2147483649 }" diff --git a/tests/bson/bson-int64-002.phpt b/tests/bson/bson-int64-002.phpt index 6bf7fecc4..2c17ee106 100644 --- a/tests/bson/bson-int64-002.phpt +++ b/tests/bson/bson-int64-002.phpt @@ -20,16 +20,13 @@ $tests = [ ]; foreach ($tests as $test) { - var_dump(MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON($test))); + var_dump(MongoDB\BSON\Document::fromJSON($test)->toPHP()); } ?> ===DONE=== --EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["max64"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -37,10 +34,6 @@ object(stdClass)#%d (%d) { string(19) "9223372036854775807" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["min64"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -48,10 +41,6 @@ object(stdClass)#%d (%d) { string(20) "-9223372036854775808" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["max32+1"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -59,10 +48,6 @@ object(stdClass)#%d (%d) { string(10) "2147483648" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["min32-1"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -70,28 +55,25 @@ object(stdClass)#%d (%d) { string(11) "-2147483649" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["max32"]=> - int(2147483647) + object(MongoDB\BSON\Int64)#%d (%d) { + ["integer"]=> + string(10) "2147483647" + } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["min32"]=> - int(-2147483648) + object(MongoDB\BSON\Int64)#%d (%d) { + ["integer"]=> + string(11) "-2147483648" + } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["zero"]=> - int(0) + object(MongoDB\BSON\Int64)#%d (%d) { + ["integer"]=> + string(1) "0" + } } ===DONE=== diff --git a/tests/bson/bson-toCanonicalJSON-001.phpt b/tests/bson/bson-toCanonicalJSON-001.phpt deleted file mode 100644 index b0383463d..000000000 --- a/tests/bson/bson-toCanonicalJSON-001.phpt +++ /dev/null @@ -1,85 +0,0 @@ ---TEST-- -MongoDB\BSON\toCanonicalExtendedJSON(): Encoding JSON ---FILE-- - null ], - [ 'boolean' => true ], - [ 'string' => 'foo' ], - [ 'integer' => 123 ], - [ 'double' => 1.0, ], - [ 'nan' => NAN ], - [ 'pos_inf' => INF ], - [ 'neg_inf' => -INF ], - [ 'array' => [ 'foo', 'bar' ]], - [ 'document' => [ 'foo' => 'bar' ]], -]; - -foreach ($tests as $value) { - $bson = MongoDB\BSON\fromPHP($value); - echo MongoDB\BSON\toCanonicalExtendedJSON($bson), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "null" : null } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "boolean" : true } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "string" : "foo" } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "integer" : { "$numberInt" : "123" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "double" : { "$numberDouble" : "1.0" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "nan" : { "$numberDouble" : "NaN" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "pos_inf" : { "$numberDouble" : "Infinity" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "neg_inf" : { "$numberDouble" : "-Infinity" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "array" : [ "foo", "bar" ] } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "document" : { "foo" : "bar" } } -===DONE=== diff --git a/tests/bson/bson-toCanonicalJSON-002.phpt b/tests/bson/bson-toCanonicalJSON-002.phpt deleted file mode 100644 index d9807ce2a..000000000 --- a/tests/bson/bson-toCanonicalJSON-002.phpt +++ /dev/null @@ -1,73 +0,0 @@ ---TEST-- -MongoDB\BSON\toCanonicalExtendedJSON(): Encoding extended JSON types ---FILE-- - new MongoDB\BSON\ObjectId('56315a7c6118fd1b920270b1') ], - [ 'binary' => new MongoDB\BSON\Binary('foo', MongoDB\BSON\Binary::TYPE_GENERIC) ], - [ 'date' => new MongoDB\BSON\UTCDateTime(1445990400000) ], - [ 'timestamp' => new MongoDB\BSON\Timestamp(1234, 5678) ], - [ 'regex' => new MongoDB\BSON\Regex('pattern', 'i') ], - [ 'code' => new MongoDB\BSON\Javascript('function() { return 1; }') ], - [ 'code_ws' => new MongoDB\BSON\Javascript('function() { return a; }', ['a' => 1]) ], - [ 'minkey' => new MongoDB\BSON\MinKey ], - [ 'maxkey' => new MongoDB\BSON\MaxKey ], -]; - -foreach ($tests as $value) { - $bson = MongoDB\BSON\fromPHP($value); - echo MongoDB\BSON\toCanonicalExtendedJSON($bson), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "_id" : { "$oid" : "56315a7c6118fd1b920270b1" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "binary" : { "$binary" : { "base64" : "Zm9v", "subType" : "00" } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "date" : { "$date" : { "$numberLong" : "1445990400000" } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "timestamp" : { "$timestamp" : { "t" : 5678, "i" : 1234 } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "regex" : { "$regularExpression" : { "pattern" : "pattern", "options" : "i" } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "code" : { "$code" : "function() { return 1; }" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "code_ws" : { "$code" : "function() { return a; }", "$scope" : { "a" : { "$numberInt" : "1" } } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "minkey" : { "$minKey" : 1 } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -{ "maxkey" : { "$maxKey" : 1 } } -===DONE=== diff --git a/tests/bson/bson-toCanonicalJSON_error-001.phpt b/tests/bson/bson-toCanonicalJSON_error-001.phpt deleted file mode 100644 index c92aafdf6..000000000 --- a/tests/bson/bson-toCanonicalJSON_error-001.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -MongoDB\BSON\toCanonicalExtendedJSON(): BSON decoding exceptions ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Reading document did not exhaust input buffer -===DONE=== diff --git a/tests/bson/bson-toCanonicalJSON_error-002.phpt b/tests/bson/bson-toCanonicalJSON_error-002.phpt deleted file mode 100644 index b4b0c131f..000000000 --- a/tests/bson/bson-toCanonicalJSON_error-002.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -MongoDB\BSON\toCanonicalExtendedJSON(): BSON decoding exceptions for malformed documents ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader -===DONE=== diff --git a/tests/bson/bson-toCanonicalJSON_error-003.phpt b/tests/bson/bson-toCanonicalJSON_error-003.phpt deleted file mode 100644 index 9cda07b86..000000000 --- a/tests/bson/bson-toCanonicalJSON_error-003.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -MongoDB\BSON\toCanonicalExtendedJSON(): BSON decoding exceptions for bson_as_canonical_json() failure ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string - -Deprecated: Function MongoDB\BSON\toCanonicalExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string -===DONE=== diff --git a/tests/bson/bson-toJSON-001.phpt b/tests/bson/bson-toJSON-001.phpt deleted file mode 100644 index 23ed10a7e..000000000 --- a/tests/bson/bson-toJSON-001.phpt +++ /dev/null @@ -1,88 +0,0 @@ ---TEST-- -MongoDB\BSON\toJSON(): Encoding JSON ---FILE-- - null ], - [ 'boolean' => true ], - [ 'string' => 'foo' ], - [ 'integer' => 123 ], - [ 'double' => 1.0, ], - /* Note: MongoDB\BSON\toJSON() does not properly handle NAN and INF values. - * MongoDB\BSON\toCanonicalExtendedJSON() or MongoDB\BSON\toRelaxedExtendedJSON() should be used - * instead. */ - [ 'nan' => NAN ], - [ 'pos_inf' => INF ], - [ 'neg_inf' => -INF ], - [ 'array' => [ 'foo', 'bar' ]], - [ 'document' => [ 'foo' => 'bar' ]], -]; - -foreach ($tests as $value) { - $bson = MongoDB\BSON\fromPHP($value); - echo MongoDB\BSON\toJSON($bson), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "null" : null } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "boolean" : true } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "string" : "foo" } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "integer" : 123 } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "double" : 1.0 } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "nan" : %r-?nan(\(ind\))?%r } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "pos_inf" : inf } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "neg_inf" : -inf } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "array" : [ "foo", "bar" ] } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "document" : { "foo" : "bar" } } -===DONE=== diff --git a/tests/bson/bson-toJSON-002.phpt b/tests/bson/bson-toJSON-002.phpt deleted file mode 100644 index 1d13e504a..000000000 --- a/tests/bson/bson-toJSON-002.phpt +++ /dev/null @@ -1,73 +0,0 @@ ---TEST-- -MongoDB\BSON\toJSON(): Encoding extended JSON types ---FILE-- - new MongoDB\BSON\ObjectId('56315a7c6118fd1b920270b1') ], - [ 'binary' => new MongoDB\BSON\Binary('foo', MongoDB\BSON\Binary::TYPE_GENERIC) ], - [ 'date' => new MongoDB\BSON\UTCDateTime(1445990400000) ], - [ 'timestamp' => new MongoDB\BSON\Timestamp(1234, 5678) ], - [ 'regex' => new MongoDB\BSON\Regex('pattern', 'i') ], - [ 'code' => new MongoDB\BSON\Javascript('function() { return 1; }') ], - [ 'code_ws' => new MongoDB\BSON\Javascript('function() { return a; }', ['a' => 1]) ], - [ 'minkey' => new MongoDB\BSON\MinKey ], - [ 'maxkey' => new MongoDB\BSON\MaxKey ], -]; - -foreach ($tests as $value) { - $bson = MongoDB\BSON\fromPHP($value); - echo MongoDB\BSON\toJSON($bson), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "_id" : { "$oid" : "56315a7c6118fd1b920270b1" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "binary" : { "$binary" : "Zm9v", "$type" : "00" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "date" : { "$date" : 1445990400000 } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "timestamp" : { "$timestamp" : { "t" : 5678, "i" : 1234 } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "regex" : { "$regex" : "pattern", "$options" : "i" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "code" : { "$code" : "function() { return 1; }" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "code_ws" : { "$code" : "function() { return a; }", "$scope" : { "a" : 1 } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "minkey" : { "$minKey" : 1 } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "maxkey" : { "$maxKey" : 1 } } -===DONE=== diff --git a/tests/bson/bson-toJSON-003.phpt b/tests/bson/bson-toJSON-003.phpt deleted file mode 100644 index afd10cf0c..000000000 --- a/tests/bson/bson-toJSON-003.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -MongoDB\BSON\toJSON(): Encoding JSON with duplicate field names ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -{ "foo" : "bar", "foo" : "baz" } -===DONE=== diff --git a/tests/bson/bson-toJSON_error-001.phpt b/tests/bson/bson-toJSON_error-001.phpt deleted file mode 100644 index 0175f8a5f..000000000 --- a/tests/bson/bson-toJSON_error-001.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -MongoDB\BSON\toJSON(): BSON decoding exceptions ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Reading document did not exhaust input buffer -===DONE=== diff --git a/tests/bson/bson-toJSON_error-002.phpt b/tests/bson/bson-toJSON_error-002.phpt deleted file mode 100644 index 6f1b76e19..000000000 --- a/tests/bson/bson-toJSON_error-002.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -MongoDB\BSON\toJSON(): BSON decoding exceptions for malformed documents ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader -===DONE=== diff --git a/tests/bson/bson-toJSON_error-003.phpt b/tests/bson/bson-toJSON_error-003.phpt deleted file mode 100644 index 8f85cdc5d..000000000 --- a/tests/bson/bson-toJSON_error-003.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -MongoDB\BSON\toJSON(): BSON decoding exceptions for bson_as_json() failure ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string -===DONE=== diff --git a/tests/bson/bson-toPHP-001.phpt b/tests/bson/bson-toPHP-001.phpt deleted file mode 100644 index 511c1b893..000000000 --- a/tests/bson/bson-toPHP-001.phpt +++ /dev/null @@ -1,111 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): __pclass must be both instantiatable and Persistable ---FILE-- -unserialized = true; - } -} - -// Create base64-encoded class names for __pclass field's binary data -$bMyAbstractDocument = base64_encode('MyAbstractDocument'); -$bMyDocument = base64_encode('MyDocument'); -$bUnserializable = base64_encode('MongoDB\BSON\Unserializable'); -$bPersistable = base64_encode('MongoDB\BSON\Persistable'); - -$tests = array( - '{ "foo": "yes", "__pclass": { "$binary": "' . $bMyAbstractDocument . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass": { "$binary": "' . $bMyDocument . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass": { "$binary": "' . $bUnserializable . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass": { "$binary": "' . $bPersistable . '", "$type": "44" } }', -); - -foreach ($tests as $test) { - echo $test, "\n"; - var_dump(MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON($test))); - echo "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -{ "foo": "yes", "__pclass": { "$binary": "TXlBYnN0cmFjdERvY3VtZW50", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(18) "MyAbstractDocument" - ["type"]=> - int(128) - } -} - -{ "foo": "yes", "__pclass": { "$binary": "TXlEb2N1bWVudA==", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(10) "MyDocument" - ["type"]=> - int(128) - } -} - -{ "foo": "yes", "__pclass": { "$binary": "TW9uZ29EQlxCU09OXFVuc2VyaWFsaXphYmxl", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(27) "MongoDB\BSON\Unserializable" - ["type"]=> - int(128) - } -} - -{ "foo": "yes", "__pclass": { "$binary": "TW9uZ29EQlxCU09OXFBlcnNpc3RhYmxl", "$type": "44" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(24) "MongoDB\BSON\Persistable" - ["type"]=> - int(68) - } -} - -===DONE=== diff --git a/tests/bson/bson-toPHP-002.phpt b/tests/bson/bson-toPHP-002.phpt deleted file mode 100644 index f088e06bf..000000000 --- a/tests/bson/bson-toPHP-002.phpt +++ /dev/null @@ -1,84 +0,0 @@ ---TEST-- -MongoDB\BSON\fromPHP(): Null type map values imply default behavior ---FILE-- -data = array( - 'list' => array(1, 2, 3), - 'map' => (object) array('foo' => 'bar'), - ); - } - - #[\ReturnTypeWillChange] - public function bsonSerialize() - { - return $this->data; - } - - public function bsonUnserialize(array $data): void - { - foreach (array('list', 'map') as $key) { - if (isset($data[$key])) { - $this->data[$key] = $data[$key]; - } - } - } -} - -$bson = MongoDB\BSON\fromPHP(new MyDocument); -echo "Test " . MongoDB\BSON\toJSON($bson) . "\n"; -hex_dump($bson); - -$typeMap = array( - 'array' => null, - 'document' => null, - 'root' => null, -); - -var_dump(MongoDB\BSON\toPHP($bson, $typeMap)); - -?> -===DONE=== - ---EXPECTF-- - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "__pclass" : { "$binary" : "TXlEb2N1bWVudA==", "$type" : "80" }, "list" : [ 1, 2, 3 ], "map" : { "foo" : "bar" } } - 0 : 55 00 00 00 05 5f 5f 70 63 6c 61 73 73 00 0a 00 [U....__pclass...] - 10 : 00 00 80 4d 79 44 6f 63 75 6d 65 6e 74 04 6c 69 [...MyDocument.li] - 20 : 73 74 00 1a 00 00 00 10 30 00 01 00 00 00 10 31 [st......0......1] - 30 : 00 02 00 00 00 10 32 00 03 00 00 00 00 03 6d 61 [......2.......ma] - 40 : 70 00 12 00 00 00 02 66 6f 6f 00 04 00 00 00 62 [p......foo.....b] - 50 : 61 72 00 00 00 [ar...] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(MyDocument)#%d (1) { - ["data"]=> - array(2) { - ["list"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["map"]=> - object(stdClass)#%d (1) { - ["foo"]=> - string(3) "bar" - } - } -} -===DONE=== diff --git a/tests/bson/bson-toPHP-003.phpt b/tests/bson/bson-toPHP-003.phpt deleted file mode 100644 index 302600f46..000000000 --- a/tests/bson/bson-toPHP-003.phpt +++ /dev/null @@ -1,571 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Tests from serialization specification ---FILE-- - $value) { - $this->$key = $value; - } - $this->unserialized = true; - } -} - -#[\AllowDynamicProperties] -class OurClass implements MongoDB\BSON\Persistable -{ - #[\ReturnTypeWillChange] - public function bsonSerialize() - { - // Not tested with this test, so return empty array - return array(); - } - - public function bsonUnserialize(array $data): void - { - foreach ($data as $key => $value) { - $this->$key = $value; - } - $this->unserialized = true; - } -} - -class TheirClass extends OurClass -{ -} - -// Create base64-encoded class names for __pclass field's binary data -$bMyClass = base64_encode('MyClass'); -$bYourClass = base64_encode('YourClass'); -$bOurClass = base64_encode('OurClass'); -$bTheirClass = base64_encode('TheirClass'); -$bInterface = base64_encode('MongoDB\BSON\Unserializable'); - -$testGroups = array( - array( - 'name' => 'DEFAULT TYPEMAP', - 'typemap' => array(), - 'tests' => array( - '{ "foo": "yes", "bar" : false }', - '{ "foo": "no", "array" : [ 5, 6 ] }', - '{ "foo": "no", "obj" : { "embedded" : 4.125 } }', - '{ "foo": "yes", "__pclass": "MyClass" }', - '{ "foo": "yes", "__pclass": { "$binary": "' . $bMyClass . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass": { "$binary": "' . $bYourClass . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass": { "$binary": "' . $bOurClass . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass": { "$binary": "' . $bYourClass . '", "$type": "44" } }', - ), - ), - array( - 'name' => 'NONEXISTING CLASS', - 'typemap' => array('root' => 'MissingClass'), - 'tests' => array( - '{ "foo": "yes" }', - ), - ), - array( - 'name' => 'DOES NOT IMPLEMENT UNSERIALIZABLE', - 'typemap' => array('root' => 'MyClass'), - 'tests' => array( - '{ "foo": "yes", "__pclass": { "$binary": "' . $bMyClass . '", "$type": "80" } }', - ), - ), - array( - 'name' => 'IS NOT A CONCRETE CLASS', - 'typemap' => array('root' => 'MongoDB\BSON\Unserializable'), - 'tests' => array( - '{ "foo": "yes" }', - ), - ), - array( - 'name' => 'IS NOT A CONCRETE CLASS VIA PCLASS', - 'typemap' => array('root' => 'YourClass'), - 'tests' => array( - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bInterface . '", "$type": "80" } }', - ), - ), - array( - 'name' => 'PCLASS OVERRIDES TYPEMAP (1)', - 'typemap' => array('root' => 'YourClass'), - 'tests' => array( - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bMyClass . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bOurClass . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bTheirClass . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bYourClass . '", "$type": "80" } }', - ), - ), - array( - 'name' => 'PCLASS OVERRIDES TYPEMAP (2)', - 'typemap' => array('root' => 'OurClass'), - 'tests' => array( - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bTheirClass . '", "$type": "80" } }', - ), - ), - array( - 'name' => 'OBJECTS AS ARRAY', - 'typemap' => array('root' => 'array', 'document' => 'array'), - 'tests' => array( - '{ "foo": "yes", "bar" : false }', - '{ "foo": "no", "array" : [ 5, 6 ] }', - '{ "foo": "no", "obj" : { "embedded" : 4.125 } }', - '{ "foo": "yes", "__pclass": "MyClass" }', - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bMyClass . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bOurClass . '", "$type": "80" } }', - ), - ), - array( - 'name' => 'OBJECTS AS STDCLASS', - 'typemap' => array('root' => 'object', 'document' => 'object'), - 'tests' => array( - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bMyClass . '", "$type": "80" } }', - '{ "foo": "yes", "__pclass" : { "$binary": "' . $bOurClass . '", "$type": "80" } }', - ), - ), -); - -foreach ($testGroups as $testGroup) { - printf("=== %s ===\n\n", $testGroup['name']); - - foreach ($testGroup['tests'] as $test) { - echo $test, "\n"; - - $bson = MongoDB\BSON\fromJSON($test); - try { - var_dump(MongoDB\BSON\toPHP($bson, $testGroup['typemap'])); - } catch (MongoDB\Driver\Exception\Exception $e) { - echo $e->getMessage(), "\n"; - } - - echo "\n"; - } - - echo "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -=== DEFAULT TYPEMAP === - -{ "foo": "yes", "bar" : false } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["bar"]=> - bool(false) -} - -{ "foo": "no", "array" : [ 5, 6 ] } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(2) "no" - ["array"]=> - array(2) { - [0]=> - int(5) - [1]=> - int(6) - } -} - -{ "foo": "no", "obj" : { "embedded" : 4.125 } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(2) "no" - ["obj"]=> - object(stdClass)#%d (1) { - ["embedded"]=> - float(4.125) - } -} - -{ "foo": "yes", "__pclass": "MyClass" } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - string(7) "MyClass" -} - -{ "foo": "yes", "__pclass": { "$binary": "TXlDbGFzcw==", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(7) "MyClass" - ["type"]=> - int(128) - } -} - -{ "foo": "yes", "__pclass": { "$binary": "WW91ckNsYXNz", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(9) "YourClass" - ["type"]=> - int(128) - } -} - -{ "foo": "yes", "__pclass": { "$binary": "T3VyQ2xhc3M=", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(OurClass)#%d (3) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(8) "OurClass" - ["type"]=> - int(128) - } - ["unserialized"]=> - bool(true) -} - -{ "foo": "yes", "__pclass": { "$binary": "WW91ckNsYXNz", "$type": "44" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(9) "YourClass" - ["type"]=> - int(68) - } -} - - -=== NONEXISTING CLASS === - -{ "foo": "yes" } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -Class MissingClass does not exist - - -=== DOES NOT IMPLEMENT UNSERIALIZABLE === - -{ "foo": "yes", "__pclass": { "$binary": "TXlDbGFzcw==", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -Class MyClass does not implement MongoDB\BSON\Unserializable - - -=== IS NOT A CONCRETE CLASS === - -{ "foo": "yes" } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -Interface MongoDB\BSON\Unserializable is not instantiatable - - -=== IS NOT A CONCRETE CLASS VIA PCLASS === - -{ "foo": "yes", "__pclass" : { "$binary": "TW9uZ29EQlxCU09OXFVuc2VyaWFsaXphYmxl", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(YourClass)#%d (3) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(27) "MongoDB\BSON\Unserializable" - ["type"]=> - int(128) - } - ["unserialized"]=> - bool(true) -} - - -=== PCLASS OVERRIDES TYPEMAP (1) === - -{ "foo": "yes", "__pclass" : { "$binary": "TXlDbGFzcw==", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(YourClass)#%d (3) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(7) "MyClass" - ["type"]=> - int(128) - } - ["unserialized"]=> - bool(true) -} - -{ "foo": "yes", "__pclass" : { "$binary": "T3VyQ2xhc3M=", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(OurClass)#%d (3) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(8) "OurClass" - ["type"]=> - int(128) - } - ["unserialized"]=> - bool(true) -} - -{ "foo": "yes", "__pclass" : { "$binary": "VGhlaXJDbGFzcw==", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(TheirClass)#%d (3) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(10) "TheirClass" - ["type"]=> - int(128) - } - ["unserialized"]=> - bool(true) -} - -{ "foo": "yes", "__pclass" : { "$binary": "WW91ckNsYXNz", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(YourClass)#%d (3) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(9) "YourClass" - ["type"]=> - int(128) - } - ["unserialized"]=> - bool(true) -} - - -=== PCLASS OVERRIDES TYPEMAP (2) === - -{ "foo": "yes", "__pclass" : { "$binary": "VGhlaXJDbGFzcw==", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(TheirClass)#%d (3) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(10) "TheirClass" - ["type"]=> - int(128) - } - ["unserialized"]=> - bool(true) -} - - -=== OBJECTS AS ARRAY === - -{ "foo": "yes", "bar" : false } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -array(2) { - ["foo"]=> - string(3) "yes" - ["bar"]=> - bool(false) -} - -{ "foo": "no", "array" : [ 5, 6 ] } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -array(2) { - ["foo"]=> - string(2) "no" - ["array"]=> - array(2) { - [0]=> - int(5) - [1]=> - int(6) - } -} - -{ "foo": "no", "obj" : { "embedded" : 4.125 } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -array(2) { - ["foo"]=> - string(2) "no" - ["obj"]=> - array(1) { - ["embedded"]=> - float(4.125) - } -} - -{ "foo": "yes", "__pclass": "MyClass" } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -array(2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - string(7) "MyClass" -} - -{ "foo": "yes", "__pclass" : { "$binary": "TXlDbGFzcw==", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -array(2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(7) "MyClass" - ["type"]=> - int(128) - } -} - -{ "foo": "yes", "__pclass" : { "$binary": "T3VyQ2xhc3M=", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -array(2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(8) "OurClass" - ["type"]=> - int(128) - } -} - - -=== OBJECTS AS STDCLASS === - -{ "foo": "yes", "__pclass" : { "$binary": "TXlDbGFzcw==", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(7) "MyClass" - ["type"]=> - int(128) - } -} - -{ "foo": "yes", "__pclass" : { "$binary": "T3VyQ2xhc3M=", "$type": "80" } } - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (2) { - ["foo"]=> - string(3) "yes" - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(8) "OurClass" - ["type"]=> - int(128) - } -} - - -===DONE=== diff --git a/tests/bson/bson-toPHP-004.phpt b/tests/bson/bson-toPHP-004.phpt deleted file mode 100644 index c8e5497f8..000000000 --- a/tests/bson/bson-toPHP-004.phpt +++ /dev/null @@ -1,705 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): BSON array keys should be disregarded during visitation ---FILE-- - [$value]]); - // Alter the key of the BSON array's first element - $bson[12] = '1'; - - var_dump(MongoDB\BSON\toPHP($bson)); - - /* Note that numeric indexes within the HashTable are not accessible without - * casting the object to an array. This is because the entries are only - * stored with numeric indexes and do not also have string equivalents, as - * might be created with zend_symtable_update(). This behavior is not unique - * to the driver, as `(object) ['foo']` would demonstrate the same issue. */ - var_dump(MongoDB\BSON\toPHP($bson, ['array' => 'object'])); - - var_dump(MongoDB\BSON\toPHP($bson, ['array' => 'MyArrayObject'])); - - echo "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Testing NULL visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - NULL - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - NULL - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - NULL - } - } -} - -Testing boolean visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - bool(true) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - bool(true) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - bool(true) - } - } -} - -Testing integer visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - int(1) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - int(1) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - int(1) - } - } -} - -Testing double visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - float(4.125) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - float(4.125) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - float(4.125) - } - } -} - -Testing string visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - string(3) "foo" - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - string(3) "foo" - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - string(3) "foo" - } - } -} - -Testing array visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - array(0) { - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(stdClass)#%d (0) { - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(0) { - } - } - } - } -} - -Testing stdClass visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(stdClass)#%d (0) { - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(stdClass)#%d (0) { - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(stdClass)#%d (0) { - } - } - } -} - -Testing MongoDB\BSON\Binary visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(3) "foo" - ["type"]=> - int(0) - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(3) "foo" - ["type"]=> - int(0) - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\Binary)#%d (2) { - ["data"]=> - string(3) "foo" - ["type"]=> - int(0) - } - } - } -} - -Testing MongoDB\BSON\Decimal128 visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\Decimal128)#%d (1) { - ["dec"]=> - string(4) "3.14" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\Decimal128)#%d (1) { - ["dec"]=> - string(4) "3.14" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\Decimal128)#%d (1) { - ["dec"]=> - string(4) "3.14" - } - } - } -} - -Testing MongoDB\BSON\Javascript visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\Javascript)#%d (2) { - ["code"]=> - string(12) "function(){}" - ["scope"]=> - NULL - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\Javascript)#%d (2) { - ["code"]=> - string(12) "function(){}" - ["scope"]=> - NULL - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\Javascript)#%d (2) { - ["code"]=> - string(12) "function(){}" - ["scope"]=> - NULL - } - } - } -} - -Testing MongoDB\BSON\MaxKey visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\MaxKey)#%d (0) { - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\MaxKey)#%d (0) { - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\MaxKey)#%d (0) { - } - } - } -} - -Testing MongoDB\BSON\MinKey visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\MinKey)#%d (0) { - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\MinKey)#%d (0) { - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\MinKey)#%d (0) { - } - } - } -} - -Testing MongoDB\BSON\ObjectId visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\ObjectId)#%d (1) { - ["oid"]=> - string(24) "586c18d86118fd6c9012dec1" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\ObjectId)#%d (1) { - ["oid"]=> - string(24) "586c18d86118fd6c9012dec1" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\ObjectId)#%d (1) { - ["oid"]=> - string(24) "586c18d86118fd6c9012dec1" - } - } - } -} - -Testing MongoDB\BSON\Regex visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\Regex)#%d (2) { - ["pattern"]=> - string(3) "foo" - ["flags"]=> - string(0) "" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\Regex)#%d (2) { - ["pattern"]=> - string(3) "foo" - ["flags"]=> - string(0) "" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\Regex)#%d (2) { - ["pattern"]=> - string(3) "foo" - ["flags"]=> - string(0) "" - } - } - } -} - -Testing MongoDB\BSON\Timestamp visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\Timestamp)#%d (2) { - ["increment"]=> - string(4) "1234" - ["timestamp"]=> - string(4) "5678" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\Timestamp)#%d (2) { - ["increment"]=> - string(4) "1234" - ["timestamp"]=> - string(4) "5678" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\Timestamp)#%d (2) { - ["increment"]=> - string(4) "1234" - ["timestamp"]=> - string(4) "5678" - } - } - } -} - -Testing MongoDB\BSON\UTCDateTime visitor function - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - array(1) { - [0]=> - object(MongoDB\BSON\UTCDateTime)#%d (1) { - ["milliseconds"]=> - string(13) "1483479256924" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(stdClass)#%d (1) { - ["0"]=> - object(MongoDB\BSON\UTCDateTime)#%d (1) { - ["milliseconds"]=> - string(13) "1483479256924" - } - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (1) { - ["x"]=> - object(MyArrayObject)#%d (1) { - ["storage":"ArrayObject":private]=> - array(1) { - [0]=> - object(MongoDB\BSON\UTCDateTime)#%d (1) { - ["milliseconds"]=> - string(13) "1483479256924" - } - } - } -} - -===DONE=== diff --git a/tests/bson/bson-toPHP-006.phpt b/tests/bson/bson-toPHP-006.phpt deleted file mode 100644 index 908a6a64c..000000000 --- a/tests/bson/bson-toPHP-006.phpt +++ /dev/null @@ -1,69 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Decodes Binary UUID types with any data length ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["foo"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(15) "0123456789abcde" - ["type"]=> - int(3) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["foo"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(17) "0123456789abcdefg" - ["type"]=> - int(3) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["foo"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(15) "0123456789abcde" - ["type"]=> - int(4) - } -} - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["foo"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(17) "0123456789abcdefg" - ["type"]=> - int(4) - } -} -===DONE=== diff --git a/tests/bson/bson-toPHP-008.phpt b/tests/bson/bson-toPHP-008.phpt deleted file mode 100644 index 1a4479bf4..000000000 --- a/tests/bson/bson-toPHP-008.phpt +++ /dev/null @@ -1,74 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Setting fieldPath typemaps for compound types with string keys ---FILE-- - 1, - 'array' => [1, 2, 3], - 'object' => ['string' => 'keys', 'for' => 'ever'] -] ); - -function fetch($bson, $typeMap = []) { - return \MongoDB\BSON\toPHP($bson, $typeMap); -} - - -echo "Default\n"; -$document = fetch($bson); -var_dump($document instanceof stdClass); -var_dump(is_array($document->array)); -var_dump($document->object instanceof stdClass); - -echo "\nSetting 'object' path to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object' => "MyArrayObject" -]]); -var_dump($document instanceof stdClass); -var_dump(is_array($document->array)); -var_dump($document->object instanceof MyArrayObject); - -echo "\nSetting 'object' and 'array' path to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object' => "MyArrayObject", - 'array' => "MyArrayObject", -]]); -var_dump($document instanceof stdClass); -var_dump($document->array instanceof MyArrayObject); -var_dump($document->object instanceof MyArrayObject); -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Default - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) - -Setting 'object' path to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) - -Setting 'object' and 'array' path to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -===DONE=== diff --git a/tests/bson/bson-toPHP-009.phpt b/tests/bson/bson-toPHP-009.phpt deleted file mode 100644 index 0166ad021..000000000 --- a/tests/bson/bson-toPHP-009.phpt +++ /dev/null @@ -1,97 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Setting fieldPath typemaps for compound types with numerical keys ---FILE-- - 1, - 'array0' => [0 => [ 4, 5, 6 ], 1 => [ 7, 8, 9 ]], - 'array1' => [1 => [ 4, 5, 6 ], 2 => [ 7, 8, 9 ]], -] ); - -function fetch($bson, $typeMap = []) { - return \MongoDB\BSON\toPHP($bson, $typeMap); -} - - -echo "Default\n"; -$document = fetch($bson); -var_dump($document instanceof stdClass); -var_dump(is_array($document->array0)); -var_dump(is_object($document->array1)); -var_dump($document->array1 instanceof stdClass); - -echo "\nSetting 'array0' path to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'array0' => "MyArrayObject" -]]); -var_dump($document instanceof stdClass); -var_dump(is_object($document->array0)); -var_dump($document->array0 instanceof MyArrayObject); - -echo "\nSetting 'array0.1' path to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'array0.1' => "MyArrayObject", -]]); -var_dump($document instanceof stdClass); -var_dump(is_array($document->array0)); -var_dump(is_array($document->array0[0])); -var_dump($document->array0[1] instanceof MyArrayObject); - -echo "\nSetting 'array1.1' path to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'array1.1' => "MyArrayObject", -]]); -var_dump($document instanceof stdClass); -var_dump(is_object($document->array1)); -var_dump($document->array1 instanceof stdClass); -$a = ((array) $document->array1); -var_dump($a[1] instanceof MyArrayObject); -var_dump(is_array($a[2])); -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s -Default - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'array0' path to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) - -Setting 'array0.1' path to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'array1.1' path to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -===DONE=== diff --git a/tests/bson/bson-toPHP-010.phpt b/tests/bson/bson-toPHP-010.phpt deleted file mode 100644 index fe360a237..000000000 --- a/tests/bson/bson-toPHP-010.phpt +++ /dev/null @@ -1,146 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Setting fieldPath typemaps for compound types with wildcard keys ---FILE-- - 1, - 'array' => [0 => [ 4, 5, 6 ], 1 => [ 7, 8, 9 ]], - 'object' => ['one' => [ 4, 5, 6 ], 'two' => [ 7, 8, 9 ]], -] ); - -function fetch($bson, $typeMap = []) { - return \MongoDB\BSON\toPHP($bson, $typeMap); -} - - -echo "\nSetting 'array.$' path to 'MyWildcardArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'array.$' => "MyWildcardArrayObject" -]]); -var_dump($document instanceof stdClass); -var_dump(is_array($document->array)); -var_dump($document->array[0] instanceof MyWildcardArrayObject); -var_dump($document->array[1] instanceof MyWildcardArrayObject); - -echo "\nSetting 'array.1' to 'MyArrayObject' and 'array.$' path to 'MyWildcardArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'array.1' => "MyArrayObject", - 'array.$' => "MyWildcardArrayObject" -]]); -var_dump($document instanceof stdClass); -var_dump(is_array($document->array)); -var_dump($document->array[0] instanceof MyWildcardArrayObject); -var_dump($document->array[1] instanceof MyArrayObject); - -echo "\nSetting 'array.$' to 'MyWildcardArrayObject' and 'array.1' path to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'array.$' => "MyWildcardArrayObject", - 'array.1' => "MyArrayObject" -]]); -var_dump($document instanceof stdClass); -var_dump(is_array($document->array)); -var_dump($document->array[0] instanceof MyWildcardArrayObject); -var_dump($document->array[1] instanceof MyWildcardArrayObject); - - -echo "\nSetting 'object.$' path to 'MyWildcardArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object.$' => "MyWildcardArrayObject" -]]); -var_dump($document instanceof stdClass); -var_dump(is_object($document->object)); -var_dump($document->object->one instanceof MyWildcardArrayObject); -var_dump($document->object->two instanceof MyWildcardArrayObject); - -echo "\nSetting 'object.two' to 'MyArrayObject' and 'object.$' path to 'MyWildcardArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object.two' => "MyArrayObject", - 'object.$' => "MyWildcardArrayObject" -]]); -var_dump($document instanceof stdClass); -var_dump(is_object($document->object)); -var_dump($document->object->one instanceof MyWildcardArrayObject); -var_dump($document->object->two instanceof MyArrayObject); - -echo "\nSetting 'object.$' to 'MyWildcardArrayObject' and 'object.one' path to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object.$' => "MyWildcardArrayObject", - 'object.one' => "MyArrayObject" -]]); -var_dump($document instanceof stdClass); -var_dump(is_object($document->object)); -var_dump($document->object->one instanceof MyWildcardArrayObject); -var_dump($document->object->two instanceof MyWildcardArrayObject); -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Setting 'array.$' path to 'MyWildcardArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'array.1' to 'MyArrayObject' and 'array.$' path to 'MyWildcardArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'array.$' to 'MyWildcardArrayObject' and 'array.1' path to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'object.$' path to 'MyWildcardArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'object.two' to 'MyArrayObject' and 'object.$' path to 'MyWildcardArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'object.$' to 'MyWildcardArrayObject' and 'object.one' path to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) -===DONE=== diff --git a/tests/bson/bson-toPHP-011.phpt b/tests/bson/bson-toPHP-011.phpt deleted file mode 100644 index dc1e4655c..000000000 --- a/tests/bson/bson-toPHP-011.phpt +++ /dev/null @@ -1,150 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Setting fieldPath typemaps for compound types with wildcard keys (nested) ---FILE-- - 1, - 'object' => [ - 'parent1' => [ - 'child1' => [ 1, 2, 3 ], - 'child2' => [ 4, 5, 6 ], - ], - 'parent2' => [ - 'child1' => [ 7, 8, 9 ], - 'child2' => [ 10, 11, 12 ], - ], - ], -] ); - -function fetch($bson, $typeMap = []) { - return \MongoDB\BSON\toPHP($bson, $typeMap); -} - - -echo "\nSetting 'object.$.child1' path to 'MyWildcardArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object.$.child1' => "MyWildcardArrayObject" -]]); -var_dump($document->object->parent1 instanceof stdClass); -var_dump($document->object->parent1->child1 instanceof MyWildcardArrayObject); -var_dump(is_array($document->object->parent1->child2)); -var_dump($document->object->parent2 instanceof stdClass); -var_dump($document->object->parent2->child1 instanceof MyWildcardArrayObject); -var_dump(is_array($document->object->parent2->child2)); - -echo "\nSetting 'object.parent1.$' path to 'MyWildcardArrayObject' and 'object.parent2.child1' to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object.parent1.$' => "MyWildcardArrayObject", - 'object.parent2.child1' => "MyArrayObject", -]]); -var_dump($document->object->parent1 instanceof stdClass); -var_dump($document->object->parent1->child1 instanceof MyWildcardArrayObject); -var_dump($document->object->parent1->child2 instanceof MyWildcardArrayObject); -var_dump($document->object->parent2 instanceof stdClass); -var_dump($document->object->parent2->child1 instanceof MyArrayObject); -var_dump(is_array($document->object->parent2->child2)); - -echo "\nSetting 'object.parent1.$' path to 'MyWildcardArrayObject' and 'object.$.$' to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object.parent1.$' => "MyWildcardArrayObject", - 'object.$.$' => "MyArrayObject", -]]); -var_dump($document->object->parent1 instanceof stdClass); -var_dump($document->object->parent1->child1 instanceof MyWildcardArrayObject); -var_dump($document->object->parent1->child2 instanceof MyWildcardArrayObject); -var_dump($document->object->parent2 instanceof stdClass); -var_dump($document->object->parent2->child1 instanceof MyArrayObject); -var_dump($document->object->parent2->child2 instanceof MyArrayObject); - -echo "\nSetting 'object.parent1.$' path to 'MyWildcardArrayObject' and 'object.$.child2' to 'MyArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object.parent1.child1' => "MyWildcardArrayObject", - 'object.$.child2' => "MyArrayObject", -]]); -var_dump($document->object->parent1 instanceof stdClass); -var_dump($document->object->parent1->child1 instanceof MyWildcardArrayObject); -var_dump($document->object->parent1->child2 instanceof MyArrayObject); -var_dump($document->object->parent2 instanceof stdClass); -var_dump(is_array($document->object->parent2->child1)); -var_dump($document->object->parent2->child2 instanceof MyArrayObject); - -echo "\nSetting 'object.parent1.child2 path to 'MyArrayObject' and 'object.$.$' to 'MyWildcardArrayObject'\n"; -$document = fetch($bson, ["fieldPaths" => [ - 'object.parent1.child2' => "MyArrayObject", - 'object.$.$' => "MyWildcardArrayObject", -]]); -var_dump($document->object->parent1 instanceof stdClass); -var_dump($document->object->parent1->child1 instanceof MyWildcardArrayObject); -var_dump($document->object->parent1->child2 instanceof MyArrayObject); -var_dump($document->object->parent2 instanceof stdClass); -var_dump($document->object->parent2->child1 instanceof MyWildcardArrayObject); -var_dump($document->object->parent2->child2 instanceof MyWildcardArrayObject); -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Setting 'object.$.child1' path to 'MyWildcardArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'object.parent1.$' path to 'MyWildcardArrayObject' and 'object.parent2.child1' to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'object.parent1.$' path to 'MyWildcardArrayObject' and 'object.$.$' to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'object.parent1.$' path to 'MyWildcardArrayObject' and 'object.$.child2' to 'MyArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) - -Setting 'object.parent1.child2 path to 'MyArrayObject' and 'object.$.$' to 'MyWildcardArrayObject' - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -===DONE=== diff --git a/tests/bson/bson-toPHP-012.phpt b/tests/bson/bson-toPHP-012.phpt deleted file mode 100644 index ae04f1826..000000000 --- a/tests/bson/bson-toPHP-012.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Decoding BSON with duplicate field names ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "baz" -} -===DONE=== diff --git a/tests/bson/bson-toPHP-013.phpt b/tests/bson/bson-toPHP-013.phpt deleted file mode 100644 index b1992279b..000000000 --- a/tests/bson/bson-toPHP-013.phpt +++ /dev/null @@ -1,119 +0,0 @@ ---TEST-- -Uninstantiatable classes are ignored when processing __pclass ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(12) "MissingClass" - ["type"]=> - int(128) - } - ["y"]=> - int(1) - } -} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(18) "MyAbstractDocument" - ["type"]=> - int(128) - } - ["y"]=> - int(1) - } -} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(10) "MyDocument" - ["type"]=> - int(128) - } - ["y"]=> - int(1) - } -} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(7) "MyTrait" - ["type"]=> - int(128) - } - ["y"]=> - int(1) - } -} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(24) "MongoDB\BSON\Persistable" - ["type"]=> - int(128) - } - ["y"]=> - int(1) - } -} -===DONE=== diff --git a/tests/bson/bson-toPHP-014.phpt b/tests/bson/bson-toPHP-014.phpt deleted file mode 100644 index 8fd6265c1..000000000 --- a/tests/bson/bson-toPHP-014.phpt +++ /dev/null @@ -1,66 +0,0 @@ ---TEST-- -Uninstantiatable classes are ignored when processing __pclass (enums) ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(6) "MyEnum" - ["type"]=> - int(128) - } - ["name"]=> - string(1) "A" - } -} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(12) "MyBackedEnum" - ["type"]=> - int(128) - } - ["name"]=> - string(1) "A" - ["value"]=> - int(1) - } -} -===DONE=== diff --git a/tests/bson/bson-toPHP-015.phpt b/tests/bson/bson-toPHP-015.phpt deleted file mode 100644 index 22c851b37..000000000 --- a/tests/bson/bson-toPHP-015.phpt +++ /dev/null @@ -1,394 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Type map values can override Persistable behavior ---DESCRIPTION-- -The special type map values below always override Persistable behavior. Note -that an Unserializable class name will only override Persistable behavior if -the class specified in __pclass does not exist or does not implement -MongoDB\BSON\Persistable. ---FILE-- -data = array( - 'list' => array(1, 2, 3), - 'map' => (object) array('foo' => 'bar'), - ); - } - - #[\ReturnTypeWillChange] - public function bsonSerialize() - { - return $this->data; - } - - public function bsonUnserialize(array $data): void - { - foreach (array('list', 'map') as $key) { - if (isset($data[$key])) { - $this->data[$key] = $data[$key]; - } - } - } -} - -$tests = [ - 'root document as object' => [ - new MyDocument, - ['root' => 'object'], - ], - 'root document as array' => [ - new MyDocument, - ['root' => 'array'], - ], - 'root document as bson' => [ - new MyDocument, - ['root' => 'bson'], - ], - 'embedded document as object' => [ - ['embedded' => new MyDocument], - ['document' => 'object'], - ], - 'embedded document as array' => [ - ['embedded' => new MyDocument], - ['document' => 'array'], - ], - 'embedded document as bson' => [ - ['embedded' => new MyDocument], - ['document' => 'bson'], - ], - 'fieldPath document as object' => [ - ['embedded' => new MyDocument], - ['fieldPaths' => ['embedded' => 'object']], - ], - 'fieldPath document as array' => [ - ['embedded' => new MyDocument], - ['fieldPaths' => ['embedded' => 'array']], - ], - 'fieldPath document as bson' => [ - ['embedded' => new MyDocument], - ['fieldPaths' => ['embedded' => 'bson']], - ], -]; - -foreach ($tests as $test => [$document, $typeMap]) { - echo "Test ", $test, "\n"; - - $bson = MongoDB\BSON\fromPHP($document); - var_dump(MongoDB\BSON\toPHP($bson, $typeMap)); -} - -?> -===DONE=== - ---EXPECTF-- -Test root document as object - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(10) "MyDocument" - ["type"]=> - int(128) - } - ["list"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["map"]=> - object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "bar" - } -} -Test root document as array - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -array(3) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(10) "MyDocument" - ["type"]=> - int(128) - } - ["list"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["map"]=> - object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "bar" - } -} -Test root document as bson - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(116) "VQAAAAVfX3BjbGFzcwAKAAAAgE15RG9jdW1lbnQEbGlzdAAaAAAAEDAAAQAAABAxAAIAAAAQMgADAAAAAANtYXAAEgAAAAJmb28ABAAAAGJhcgAAAA==" - ["value"]=> - object(MyDocument)#%d (%d) { - ["data"]=> - array(2) { - ["list"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "GgAAABAwAAEAAAAQMQACAAAAEDIAAwAAAAA=" - ["value"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - } - ["map"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(24) "EgAAAAJmb28ABAAAAGJhcgAA" - ["value"]=> - object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "bar" - } - } - } - } -} -Test embedded document as object - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["embedded"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(10) "MyDocument" - ["type"]=> - int(128) - } - ["list"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["map"]=> - object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "bar" - } - } -} -Test embedded document as array - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["embedded"]=> - array(3) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(10) "MyDocument" - ["type"]=> - int(128) - } - ["list"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["map"]=> - array(1) { - ["foo"]=> - string(3) "bar" - } - } -} -Test embedded document as bson - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["embedded"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(116) "VQAAAAVfX3BjbGFzcwAKAAAAgE15RG9jdW1lbnQEbGlzdAAaAAAAEDAAAQAAABAxAAIAAAAQMgADAAAAAANtYXAAEgAAAAJmb28ABAAAAGJhcgAAAA==" - ["value"]=> - object(MyDocument)#%d (%d) { - ["data"]=> - array(2) { - ["list"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "GgAAABAwAAEAAAAQMQACAAAAEDIAAwAAAAA=" - ["value"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - } - ["map"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(24) "EgAAAAJmb28ABAAAAGJhcgAA" - ["value"]=> - object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "bar" - } - } - } - } - } -} -Test fieldPath document as object - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["embedded"]=> - object(stdClass)#%d (%d) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(10) "MyDocument" - ["type"]=> - int(128) - } - ["list"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["map"]=> - object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "bar" - } - } -} -Test fieldPath document as array - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["embedded"]=> - array(3) { - ["__pclass"]=> - object(MongoDB\BSON\Binary)#%d (%d) { - ["data"]=> - string(10) "MyDocument" - ["type"]=> - int(128) - } - ["list"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["map"]=> - object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "bar" - } - } -} -Test fieldPath document as bson - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["embedded"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(116) "VQAAAAVfX3BjbGFzcwAKAAAAgE15RG9jdW1lbnQEbGlzdAAaAAAAEDAAAQAAABAxAAIAAAAQMgADAAAAAANtYXAAEgAAAAJmb28ABAAAAGJhcgAAAA==" - ["value"]=> - object(MyDocument)#%d (%d) { - ["data"]=> - array(2) { - ["list"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "GgAAABAwAAEAAAAQMQACAAAAEDIAAwAAAAA=" - ["value"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - } - ["map"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(24) "EgAAAAJmb28ABAAAAGJhcgAA" - ["value"]=> - object(stdClass)#%d (%d) { - ["foo"]=> - string(3) "bar" - } - } - } - } - } -} -===DONE=== diff --git a/tests/bson/bson-toPHP-016.phpt b/tests/bson/bson-toPHP-016.phpt deleted file mode 100644 index efa3fbdd3..000000000 --- a/tests/bson/bson-toPHP-016.phpt +++ /dev/null @@ -1,419 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Decoding with raw BSON type ---FILE-- - 1, - 'object' => [ - 'parent1' => [ - 'child1' => [ 1, 2, 3 ], - 'child2' => [ 4, 5, 6 ], - ], - 'parent2' => [ - 'child1' => [ 7, 8, 9 ], - 'child2' => [ 10, 11, 12 ], - ], - ], -]); - -$tests = [ - 'Root as BSON' => ['root' => 'bson'], - 'Arrays as BSON' => ['array' => 'bson'], - 'Documents as BSON' => ['document' => 'bson'], - 'Field path as BSON' => ['fieldPaths' => ['object.parent1.child1' => 'bson', 'object.parent2' => 'bson']], - 'Non-complex field ignores BSON typemap element' => ['fieldPaths' => ['_id' => 'bson']], -]; - -foreach ($tests as $name => $typeMap) { - echo "\n" . $name . "\n"; - var_dump(MongoDB\BSON\toPHP($bson, $typeMap)); -} -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Root as BSON - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(256) "%a" - ["value"]=> - object(stdClass)#%d (%d) { - ["_id"]=> - int(1) - ["object"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(228) "%a" - ["value"]=> - object(stdClass)#%d (%d) { - ["parent1"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(100) "%a" - ["value"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - } - ["child2"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(4) - [1]=> - int(5) - [2]=> - int(6) - } - } - } - } - ["parent2"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(100) "%a" - ["value"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - } - ["child2"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(10) - [1]=> - int(11) - [2]=> - int(12) - } - } - } - } - } - } - } -} - -Arrays as BSON - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["_id"]=> - int(1) - ["object"]=> - object(stdClass)#%d (%d) { - ["parent1"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - } - ["child2"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(4) - [1]=> - int(5) - [2]=> - int(6) - } - } - } - ["parent2"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - } - ["child2"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(10) - [1]=> - int(11) - [2]=> - int(12) - } - } - } - } -} - -Documents as BSON - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["_id"]=> - int(1) - ["object"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(228) "%a" - ["value"]=> - object(stdClass)#%d (%d) { - ["parent1"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(100) "%a" - ["value"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - } - ["child2"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(4) - [1]=> - int(5) - [2]=> - int(6) - } - } - } - } - ["parent2"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(100) "%a" - ["value"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - } - ["child2"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(10) - [1]=> - int(11) - [2]=> - int(12) - } - } - } - } - } - } -} - -Field path as BSON - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["_id"]=> - int(1) - ["object"]=> - object(stdClass)#%d (%d) { - ["parent1"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - } - ["child2"]=> - array(3) { - [0]=> - int(4) - [1]=> - int(5) - [2]=> - int(6) - } - } - ["parent2"]=> - object(MongoDB\BSON\Document)#%d (%d) { - ["data"]=> - string(100) "%a" - ["value"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - } - ["child2"]=> - object(MongoDB\BSON\PackedArray)#%d (%d) { - ["data"]=> - string(36) "%a" - ["value"]=> - array(3) { - [0]=> - int(10) - [1]=> - int(11) - [2]=> - int(12) - } - } - } - } - } -} - -Non-complex field ignores BSON typemap element - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["_id"]=> - int(1) - ["object"]=> - object(stdClass)#%d (%d) { - ["parent1"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["child2"]=> - array(3) { - [0]=> - int(4) - [1]=> - int(5) - [2]=> - int(6) - } - } - ["parent2"]=> - object(stdClass)#%d (%d) { - ["child1"]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - ["child2"]=> - array(3) { - [0]=> - int(10) - [1]=> - int(11) - [2]=> - int(12) - } - } - } -} -===DONE=== diff --git a/tests/bson/bson-toPHP-017.phpt b/tests/bson/bson-toPHP-017.phpt deleted file mode 100644 index 5c8d6f72b..000000000 --- a/tests/bson/bson-toPHP-017.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): int64 values are returned as int scalars ---FILE-- - 123, - // Using a 32-bit value to simplify testing - 'int64' => new MongoDB\BSON\Int64(123), -]); - -var_dump(MongoDB\BSON\toPHP($bson)); - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["int32"]=> - int(123) - ["int64"]=> - int(123) -} -===DONE=== diff --git a/tests/bson/bson-toPHP_error-001.phpt b/tests/bson/bson-toPHP_error-001.phpt deleted file mode 100644 index 0049d4ed0..000000000 --- a/tests/bson/bson-toPHP_error-001.phpt +++ /dev/null @@ -1,203 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Type map classes must be instantiatable and implement Unserializable ---FILE-- - $class], - ['document' => $class], - ['root' => $class], - ['fieldPaths' => ['x' => $class]], - ]; - - foreach ($typeMaps as $typeMap) { - printf("Test typeMap: %s\n", json_encode($typeMap)); - - echo throws(function() use ($typeMap) { - MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{}'), $typeMap); - }, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n\n"; - } -} - -?> -===DONE=== - ---EXPECTF-- -Test typeMap: {"array":"MissingClass"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MissingClass does not exist - -Test typeMap: {"document":"MissingClass"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MissingClass does not exist - -Test typeMap: {"root":"MissingClass"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MissingClass does not exist - -Test typeMap: {"fieldPaths":{"x":"MissingClass"}} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MissingClass does not exist - -Test typeMap: {"array":"MyAbstractDocument"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MyAbstractDocument is not instantiatable - -Test typeMap: {"document":"MyAbstractDocument"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MyAbstractDocument is not instantiatable - -Test typeMap: {"root":"MyAbstractDocument"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MyAbstractDocument is not instantiatable - -Test typeMap: {"fieldPaths":{"x":"MyAbstractDocument"}} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MyAbstractDocument is not instantiatable - -Test typeMap: {"array":"MyDocument"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MyDocument does not implement MongoDB\BSON\Unserializable - -Test typeMap: {"document":"MyDocument"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MyDocument does not implement MongoDB\BSON\Unserializable - -Test typeMap: {"root":"MyDocument"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MyDocument does not implement MongoDB\BSON\Unserializable - -Test typeMap: {"fieldPaths":{"x":"MyDocument"}} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Class MyDocument does not implement MongoDB\BSON\Unserializable - -Test typeMap: {"array":"MyTrait"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Trait MyTrait is not instantiatable - -Test typeMap: {"document":"MyTrait"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Trait MyTrait is not instantiatable - -Test typeMap: {"root":"MyTrait"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Trait MyTrait is not instantiatable - -Test typeMap: {"fieldPaths":{"x":"MyTrait"}} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Trait MyTrait is not instantiatable - -Test typeMap: {"array":"MongoDB\\BSON\\Unserializable"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Interface MongoDB\BSON\Unserializable is not instantiatable - -Test typeMap: {"document":"MongoDB\\BSON\\Unserializable"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Interface MongoDB\BSON\Unserializable is not instantiatable - -Test typeMap: {"root":"MongoDB\\BSON\\Unserializable"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Interface MongoDB\BSON\Unserializable is not instantiatable - -Test typeMap: {"fieldPaths":{"x":"MongoDB\\BSON\\Unserializable"}} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Interface MongoDB\BSON\Unserializable is not instantiatable - -===DONE=== diff --git a/tests/bson/bson-toPHP_error-002.phpt b/tests/bson/bson-toPHP_error-002.phpt deleted file mode 100644 index 675584ba6..000000000 --- a/tests/bson/bson-toPHP_error-002.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): BSON decoding exceptions ---FILE-- -getMessage(), "\n"; - } -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -Could not read document from BSON reader - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -Reading document did not exhaust input buffer -===DONE=== diff --git a/tests/bson/bson-toPHP_error-003.phpt b/tests/bson/bson-toPHP_error-003.phpt deleted file mode 100644 index 1ea084322..000000000 --- a/tests/bson/bson-toPHP_error-003.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): BSON decoding exceptions for malformed documents ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader -===DONE=== diff --git a/tests/bson/bson-toPHP_error-004.phpt b/tests/bson/bson-toPHP_error-004.phpt deleted file mode 100644 index f6fa07f8f..000000000 --- a/tests/bson/bson-toPHP_error-004.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): BSON decoding exceptions for bson_iter_visit_all() failure ---FILE-- - 'bar'])), - // Invalid UTF-8 character in embedded document's field name - str_replace('INVALID!', "INVALID\xFE", MongoDB\BSON\fromPHP(['foo' => ['INVALID!' => 'bar']])), - // Invalid UTF-8 character in string within array field - str_replace('INVALID!', "INVALID\xFE", MongoDB\BSON\fromPHP(['foo' => ['INVALID!']])), - /* Note: we don't use a three-character string in the underflow case, as - * the 4-byte string length and payload (i.e. three characters + null byte) - * coincidentally satisfy the expected size for an 8-byte double. We also - * don't use a four-character string, since its null byte would be - * interpreted as the document terminator. The actual document terminator - * would then remain in the buffer and trigger a "did not exhaust" error. - */ - pack('VCa*xVa*xx', 17, 1, 'foo', 3, 'ab'), // Invalid field type (underflow) - pack('VCa*xVa*xx', 20, 1, 'foo', 6, 'abcde'), // Invalid field type (overflow) -); - -foreach ($tests as $bson) { - echo throws(function() use ($bson) { - MongoDB\BSON\toPHP($bson); - }, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path '' at offset 4 - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path 'foo' at offset 0 - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path 'foo' at offset 0 - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path '' at offset 9 - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected unknown BSON type 0x65 for field path "". Are you using the latest driver? -===DONE=== diff --git a/tests/bson/bson-toPHP_error-005.phpt b/tests/bson/bson-toPHP_error-005.phpt deleted file mode 100644 index 76c756c53..000000000 --- a/tests/bson/bson-toPHP_error-005.phpt +++ /dev/null @@ -1,55 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Field path values with bson_iter_visit_all() failures ---FILE-- - ['INVALID!' => 'bar'] ])), - str_replace('INVALID!', "INVALID\xFE", MongoDB\BSON\fromPHP(['foo' => ['bar' => ['INVALID!' => 'bar']]])), - str_replace('INVALID!', "INVALID\xFE", MongoDB\BSON\fromPHP(['foo' => ['bar' => ['INVALID!']]])), - str_replace('INVALID!', "INVALID\xFE", MongoDB\BSON\fromPHP(['foo' => [['INVALID!']]])), - str_replace('INVALID!', "INVALID\xFE", MongoDB\BSON\fromPHP(['foo' => [ ['bar' => ['INVALID!' => 'bar']], 6 ]])), -); - -foreach ($tests as $bson) { - echo throws(function() use ($bson) { - MongoDB\BSON\toPHP($bson); - }, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path 'foo' at offset 0 - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path 'foo.bar' at offset 0 - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path 'foo.bar' at offset 0 - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path 'foo.0' at offset 0 - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected corrupt BSON data for field path 'foo.0.bar' at offset 0 -===DONE=== diff --git a/tests/bson/bson-toPHP_error-006.phpt b/tests/bson/bson-toPHP_error-006.phpt deleted file mode 100644 index 866a638ba..000000000 --- a/tests/bson/bson-toPHP_error-006.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): BSON decoding exception with unknown BSON type ---FILE-- - ["cruel" => "world"]]); -$bson[15] = chr(0x42); - -echo throws(function() use ($bson) { - MongoDB\BSON\toPHP($bson); -}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Detected unknown BSON type 0x42 for field path "hello.cruel". Are you using the latest driver? -===DONE=== diff --git a/tests/bson/bson-toPHP_error-007.phpt b/tests/bson/bson-toPHP_error-007.phpt deleted file mode 100644 index bfaf1f36c..000000000 --- a/tests/bson/bson-toPHP_error-007.phpt +++ /dev/null @@ -1,108 +0,0 @@ ---TEST-- -MongoDB\BSON\toPHP(): Type map classes must be instantiatable and implement Unserializable (enums) ---FILE-- - $class], - ['document' => $class], - ['root' => $class], - ['fieldPaths' => ['x' => $class]], - ]; - - foreach ($typeMaps as $typeMap) { - printf("Test typeMap: %s\n", json_encode($typeMap)); - - echo throws(function() use ($typeMap) { - MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{}'), $typeMap); - }, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n\n"; - } -} - -?> -===DONE=== - ---EXPECTF-- -Test typeMap: {"array":"MyEnum"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Enum MyEnum is not instantiatable - -Test typeMap: {"document":"MyEnum"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Enum MyEnum is not instantiatable - -Test typeMap: {"root":"MyEnum"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Enum MyEnum is not instantiatable - -Test typeMap: {"fieldPaths":{"x":"MyEnum"}} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Enum MyEnum is not instantiatable - -Test typeMap: {"array":"MyBackedEnum"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Enum MyBackedEnum is not instantiatable - -Test typeMap: {"document":"MyBackedEnum"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Enum MyBackedEnum is not instantiatable - -Test typeMap: {"root":"MyBackedEnum"} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Enum MyBackedEnum is not instantiatable - -Test typeMap: {"fieldPaths":{"x":"MyBackedEnum"}} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Enum MyBackedEnum is not instantiatable - -===DONE=== diff --git a/tests/bson/bson-toRelaxedJSON-001.phpt b/tests/bson/bson-toRelaxedJSON-001.phpt deleted file mode 100644 index 9806fc598..000000000 --- a/tests/bson/bson-toRelaxedJSON-001.phpt +++ /dev/null @@ -1,85 +0,0 @@ ---TEST-- -MongoDB\BSON\toRelaxedExtendedJSON(): Encoding JSON ---FILE-- - null ], - [ 'boolean' => true ], - [ 'string' => 'foo' ], - [ 'integer' => 123 ], - [ 'double' => 1.0, ], - [ 'nan' => NAN ], - [ 'pos_inf' => INF ], - [ 'neg_inf' => -INF ], - [ 'array' => [ 'foo', 'bar' ]], - [ 'document' => [ 'foo' => 'bar' ]], -]; - -foreach ($tests as $value) { - $bson = MongoDB\BSON\fromPHP($value); - echo MongoDB\BSON\toRelaxedExtendedJSON($bson), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "null" : null } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "boolean" : true } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "string" : "foo" } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "integer" : 123 } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "double" : 1.0 } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "nan" : { "$numberDouble" : "NaN" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "pos_inf" : { "$numberDouble" : "Infinity" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "neg_inf" : { "$numberDouble" : "-Infinity" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "array" : [ "foo", "bar" ] } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "document" : { "foo" : "bar" } } -===DONE=== diff --git a/tests/bson/bson-toRelaxedJSON-002.phpt b/tests/bson/bson-toRelaxedJSON-002.phpt deleted file mode 100644 index a324d1580..000000000 --- a/tests/bson/bson-toRelaxedJSON-002.phpt +++ /dev/null @@ -1,73 +0,0 @@ ---TEST-- -MongoDB\BSON\toRelaxedExtendedJSON(): Encoding extended JSON types ---FILE-- - new MongoDB\BSON\ObjectId('56315a7c6118fd1b920270b1') ], - [ 'binary' => new MongoDB\BSON\Binary('foo', MongoDB\BSON\Binary::TYPE_GENERIC) ], - [ 'date' => new MongoDB\BSON\UTCDateTime(1445990400000) ], - [ 'timestamp' => new MongoDB\BSON\Timestamp(1234, 5678) ], - [ 'regex' => new MongoDB\BSON\Regex('pattern', 'i') ], - [ 'code' => new MongoDB\BSON\Javascript('function() { return 1; }') ], - [ 'code_ws' => new MongoDB\BSON\Javascript('function() { return a; }', ['a' => 1]) ], - [ 'minkey' => new MongoDB\BSON\MinKey ], - [ 'maxkey' => new MongoDB\BSON\MaxKey ], -]; - -foreach ($tests as $value) { - $bson = MongoDB\BSON\fromPHP($value); - echo MongoDB\BSON\toRelaxedExtendedJSON($bson), "\n"; -} - -?> -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "_id" : { "$oid" : "56315a7c6118fd1b920270b1" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "binary" : { "$binary" : { "base64" : "Zm9v", "subType" : "00" } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "date" : { "$date" : "2015-10-28T00:00:00Z" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "timestamp" : { "$timestamp" : { "t" : 5678, "i" : 1234 } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "regex" : { "$regularExpression" : { "pattern" : "pattern", "options" : "i" } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "code" : { "$code" : "function() { return 1; }" } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "code_ws" : { "$code" : "function() { return a; }", "$scope" : { "a" : 1 } } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "minkey" : { "$minKey" : 1 } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -{ "maxkey" : { "$maxKey" : 1 } } -===DONE=== diff --git a/tests/bson/bson-toRelaxedJSON_error-001.phpt b/tests/bson/bson-toRelaxedJSON_error-001.phpt deleted file mode 100644 index 3472df766..000000000 --- a/tests/bson/bson-toRelaxedJSON_error-001.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -MongoDB\BSON\toRelaxedExtendedJSON(): BSON decoding exceptions ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Reading document did not exhaust input buffer -===DONE=== diff --git a/tests/bson/bson-toRelaxedJSON_error-002.phpt b/tests/bson/bson-toRelaxedJSON_error-002.phpt deleted file mode 100644 index 8abcce3db..000000000 --- a/tests/bson/bson-toRelaxedJSON_error-002.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -MongoDB\BSON\toRelaxedExtendedJSON(): BSON decoding exceptions for malformed documents ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not read document from BSON reader -===DONE=== diff --git a/tests/bson/bson-toRelaxedJSON_error-003.phpt b/tests/bson/bson-toRelaxedJSON_error-003.phpt deleted file mode 100644 index c428a9854..000000000 --- a/tests/bson/bson-toRelaxedJSON_error-003.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -MongoDB\BSON\toRelaxedExtendedJSON(): BSON decoding exceptions for bson_as_canonical_json() failure ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string - -Deprecated: Function MongoDB\BSON\toRelaxedExtendedJSON() is deprecated in %s -OK: Got MongoDB\Driver\Exception\UnexpectedValueException -Could not convert BSON document to a JSON string -===DONE=== diff --git a/tests/bson/bug0544.phpt b/tests/bson/bug0544.phpt index 57c1c0481..7626264d4 100644 --- a/tests/bson/bug0544.phpt +++ b/tests/bson/bug0544.phpt @@ -19,13 +19,12 @@ $tests = [ ]; foreach ($tests as $test) { - $bson = MongoDB\BSON\fromPHP($test); + $bson = MongoDB\BSON\Document::fromPHP($test); /* Note: Although libbson can parse the extended JSON representation for * 64-bit integers (i.e. "$numberLong"), it currently prints them as * doubles (see: https://jira.mongodb.org/browse/CDRIVER-375). */ - printf("Test %s\n", MongoDB\BSON\toJSON($bson)); - hex_dump($bson); - var_dump(MongoDB\BSON\toPHP($bson)); + printf("Test %s\n", json_encode($test)); + var_dump($bson); echo "\n"; } @@ -33,107 +32,92 @@ foreach ($tests as $test) { ===DONE=== --EXPECTF-- -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : -2147483648 } - 0 : 0c 00 00 00 10 78 00 00 00 00 80 00 [.....x......] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - int(-2147483648) +Test {"x":-2147483648} +object(MongoDB\BSON\Document)#%d (%d) { + ["data"]=> + string(16) "DAAAABB4AAAAAIAA" + ["value"]=> + object(stdClass)#%d (%d) { + ["x"]=> + int(-2147483648) + } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : 2147483647 } - 0 : 0c 00 00 00 10 78 00 ff ff ff 7f 00 [.....x......] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - int(2147483647) +Test {"x":2147483647} +object(MongoDB\BSON\Document)#%d (%d) { + ["data"]=> + string(16) "DAAAABB4AP///38A" + ["value"]=> + object(stdClass)#%d (%d) { + ["x"]=> + int(2147483647) + } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : -4294967294 } - 0 : 10 00 00 00 12 78 00 02 00 00 00 ff ff ff ff 00 [.....x..........] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - int(-4294967294) +Test {"x":-4294967294} +object(MongoDB\BSON\Document)#%d (%d) { + ["data"]=> + string(24) "EAAAABJ4AAIAAAD/////AA==" + ["value"]=> + object(stdClass)#%d (%d) { + ["x"]=> + int(-4294967294) + } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : 4294967294 } - 0 : 10 00 00 00 12 78 00 fe ff ff ff 00 00 00 00 00 [.....x..........] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - int(4294967294) +Test {"x":4294967294} +object(MongoDB\BSON\Document)#%d (%d) { + ["data"]=> + string(24) "EAAAABJ4AP7///8AAAAAAA==" + ["value"]=> + object(stdClass)#%d (%d) { + ["x"]=> + int(4294967294) + } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : -4294967295 } - 0 : 10 00 00 00 12 78 00 01 00 00 00 ff ff ff ff 00 [.....x..........] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - int(-4294967295) +Test {"x":-4294967295} +object(MongoDB\BSON\Document)#%d (%d) { + ["data"]=> + string(24) "EAAAABJ4AAEAAAD/////AA==" + ["value"]=> + object(stdClass)#%d (%d) { + ["x"]=> + int(-4294967295) + } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : 4294967295 } - 0 : 10 00 00 00 12 78 00 ff ff ff ff 00 00 00 00 00 [.....x..........] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - int(4294967295) +Test {"x":4294967295} +object(MongoDB\BSON\Document)#%d (%d) { + ["data"]=> + string(24) "EAAAABJ4AP////8AAAAAAA==" + ["value"]=> + object(stdClass)#%d (%d) { + ["x"]=> + int(4294967295) + } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : -9223372036854775807 } - 0 : 10 00 00 00 12 78 00 01 00 00 00 00 00 00 80 00 [.....x..........] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - int(-9223372036854775807) +Test {"x":-9223372036854775807} +object(MongoDB\BSON\Document)#%d (%d) { + ["data"]=> + string(24) "EAAAABJ4AAEAAAAAAACAAA==" + ["value"]=> + object(stdClass)#%d (%d) { + ["x"]=> + int(-9223372036854775807) + } } - -Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s -Test { "x" : 9223372036854775807 } - 0 : 10 00 00 00 12 78 00 ff ff ff ff ff ff ff 7f 00 [.....x..........] - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s -object(stdClass)#%d (%d) { - ["x"]=> - int(9223372036854775807) +Test {"x":9223372036854775807} +object(MongoDB\BSON\Document)#%d (%d) { + ["data"]=> + string(24) "EAAAABJ4AP////////9/AA==" + ["value"]=> + object(stdClass)#%d (%d) { + ["x"]=> + int(9223372036854775807) + } } ===DONE=== diff --git a/tests/bson/bug0592.phpt b/tests/bson/bug0592.phpt index 8ed6f2080..a4349f712 100644 --- a/tests/bson/bug0592.phpt +++ b/tests/bson/bug0592.phpt @@ -22,12 +22,7 @@ $tests = [ foreach ($tests as $json) { printf("Test %s\n", $json); - try { - $encoded = MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON($json)); - var_dump( $encoded ); - } catch ( MongoDB\Driver\Exception\InvalidArgumentException $e ) { - echo "MongoDB\Driver\Exception\InvalidArgumentException: ", $e->getMessage(), "\n"; - } + var_dump(MongoDB\BSON\Document::fromJSON($json)->toPHP()); echo "\n"; } @@ -36,30 +31,24 @@ foreach ($tests as $json) { --EXPECTF-- Test { "x": { "$numberLong": "-2147483648" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["x"]=> - int(-2147483648) + object(MongoDB\BSON\Int64)#%d (%d) { + ["integer"]=> + string(11) "-2147483648" + } } Test { "x": { "$numberLong": "2147483647" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["x"]=> - int(2147483647) + object(MongoDB\BSON\Int64)#%d (%d) { + ["integer"]=> + string(10) "2147483647" + } } Test { "x": { "$numberLong": "4294967294" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["x"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -69,10 +58,6 @@ object(stdClass)#%d (%d) { } Test { "x": { "$numberLong": "4294967295" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["x"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -82,10 +67,6 @@ object(stdClass)#%d (%d) { } Test { "x": { "$numberLong": "9223372036854775807" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["x"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -95,30 +76,24 @@ object(stdClass)#%d (%d) { } Test { "longFieldName": { "$numberLong": "-2147483648" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["longFieldName"]=> - int(-2147483648) + object(MongoDB\BSON\Int64)#%d (%d) { + ["integer"]=> + string(11) "-2147483648" + } } Test { "longFieldName": { "$numberLong": "2147483647" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["longFieldName"]=> - int(2147483647) + object(MongoDB\BSON\Int64)#%d (%d) { + ["integer"]=> + string(10) "2147483647" + } } Test { "longFieldName": { "$numberLong": "4294967294" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["longFieldName"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -128,10 +103,6 @@ object(stdClass)#%d (%d) { } Test { "longFieldName": { "$numberLong": "4294967295" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["longFieldName"]=> object(MongoDB\BSON\Int64)#%d (%d) { @@ -141,10 +112,6 @@ object(stdClass)#%d (%d) { } Test { "longFieldName": { "$numberLong": "9223372036854775807" }} - -Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s - -Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s object(stdClass)#%d (%d) { ["longFieldName"]=> object(MongoDB\BSON\Int64)#%d (%d) {