Commit Graph

52 Commits

Author SHA1 Message Date
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
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
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
Andreas Braun
a520c00959 PHPC-1629: Check if write concern is valid during construction and unserialization 2020-05-29 14:47:24 +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
Jeremy Mikola
366dcbe7d2 PHPC-1411: Prefer integer types for wtimeout when possible
For serialization, 64-bit wtimeout values will always be encoded as strings for portability. Debug output and bsonSerialize() can always use integers on 64-bit platforms and can fall back to strings and Int64 objects on 32-bit platforms, respectively.
2019-12-19 06:51:06 +01:00
Andreas Braun
a54fbcd8c0 PHPC-1411: Emit warning when truncating 64-bit value 2019-12-19 06:50:41 +01:00
Andreas Braun
cdff70faf6 PHPC-1411: Accept 64-bit integers for wTimeoutMS 2019-12-19 06:50:41 +01:00
Andreas Braun
7a98fb6f52 Fix wrong grammar in comment 2019-10-18 13:45:13 -04:00
Andreas Braun
0437e98453 PHPC-1281: Add Serializable support for MongoDB\Driver\WriteConcern 2019-10-18 13:23:48 -04:00
Derick Rethans
9cbb01a860 PHPC-1206: Add __set_state() support for ReadPreference 2018-10-19 16:26:17 -04:00
Derick Rethans
b03d1714c4 PHPC-1206: Add __set_state() support for WriteConcern 2018-10-19 16:26:17 -04:00
Derick Rethans
d92d94224a PHPC-850: var_export() support for WriteConcern 2018-06-07 17:08:22 +01:00
Derick Rethans
98e583b738 PHPC-1175: Fixed test cases due to changes in variable type names in PHP 7.3 2018-05-17 16:18:27 +02: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
Jeremy Mikola
03af904b5d PHPC-1071: Report class name for unexpected object values
This only updates exceptions where object types are entirely unexpected. For instance, options that expect a BSON document (i.e. array or object) need not use this macro, as any object would be accepted.
2017-12-15 11:23:44 -05:00
Derick Rethans
f609ac7d35 PHPC-1037: Upgrade bundled libmongoc and libbson to 1.9 2017-11-21 14:47:12 +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
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
4d8e3e304a PHPC-595: Throw exception if wtimeout > INT32_MAX
This also defines a compatility constant for printing phongo_long, which may vary by PHP version and architecture.
2016-02-29 12:43:34 -05:00
Jeremy Mikola
2fa57d7d05 Regression test for extending final classes 2016-02-09 15:25:14 -05:00
Derick Rethans
9aad2931d3 Fixed test case, where PHP 5 and PHP 7 call the type differently 2015-12-18 16:15:40 +00:00
Jeremy Mikola
dcbf5ae6ba PHPC-428: Remove support for WriteConcern fsync option 2015-09-23 11:47:53 -04:00
Jeremy Mikola
44a85b5438 PHPC-427: Do not set WC journal/fsync to false for NULL args 2015-09-22 14:10:50 -04:00
Jeremy Mikola
380aee31c9 Additional tests for WriteConcern debug handler 2015-09-22 14:07:23 -04:00
Jeremy Mikola
a6932d59e0 PHPC-423: WriteConcern should report default "w" option as null 2015-09-22 14:07:23 -04:00
Jeremy Mikola
3f8b851556 PHPC-426: WC ctor should throw for invalid $w and $wtimeout args 2015-09-22 14:06:37 -04:00
Jeremy Mikola
7757f1118a PHPC-425: WC ctor should accept int/string $w args w/o casting 2015-09-22 14:06:37 -04:00
Jeremy Mikola
6b5e7cacb2 WriteConcern ctor error test doesn't need EXPECTF 2015-09-22 14:06:37 -04:00
Jeremy Mikola
33e91fa908 Use throws() helper function in WriteConcern ctor error test 2015-09-22 14:06:37 -04:00
Jeremy Mikola
4e01486cd6 PHPC-418: Getters for WriteConcern properties 2015-09-16 17:37:14 -04:00
Jeremy Mikola
106ee84693 Rename WriteConcern tests 2015-09-16 17:37:14 -04:00
Derick Rethans
b31ad7c271 PHPC-129: Split out WriteConcern constructor error test
The error test should be skipped for HHVM, since it currently has inconsistent error handling.
2015-08-05 21:11:16 -04:00
Jeremy Mikola
998c85bfba PHPC-179: Show unset journal/fsync as null in WriteConcern debug handler 2015-05-04 14:24:37 -04:00
Hannes Magnusson
227e7842cb Use absolute paths in skipifs too 2015-03-25 14:08:39 -07:00
Hannes Magnusson
1cce49d21c Use absolute paths on in tests so they can run easier on windows 2015-03-25 13:32:09 -07:00
Jeremy Mikola
70715516b5 PHPC-177: Include all fields in WriteConcern debug output
This mainly removes logic where no fields were included in the debug output if "w" was equal to MONGOC_WRITE_CONCERN_W_DEFAULT.

Although the "wmajority" boolean exists, we can still report the actual "w" value, which will be sent to the server.
2015-03-13 02:26:51 -04:00
Jeremy Mikola
a56939385e Remove unnecessary Manager and apply EXPECTF patterns 2015-03-12 19:48:01 -04:00
Hannes Magnusson
4acca269c2 This is a Manager, not MongoClient 2015-02-19 13:59:50 -08:00
Hannes Magnusson
a9823e706f Ignore me. Trim trailing space
This has been annoying me for a long time, especially the '<?php '
2015-02-19 13:57:58 -08:00
Hannes Magnusson
4b8ef30fd1 PHPC-138: var_dump()ing WriteConcern 2015-01-27 11:56:15 -08:00
Hannes Magnusson
bb5f45c313 PHPC-118: Use MongoDB\Driver namespace for phongo 2014-12-30 14:58:33 -08:00