Skip to content

Commit 67eebe5

Browse files
PHPLIB-718: APM spec tests for serverConnectionId (#930)
Relevant spec tests were previously updated in c4302b9 for PHPLIB-671.
1 parent af516eb commit 67eebe5

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

tests/UnifiedSpecTests/EventObserver.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private function assertEvent($actual, stdClass $expected, string $message)
262262

263263
private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass $expected, string $message): void
264264
{
265-
Util::assertHasOnlyKeys($expected, ['command', 'commandName', 'databaseName', 'hasServiceId']);
265+
Util::assertHasOnlyKeys($expected, ['command', 'commandName', 'databaseName', 'hasServiceId', 'hasServerConnectionId']);
266266

267267
if (isset($expected->command)) {
268268
assertIsObject($expected->command);
@@ -284,11 +284,16 @@ private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass
284284
assertIsBool($expected->hasServiceId);
285285
assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches');
286286
}
287+
288+
if (isset($expected->hasServerConnectionId)) {
289+
assertIsBool($expected->hasServerConnectionId);
290+
assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches');
291+
}
287292
}
288293

289294
private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdClass $expected, string $message): void
290295
{
291-
Util::assertHasOnlyKeys($expected, ['reply', 'commandName', 'hasServiceId']);
296+
Util::assertHasOnlyKeys($expected, ['reply', 'commandName', 'hasServiceId', 'hasServerConnectionId']);
292297

293298
if (isset($expected->reply)) {
294299
assertIsObject($expected->reply);
@@ -305,11 +310,16 @@ private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdC
305310
assertIsBool($expected->hasServiceId);
306311
assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches');
307312
}
313+
314+
if (isset($expected->hasServerConnectionId)) {
315+
assertIsBool($expected->hasServerConnectionId);
316+
assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches');
317+
}
308318
}
309319

310320
private function assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $expected, string $message): void
311321
{
312-
Util::assertHasOnlyKeys($expected, ['commandName', 'hasServiceId']);
322+
Util::assertHasOnlyKeys($expected, ['commandName', 'hasServiceId', 'hasServerConnectionId']);
313323

314324
if (isset($expected->commandName)) {
315325
assertIsString($expected->commandName);
@@ -320,6 +330,11 @@ private function assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $
320330
assertIsBool($expected->hasServiceId);
321331
assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches');
322332
}
333+
334+
if (isset($expected->hasServerConnectionId)) {
335+
assertIsBool($expected->hasServerConnectionId);
336+
assertSame($actual->getServerConnectionId() !== null, $expected->hasServerConnectionId, $message . ': hasServerConnectionId matches');
337+
}
323338
}
324339

325340
/** @param CommandStartedEvent|CommandSucceededEvent|CommandFailedEvent $event */

tests/UnifiedSpecTests/UnifiedSpecTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ class UnifiedSpecTest extends FunctionalTestCase
5959
'valid-pass/entity-client-cmap-events: events are captured during an operation' => 'PHPC does not implement CMAP',
6060
'valid-pass/expectedEventsForClient-eventType: eventType can be set to command and cmap' => 'PHPC does not implement CMAP',
6161
'valid-pass/expectedEventsForClient-eventType: eventType defaults to command if unset' => 'PHPC does not implement CMAP',
62-
// Command monitoring event serverConnectionId is not yet implemented
63-
'command-monitoring/pre-42-server-connection-id: command events do not include server connection id' => 'Not yet implemented (PHPC-1899, PHPLIB-718)',
64-
'command-monitoring/server-connection-id: command events include server connection id' => 'Not yet implemented (PHPC-1899, PHPLIB-718)',
6562
// Change stream "comment" option is not yet implemented
6663
'change-streams/change-streams: Test with document comment' => 'Not yet implemented (PHPLIB-749)',
6764
'change-streams/change-streams: Test with document comment - pre 4.4' => 'Not yet implemented (PHPLIB-749)',

tests/UnifiedSpecTests/UnifiedTestRunner.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ final class UnifiedTestRunner
6060

6161
public const MIN_SCHEMA_VERSION = '1.0';
6262

63-
// Note: schema version 1.6 is not yet implemented (see: PHPLIB-718)
6463
public const MAX_SCHEMA_VERSION = '1.7';
6564

6665
/** @var MongoDB\Client */

0 commit comments

Comments
 (0)