File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ MongoDB\Driver\Monitoring\CommandStartedEvent during mongoc_client_destroy()
3
+ --SKIPIF--
4
+ <?php require __DIR__ . "/../utils/basic-skipif.inc " ; ?>
5
+ <?php skip_if_not_libmongoc_crypto (); ?>
6
+ <?php skip_if_not_live (); ?>
7
+ <?php skip_if_server_version ('< ' , '3.6 ' ); ?>
8
+ --FILE--
9
+ <?php
10
+ require_once __DIR__ . "/../utils/basic.inc " ;
11
+
12
+ class MySubscriber implements MongoDB \Driver \Monitoring \CommandSubscriber
13
+ {
14
+ public function commandStarted (MongoDB \Driver \Monitoring \CommandStartedEvent $ event )
15
+ {
16
+ printf ("Observed commandStarted for %s \n" , $ event ->getCommandName ());
17
+ }
18
+
19
+ public function commandSucceeded (MongoDB \Driver \Monitoring \CommandSucceededEvent $ event ) {}
20
+
21
+ public function commandFailed (MongoDB \Driver \Monitoring \CommandFailedEvent $ event ) {}
22
+ }
23
+
24
+ $ manager = create_test_manager (URI , [], ['disableClientPersistence ' => true ]);
25
+
26
+ $ singleSubscriber = new MySubscriber ();
27
+ $ manager ->addSubscriber ($ singleSubscriber );
28
+
29
+ $ command = new MongoDB \Driver \Command (['ping ' => 1 ]);
30
+ $ manager ->executeCommand (DATABASE_NAME , $ command );
31
+
32
+ /* Events dispatched during mongoc_client_destroy can only be observed before
33
+ * RSHUTDOWN. This means that we must use a non-persistent client and free it
34
+ * before the script ends. */
35
+ unset($ manager );
36
+
37
+ ?>
38
+ ===DONE===
39
+ --EXPECT--
40
+ Observed commandStarted for ping
41
+ Observed commandStarted for endSessions
42
+ ===DONE===
You can’t perform that action at this time.
0 commit comments