File tree Expand file tree Collapse file tree 3 files changed +120
-0
lines changed Expand file tree Collapse file tree 3 files changed +120
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MongoDB \Monitoring ;
4
+
5
+ use MongoDB \Driver \Monitoring \CommandFailedEvent ;
6
+ use MongoDB \Driver \Monitoring \CommandStartedEvent ;
7
+ use MongoDB \Driver \Monitoring \CommandSubscriber ;
8
+ use MongoDB \Driver \Monitoring \CommandSucceededEvent ;
9
+
10
+ /** @see CommandSubscriber */
11
+ trait CommandEvents
12
+ {
13
+ public function commandFailed (CommandFailedEvent $ event ): void
14
+ {
15
+ }
16
+
17
+ public function commandStarted (CommandStartedEvent $ event ): void
18
+ {
19
+ }
20
+
21
+ public function commandSucceeded (CommandSucceededEvent $ event ): void
22
+ {
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MongoDB \Monitoring ;
4
+
5
+ use MongoDB \Driver \Monitoring \SDAMSubscriber ;
6
+ use MongoDB \Driver \Monitoring \ServerChangedEvent ;
7
+ use MongoDB \Driver \Monitoring \ServerClosedEvent ;
8
+ use MongoDB \Driver \Monitoring \ServerHeartbeatFailedEvent ;
9
+ use MongoDB \Driver \Monitoring \ServerHeartbeatStartedEvent ;
10
+ use MongoDB \Driver \Monitoring \ServerHeartbeatSucceededEvent ;
11
+ use MongoDB \Driver \Monitoring \ServerOpeningEvent ;
12
+ use MongoDB \Driver \Monitoring \TopologyChangedEvent ;
13
+ use MongoDB \Driver \Monitoring \TopologyClosedEvent ;
14
+ use MongoDB \Driver \Monitoring \TopologyOpeningEvent ;
15
+
16
+ /** @see SDAMSubscriber */
17
+ trait SDAMEvents
18
+ {
19
+ public function serverChanged (ServerChangedEvent $ event ): void
20
+ {
21
+ }
22
+
23
+ public function serverClosed (ServerClosedEvent $ event ): void
24
+ {
25
+ }
26
+
27
+ public function serverHeartbeatFailed (ServerHeartbeatFailedEvent $ event ): void
28
+ {
29
+ }
30
+
31
+ public function serverHeartbeatStarted (ServerHeartbeatStartedEvent $ event ): void
32
+ {
33
+ }
34
+
35
+ public function serverHeartbeatSucceeded (ServerHeartbeatSucceededEvent $ event ): void
36
+ {
37
+ }
38
+
39
+ public function serverOpening (ServerOpeningEvent $ event ): void
40
+ {
41
+ }
42
+
43
+ public function topologyChanged (TopologyChangedEvent $ event ): void
44
+ {
45
+ }
46
+
47
+ public function topologyClosed (TopologyClosedEvent $ event ): void
48
+ {
49
+ }
50
+
51
+ public function topologyOpening (TopologyOpeningEvent $ event ): void
52
+ {
53
+ }
54
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MongoDB \Tests ;
4
+
5
+ use MongoDB \Driver \Monitoring \CommandSubscriber ;
6
+ use MongoDB \Driver \Monitoring \SDAMSubscriber ;
7
+ use MongoDB \Driver \Monitoring \Subscriber ;
8
+ use MongoDB \Monitoring \CommandEvents ;
9
+ use MongoDB \Monitoring \SDAMEvents ;
10
+
11
+ use function MongoDB \Driver \Monitoring \addSubscriber ;
12
+ use function MongoDB \Driver \Monitoring \removeSubscriber ;
13
+
14
+ class MonitoringTest extends TestCase
15
+ {
16
+ /**
17
+ * @doesNotPerformAssertions
18
+ *
19
+ * @dataProvider provideSubscribers
20
+ */
21
+ public function testSubscriber (Subscriber $ subscriber ): void
22
+ {
23
+ // Fatal error if the trait does not implement all methods required by the interface
24
+ addSubscriber ($ subscriber );
25
+ removeSubscriber ($ subscriber );
26
+ }
27
+
28
+ public static function provideSubscribers (): iterable
29
+ {
30
+ yield 'Command ' => [
31
+ new class implements CommandSubscriber {
32
+ use CommandEvents;
33
+ },
34
+ ];
35
+
36
+ yield 'SDAM ' => [
37
+ new class implements SDAMSubscriber {
38
+ use SDAMEvents;
39
+ },
40
+ ];
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments