Commit Graph

26 Commits

Author SHA1 Message Date
levon80999
d6b2fd6077 PHPC-1929: ReadConcern tests need not exhaustively test each constant (#1360) 2022-09-27 14:42:42 +04:00
Andreas Braun
6ffcb1f1dd PHPC-2117: Test on PHP 8.2 (#1340)
* Test on PHP 8.2

* Fix tests relating to dynamic properties

* Fix tests failing due to different __set_state output

* Duplicate clone test without dynamic properties for PHP >= 8.2
2022-08-04 08:53:25 +02:00
Andreas Braun
6887226d34 PHPC-1709: Add typing information to arginfo (#1337)
* Add missing macros for declaring arguments

* Add macros to define disabled constructor and __wakeup

* Define arginfo via stubs for BSON classes

* Declare tentative return types in interfaces

* Add correct return type for __set_state methods

* Generate class entries for BSON classes

* Declare Binary class constants in stub file

* Use stubs in exception classes

* Add stubs for monitoring classes

* Fix wrong JsonSerializable class in BSON stubs

* Disable declaration-after-statement

This is necessary to let the generated arginfo files compile

* Use stubs for driver classes

* Fix deprecation messages in tests

* Add missing macro

* Fix tests relying on value injection

* Parse parameters in disabled constructor/wakup function

* Add note about arginfo files to contribution docs

* Add GitHub action to check generated arginfo files

* PHPC-2115: Use DateTimeInterface in UTCDateTime constructor signature

* Don't install mongodb extension in GitHub actions workflows

* Change indentation in stub files

* Use individual #if conditions for each stub method

* Make disabled constructor/wakeup methods static

* Fix bulkWrite parameter name

* Use %d to match property count in tests

* Ensure all classes with disabled serialisation declare __wakeup
2022-08-03 08:42:07 +02:00
Andreas Braun
b27fa4d019 PHPC-1965 Re-enable PHP 8.1 build on GH Actions (#1258)
* Re-enable PHP 8.1 build on GH Actions

* Work around different error wording in PHP 8.1

* Limit failing tests to PHP < 8.1

* Add tests for PHPC-1839 for PHP >= 8.1
2021-09-07 08:18:08 +02:00
Jeremy Mikola
bd10948415 PHPC-1849: Handle deprecation of Serializable in PHP 8.1 (#1246)
* Add __serialize and __unserialize methods to Serializable classes

These methods will be used on PHP 7.4+ when available. Implementing them is required to suppress a deprecation notice on PHP 8.1+.

This commit also renames is_debug parameter for get_properties_hash utility functions (and related macros) to more accurately reflect its purpose of allocating a new HashTable instead of using an internal props table.

* Explicitly handle serialize output in php_phongo_cursorid_get_properties_hash

* Explicitly handle serialize output in php_phongo_writeconcern_get_properties_hash

* Note maxStalenessSeconds handling in php_phongo_readpreference_get_properties_hash

* CursorId should always serialize id as string
2021-08-31 22:13:11 -04:00
Jeremy Mikola
ac4935338a PHPC-1761: Snapshot Reads (#1243)
* Bump libmongoc to 1.19-dev

* PHPC-1890: Constant for ReadConcern snapshot level

* Move Manager::startSession() error test and delete obsolete test

The deleted error test was redundant. It was originally created in ca4c52eb1c to work around changes in PHP 8, but 60febd0f28 subsequently reintroduced a portable version of the test case.

Also adds missing SKIPIF to startSession test.

* PHPC-1889: Session snapshot option

* PHPC-1875: Session with snapshot=true cannot perform writes

* PHPC-1876: Session with snapshot=true requires MongoDB 5.0+
2021-08-04 19:11:33 -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
60febd0f28 PHPC-1699: Ensure all argument parsing errors throw InvalidArgumentException (#1173)
Co-authored-by: Jeremy Mikola <jmikola@gmail.com>
2020-10-28 08:20:32 +01:00
Jeremy Mikola
ca4c52eb1c PHPC-1692: Test suite fixes for PHP 8 2020-10-13 15:24:02 +02:00
Jeremy Mikola
354bcc9441 PHPC-1598: Fix get_gc handlers for classes with get_properties
The ReadConcern, ReadPreference, WriteConcern, and BSON classes have no properties beyond pointers to libmongoc/libbson structs; however, all of these classes use get_properties to report fields for var_export (PHPC-850, PHPC-460).

The standard get_gc handler defers to get_properties to collect other zvals for GC inspection. This is problematic for the aforementioned get_properties handlers, since a HashTable of zvals intended for debugging will be returned and those properties will already be freed by our free_object handler (via FREE_HASHTABLE).

Having each class define its own get_gc handler is the first step to fixing this issue. The BSON classes already defined their own get_gc handlers, but erroneously returned the internally cached properties directly.

The second step to fixing this issue is ensuring that get_gc delegates to zend_std_get_properties, as is done in various PHP core extensions. Doing so ensures that we do not leak other zvals that may be assigned as public properties by the application (covered by the second regression test), since zend_std_get_properties will return those for GC inspection.
2020-05-19 18:14:53 -04:00
Andreas Braun
1d04171fe0 PHPC-1281: Add Serializable support for MongoDB\Driver\ReadConcern 2019-10-18 13:23:48 -04:00
Derick Rethans
4a568e300a PHPC-1206: Add __set_state() support for ReadConcern 2018-10-19 16:26:17 -04:00
Derick Rethans
a801b8cb34 PHPC-850: var_export() support for ReadConcern 2018-06-07 17:08:22 +01:00
Jeremy Mikola
0b200dda09 PHPC-1133: Remove unused includes in SKIPIF and FILE sections 2018-02-27 09:48:25 -05:00
Jeremy Mikola
05c83bdef2 PHPC-1132: Remove HHVM checks in test suite 2018-02-27 09:48:25 -05:00
Derick Rethans
5c7fa9bf61 PHPC-1078: Create constant for available read concern level 2018-01-04 15:50:59 +00:00
Jeremy Mikola
7158ed16e8 PHPC-976: Add more test cases for default read and write concerns 2017-08-17 12:11:41 -04:00
Jeremy Mikola
f581777126 PHPC-976: RC and WC isDefault() tests don't need a server 2017-08-17 12:11:41 -04:00
Jeremy Mikola
31aa04b746 PHPC-976: isDefault() method for read and write concerns 2017-07-11 16:56:19 -04:00
Jeremy Mikola
a267e05eb8 Comprehensive tests for RC, RP, and WC debug output and BSON serialization 2016-09-26 10:53:21 -04:00
Jeremy Mikola
6d46d62577 PHPC-359: Ensure RP tag sets serialize as documents 2016-09-26 10:53:21 -04:00
Jeremy Mikola
97a26a18e7 Remove unnecessary SKIPIFs from extends tests 2016-09-21 16:32:39 -04:00
Derick Rethans
8f9e6c8c53 PHPC-498: ReadPreference, ReadConcern, and WriteConcern should serialize to BSON 2016-09-19 20:33:14 +01:00
Jeremy Mikola
2fa57d7d05 Regression test for extending final classes 2016-02-09 15:25:14 -05:00
Derick Rethans
8e61bb78a5 Skip and fix test for HHVM with ReadConcerns 2016-01-12 16:43:03 +00:00
Jeremy Mikola
92348caffc PHPC-448: Implement ReadConcern class 2015-12-11 14:44:59 -05:00