diff --git a/tests/UnifiedSpecTests/EventObserver.php b/tests/UnifiedSpecTests/EventObserver.php index 651d21b2d..842dfb89a 100644 --- a/tests/UnifiedSpecTests/EventObserver.php +++ b/tests/UnifiedSpecTests/EventObserver.php @@ -262,7 +262,7 @@ private function assertEvent($actual, stdClass $expected, string $message) private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass $expected, string $message): void { - Util::assertHasOnlyKeys($expected, ['command', 'commandName', 'databaseName', 'hasServiceId']); + Util::assertHasOnlyKeys($expected, ['command', 'commandName', 'databaseName', 'hasServiceId', 'hasServerConnectionId']); if (isset($expected->command)) { assertIsObject($expected->command); @@ -284,11 +284,16 @@ private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass assertIsBool($expected->hasServiceId); assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches'); } + + if (isset($expected->hasServerConnectionId)) { + assertIsBool($expected->hasServerConnectionId); + assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches'); + } } private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdClass $expected, string $message): void { - Util::assertHasOnlyKeys($expected, ['reply', 'commandName', 'hasServiceId']); + Util::assertHasOnlyKeys($expected, ['reply', 'commandName', 'hasServiceId', 'hasServerConnectionId']); if (isset($expected->reply)) { assertIsObject($expected->reply); @@ -305,11 +310,16 @@ private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdC assertIsBool($expected->hasServiceId); assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches'); } + + if (isset($expected->hasServerConnectionId)) { + assertIsBool($expected->hasServerConnectionId); + assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches'); + } } private function assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $expected, string $message): void { - Util::assertHasOnlyKeys($expected, ['commandName', 'hasServiceId']); + Util::assertHasOnlyKeys($expected, ['commandName', 'hasServiceId', 'hasServerConnectionId']); if (isset($expected->commandName)) { assertIsString($expected->commandName); @@ -320,6 +330,11 @@ private function assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $ assertIsBool($expected->hasServiceId); assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches'); } + + if (isset($expected->hasServerConnectionId)) { + assertIsBool($expected->hasServerConnectionId); + assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches'); + } } /** @param CommandStartedEvent|CommandSucceededEvent|CommandFailedEvent $event */ diff --git a/tests/UnifiedSpecTests/UnifiedSpecTest.php b/tests/UnifiedSpecTests/UnifiedSpecTest.php index 5db237cbb..80b531255 100644 --- a/tests/UnifiedSpecTests/UnifiedSpecTest.php +++ b/tests/UnifiedSpecTests/UnifiedSpecTest.php @@ -59,9 +59,6 @@ class UnifiedSpecTest extends FunctionalTestCase 'valid-pass/entity-client-cmap-events: events are captured during an operation' => 'PHPC does not implement CMAP', 'valid-pass/expectedEventsForClient-eventType: eventType can be set to command and cmap' => 'PHPC does not implement CMAP', 'valid-pass/expectedEventsForClient-eventType: eventType defaults to command if unset' => 'PHPC does not implement CMAP', - // Command monitoring event serverConnectionId is not yet implemented - 'command-monitoring/pre-42-server-connection-id: command events do not include server connection id' => 'Not yet implemented (PHPC-1899, PHPLIB-718)', - 'command-monitoring/server-connection-id: command events include server connection id' => 'Not yet implemented (PHPC-1899, PHPLIB-718)', // Change stream "comment" option is not yet implemented 'change-streams/change-streams: Test with document comment' => 'Not yet implemented (PHPLIB-749)', 'change-streams/change-streams: Test with document comment - pre 4.4' => 'Not yet implemented (PHPLIB-749)', diff --git a/tests/UnifiedSpecTests/UnifiedTestRunner.php b/tests/UnifiedSpecTests/UnifiedTestRunner.php index 5a2718223..a378f7996 100644 --- a/tests/UnifiedSpecTests/UnifiedTestRunner.php +++ b/tests/UnifiedSpecTests/UnifiedTestRunner.php @@ -60,7 +60,6 @@ final class UnifiedTestRunner public const MIN_SCHEMA_VERSION = '1.0'; - // Note: schema version 1.6 is not yet implemented (see: PHPLIB-718) public const MAX_SCHEMA_VERSION = '1.7'; /** @var MongoDB\Client */