1--TEST--
2MongoDB\Driver\Monitoring\CommandSucceededEvent: requestId and operationId match
3--SKIPIF--
4<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5<?php skip_if_not_live(); ?>
6<?php skip_if_not_clean(); ?>
7--FILE--
8<?php
9require_once __DIR__ . "/../utils/basic.inc";
10
11$m = new MongoDB\Driver\Manager(URI);
12
13class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber
14{
15    public function commandStarted( \MongoDB\Driver\Monitoring\CommandStartedEvent $event )
16    {
17        echo "started: ", $event->getCommandName(), "\n";
18        $this->startRequestId = $event->getRequestId();
19        $this->startOperationId = $event->getOperationId();
20    }
21
22    public function commandSucceeded( \MongoDB\Driver\Monitoring\CommandSucceededEvent $event )
23    {
24        echo "succeeded: ", $event->getCommandName(), "\n";
25        echo "- requestId matches: ", $this->startRequestId == $event->getRequestId() ? 'yes' : 'no', " \n";
26        echo "- operationId matches: ", $this->startOperationId == $event->getOperationId() ? 'yes' : 'no', " \n";
27    }
28
29    public function commandFailed( \MongoDB\Driver\Monitoring\CommandFailedEvent $event )
30    {
31    }
32}
33
34$query = new MongoDB\Driver\Query( [] );
35$subscriber = new MySubscriber;
36
37MongoDB\Driver\Monitoring\addSubscriber( $subscriber );
38
39$cursor = $m->executeQuery( "demo.test", $query );
40?>
41--EXPECT--
42started: find
43succeeded: find
44- requestId matches: yes
45- operationId matches: yes
46