Commit Graph

15 Commits

Author SHA1 Message Date
Andreas Braun
a237193eca BSON class implementations (#1387)
* Extract bson to json conversion logic

* PHPC-326: Add class to represent raw BSON document

* PHPC-326: Add class to represent raw BSON array

* Typemaps now support raw BSON type

* Short-circuit encoding of BSON zvals

* PHPC-324: Add BSONIterator class

* Polyfill zend_array_is_list on PHP < 8.1

* Add offset accessors to BSON classes

* Add more tests around iterators and fetching offsets

* Remove compare handler for BSONIterator

* Rename BSONArray to ArrayList

* Rename BSONDocument to Document

* Rename BSONIterator to Iterator

* Implement Document::fromBSONString

* Test BSON document in bson-corpus tests

* Fix ArrayList handling of BSON arrays with wrong keys

* Address code review for bson-corpus tests

* Address code review in ArrayList

* Address code review for Document

* Address code review for Iterator

* Allow BSON iterators to be rewound

* Address code review in tests

* Fix comment explaining php_phongo_bson_append_object

* Remove obsolete php_phongo_bson_append_zval

* More review changes to tests

* Return base64 encoded data when debugging BSON classes

* Allow serialisation of Document and ArrayList

* Add test for iterating past the end of a structure

* Update exception message to contain class name

* Make BSON pclass handling test more complete

* Fix wrong handling of type map in nested structures

* Ensure objects are backed by actual memory

* Validate UTF-8 BSON data before returning it

* Allow ArrayList::toPHP() to accept a different root type map

* Ignore null return type for invalid BSON iterators on PHP < 8

* Throw when calling get on non-existing BSON offsets

* Remove unnecessary length from serialised output

* Refactor names around type map handling

* Use short array syntax in new tests

* Improve test descriptions

* Restructure BSON iterator tests

* Expand BSON class serialisation tests

* Throw exception when iterator is exhausted

The previous method relied on the type system of PHP to throw an exception when accessing the key of an exhausted iterator, but this does not work on non-debug versions of PHP.

* Update test description

* Rename ArrayList class to PackedArray
2022-12-16 08:48:09 +01:00
Jeremy Mikola
e2ba4103d5 PHPC-1918: Update Javascript and Symbol BSON corpus tests (#1256)
Synced with mongodb/specifications@c4cc034e29
2021-08-26 10:57:36 -04:00
Andreas Braun
deead9687e PHPC-1716 Allow configuring server API version in manager (#1204)
* Introduce MongoDB\Driver\ServerApi

* Accept serverApi driver option

* Introduce create_test_manager factory to create manager

A centralised entry point is required to inject the API_VERSION env variable later.

* Add build variant to test with requireApiVersion=true

* Fix wrong configuration for auth variable

This changed when migrating from our own scripts to drivers-evergreen-tools and was not updated properly, causing all tests to run with auth disabled.

* Declare ZEND_PARSE_PARAMETERS_NONE macro

This macro is missing on PHP < 7.3

* Remove duplicated API param storage

* Add missing semicolons

* Add ZEND_PARSE_PARAMETERS_NON_EX macro

* Extract error handling functionality to separate macros

* Throw if internal mongoc_server_api_t is already initialised

* Use imported namespaces in tools file

* Fix type info for reflection

* Use American English spelling

* Only use typed serialize signature on PHP 8+

* Update PHONGO_PARSE_PARAMETERS_NONE macro for PHP < 7.3

* Remove usage of ZEND_STRL within zend_hash_str_add

This causes compile failures on PHP < 7.3 that I have yet to understand.

* Fix errors in new PHONGO_PARSE_PARAMETERS macros
2021-03-26 15:43:48 +01:00
Andreas Braun
9f854a43f7 PHPC-1681 Support parsing $uuid as extended JSON representation for subtype 4 binary (#1208)
* Update to latest version of libmongoc

* Support parse error tests for binary types

* Sync bson-corpus spec tests for binary
2021-03-26 10:04:18 +01:00
Jeremy Mikola
c81330c077 Remove trailing space in generated comments 2020-07-23 11:36:09 -04:00
Jeremy Mikola
96f97f8d43 PHPC-1653: Resync BSON corpus spec tests
Syncs tests with mongodb/specifications@1713439515. Includes tests for PHPC-1655 and PHPC-1652.

Adds logic to canonicalize $numberDouble values, which allows previously skipped tests to pass. This was noticed because SPEC-1537 changed the description of these tests and they were no loner skipped by convert-bson-corpus-tests.php.
2020-07-23 11:36:09 -04:00
Andreas Braun
5fd52869e2 PHPC-889: Validate Javascript scope on BSON decoding 2019-10-25 11:25:28 +02:00
Jeremy Mikola
0f07beb7c5 PHPC-1211: Update SKIPIFs for 32-bit platforms 2018-06-22 13:07:33 -04:00
Derick Rethans
d1563898e6 Disable tests for Int64 type that can not work on a 32-bit platform 2018-01-11 14:57:02 +00:00
Derick Rethans
d981fff0d3 PHPC-1065: Enable BSON corpus tests for deprecated types 2018-01-03 10:31:52 +00:00
Jeremy Mikola
58324ad627 PHPC-992: Rename extended JSON functions to[Canonical|Relaxed]ExtendedJSON() 2017-08-10 12:56:47 -04:00
Jeremy Mikola
98d3e02094 PHPC-941: Update BSON corpus tests for canonical and relaxed JSON
Generated from mongodb/specifications@f01908343f

Expected test failures are now defined in the generator script and have been updated for libbson changes.
2017-07-28 13:30:07 -04:00
Jeremy Mikola
0fd4ab4258 PHPC-977: Update BSON corpous tests
Generated from mongodb/specifications@7b5793561e
2017-07-11 11:39:44 -04:00
Derick Rethans
611b9f2fc7 PHPC-941: Use toExtendedJSON() for BSON corpus tests 2017-04-07 14:54:54 -04:00
Jeremy Mikola
56f3a9da74 PHPC-714: Script to convert BSON corpus tests 2017-01-13 15:05:41 -05:00