Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ axes:
display_name: "latest"
variables:
VERSION: "latest"
- id: "5.0"
display_name: "5.0"
variables:
VERSION: "5.0"
- id: "4.4"
display_name: "4.4"
variables:
Expand Down Expand Up @@ -626,7 +630,7 @@ buildvariants:
- name: "test-atlas-data-lake"

- matrix_name: "test-versioned-api"
matrix_spec: { "php-edge-versions": "latest-stable", "versions": "latest", "driver-versions": "latest" }
matrix_spec: { "php-edge-versions": "latest-stable", "versions": ["5.0", "latest"], "driver-versions": "latest" }
display_name: "Versioned API - ${versions}"
run_on: rhel70
tasks:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ jobs:
topology:
- "server"
include:
- os: "ubuntu-20.04"
php-version: "8.0"
mongodb-version: "5.0"
driver-version: "mongodb/mongo-php-driver@master"
topology: "server"
- os: "ubuntu-20.04"
php-version: "8.0"
mongodb-version: "4.4"
Expand Down
2 changes: 0 additions & 2 deletions tests/SpecTests/TransactionsSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class TransactionsSpecTest extends FunctionalTestCase
'transactions/mongos-recovery-token: commitTransaction retry fails on new mongos' => 'isMaster failpoints cannot be disabled',
'transactions/pin-mongos: remain pinned after non-transient error on commit' => 'Blocked on SPEC-1320',
'transactions/pin-mongos: unpin after transient error within a transaction and commit' => 'isMaster failpoints cannot be disabled',
'transactions/errors-client: Client side error in command starting transaction' => 'PHPLIB-665',
'transactions/errors-client: Client side error when transaction is in progress' => 'PHPLIB-665',
];

public function setUp() : void
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/command-monitoring/find.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@
]
},
{
"description": "A successful find event with a getmore and the server kills the cursor",
"description": "A successful find event with a getmore and the server kills the cursor (<= 4.4)",
"ignore_if_server_version_less_than": "3.1",
"ignore_if_server_version_greater_than": "4.4",
"ignore_if_topology_type": [
"sharded"
],
Expand Down
26 changes: 14 additions & 12 deletions tests/SpecTests/transactions/errors-client.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
"object": "session0"
},
{
"name": "insertOne",
"name": "updateOne",
"object": "collection",
"arguments": {
"session": "session0",
"document": {
"_id": {
".": "."
}
"filter": {
"_id": 1
},
"update": {
"x": 1
}
},
"error": true
Expand Down Expand Up @@ -60,22 +61,23 @@
"arguments": {
"session": "session0",
"document": {
"_id": 4
"_id": 1
}
},
"result": {
"insertedId": 4
"insertedId": 1
}
},
{
"name": "insertOne",
"name": "updateOne",
"object": "collection",
"arguments": {
"session": "session0",
"document": {
"_id": {
".": "."
}
"filter": {
"_id": 1
},
"update": {
"x": 1
}
},
"error": true
Expand Down
7 changes: 6 additions & 1 deletion tests/UnifiedSpecTests/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use function PHPUnit\Framework\assertNotEmpty;
use function PHPUnit\Framework\assertNotFalse;
use function PHPUnit\Framework\assertNotSame;
use function PHPUnit\Framework\assertSame;
use function PHPUnit\Framework\assertStringContainsString;
use function PHPUnit\Framework\assertStringStartsWith;
use function strlen;
Expand Down Expand Up @@ -171,13 +172,17 @@ public function assertExpectedEventsForClients(array $expectedEventsForClients)

foreach ($expectedEventsForClients as $expectedEventsForClient) {
assertIsObject($expectedEventsForClient);
Util::assertHasOnlyKeys($expectedEventsForClient, ['client', 'events']);
Util::assertHasOnlyKeys($expectedEventsForClient, ['client', 'events', 'eventType']);

$client = $expectedEventsForClient->client ?? null;
$eventType = $expectedEventsForClient->eventType ?? 'command';
$expectedEvents = $expectedEventsForClient->events ?? null;

assertIsString($client);
assertArrayHasKey($client, $this->eventObserversByClient);
/* Note: PHPC does not implement CMAP. Any tests expecting CMAP
* events should be skipped explicitly. */
assertSame('command', $eventType);
assertIsArray($expectedEvents);

$this->eventObserversByClient[$client]->assert($expectedEvents);
Expand Down
14 changes: 14 additions & 0 deletions tests/UnifiedSpecTests/EntityMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use MongoDB\Client;
use MongoDB\Collection;
use MongoDB\Database;
use MongoDB\Driver\Cursor;
use MongoDB\Driver\Session;
use MongoDB\GridFS\Bucket;
use MongoDB\Tests\UnifiedSpecTests\Constraint\IsBsonType;
Expand All @@ -16,6 +17,7 @@
use function array_key_exists;
use function PHPUnit\Framework\assertArrayHasKey;
use function PHPUnit\Framework\assertArrayNotHasKey;
use function PHPUnit\Framework\assertInstanceOf;
use function PHPUnit\Framework\assertIsString;
use function PHPUnit\Framework\assertThat;
use function PHPUnit\Framework\isInstanceOf;
Expand Down Expand Up @@ -128,6 +130,17 @@ public function getRoot() : self
};
}

/**
* Closes a cursor by removing it from the entity map.
*
* @see Operation::executeForCursor()
*/
public function closeCursor(string $cursorId)
{
assertInstanceOf(Cursor::class, $this[$cursorId]);
unset($this->map[$cursorId]);
}

public function getClient(string $clientId) : Client
{
return $this[$clientId];
Expand Down Expand Up @@ -170,6 +183,7 @@ private static function isSupportedType() : Constraint
isInstanceOf(Session::class),
isInstanceOf(Bucket::class),
isInstanceOf(ChangeStream::class),
isInstanceOf(Cursor::class),
IsBsonType::any()
);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/UnifiedSpecTests/EventObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ private function assertEvent($actual, stdClass $expected, string $message)

private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass $expected, string $message)
{
// TODO: Assert hasServiceId (blocked on PHPC-1752)
Util::assertHasOnlyKeys($expected, ['command', 'commandName', 'databaseName']);

if (isset($expected->command)) {
Expand All @@ -220,6 +221,7 @@ private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass

private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdClass $expected, string $message)
{
// TODO: Assert hasServiceId (blocked on PHPC-1752)
Util::assertHasOnlyKeys($expected, ['reply', 'commandName']);

if (isset($expected->reply)) {
Expand All @@ -236,6 +238,7 @@ private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdC

private function assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $expected, string $message)
{
// TODO: Assert hasServiceId (blocked on PHPC-1752)
Util::assertHasOnlyKeys($expected, ['commandName']);

if (isset($expected->commandName)) {
Expand Down
Loading