--TEST-- MongoDB\Driver\Monitoring\CommandFailedEvent debug output --SKIPIF-- --FILE-- addSubscriber(new MySubscriber); $command = new MongoDB\Driver\Command([ 'aggregate' => COLLECTION_NAME, 'pipeline' => [['$unsupported' => 1]], ]); /* Note: Although executeCommand() throws a CommandException, CommandFailedEvent * will report a ServerException for its "error" property (PHPC-1990) */ throws(function() use ($manager, $command) { $manager->executeCommand(DATABASE_NAME, $command); }, MongoDB\Driver\Exception\CommandException::class); ?> ===DONE=== --EXPECTF-- object(MongoDB\Driver\Monitoring\CommandFailedEvent)#%d (%d) { ["commandName"]=> string(9) "aggregate" ["durationMicros"]=> int(%d) ["error"]=> object(MongoDB\Driver\Exception\ServerException)#%d (%d) {%A } ["operationId"]=> string(%d) "%d" ["reply"]=> object(stdClass)#%d (%d) {%A } ["requestId"]=> string(%d) "%d" ["server"]=> object(MongoDB\Driver\Server)#%d (%d) {%A } ["serviceId"]=> %r(NULL|object\(MongoDB\\BSON\\ObjectId\).*)%r ["serverConnectionId"]=> %r(NULL|int\(\d+\))%r } OK: Got MongoDB\Driver\Exception\CommandException ===DONE===