@@ -28,15 +28,37 @@ public function testSoftFailsAreRecorded(): void
28
28
self ::markTestSkipped ('Messenger not supported in this environment. ' );
29
29
}
30
30
31
+ $ message = (object ) ['foo ' => 'bar ' ];
32
+ $ envelope = Envelope::wrap ($ message );
33
+
31
34
$ error = new \RuntimeException ();
35
+ $ wrappedError = new HandlerFailedException ($ envelope , [$ error ]);
32
36
33
37
$ this ->client ->captureException ($ error )->shouldBeCalled ();
34
38
$ this ->client ->flush ()->shouldBeCalled ();
35
39
36
40
$ listener = new MessengerListener ($ this ->client ->reveal (), true );
41
+ $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ wrappedError , true );
42
+
43
+ $ listener ->onWorkerMessageFailed ($ event );
44
+ }
45
+
46
+ public function testNonMessengerErrorsAreRecorded (): void
47
+ {
48
+ if (! $ this ->supportsMessenger ()) {
49
+ self ::markTestSkipped ('Messenger not supported in this environment. ' );
50
+ }
51
+
37
52
$ message = (object ) ['foo ' => 'bar ' ];
38
53
$ envelope = Envelope::wrap ($ message );
39
- $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ error , true );
54
+
55
+ $ error = new \RuntimeException ();
56
+
57
+ $ this ->client ->captureException ($ error )->shouldBeCalled ();
58
+ $ this ->client ->flush ()->shouldBeCalled ();
59
+
60
+ $ listener = new MessengerListener ($ this ->client ->reveal (), true );
61
+ $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ error , false );
40
62
41
63
$ listener ->onWorkerMessageFailed ($ event );
42
64
}
@@ -47,15 +69,17 @@ public function testHardFailsAreRecorded(): void
47
69
self ::markTestSkipped ('Messenger not supported in this environment. ' );
48
70
}
49
71
72
+ $ message = (object ) ['foo ' => 'bar ' ];
73
+ $ envelope = Envelope::wrap ($ message );
74
+
50
75
$ error = new \RuntimeException ();
76
+ $ wrappedError = new HandlerFailedException ($ envelope , [$ error ]);
51
77
52
78
$ this ->client ->captureException ($ error )->shouldBeCalled ();
53
79
$ this ->client ->flush ()->shouldBeCalled ();
54
80
55
81
$ listener = new MessengerListener ($ this ->client ->reveal (), true );
56
- $ message = (object ) ['foo ' => 'bar ' ];
57
- $ envelope = Envelope::wrap ($ message );
58
- $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ error , false );
82
+ $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ wrappedError , false );
59
83
60
84
$ listener ->onWorkerMessageFailed ($ event );
61
85
}
@@ -66,15 +90,17 @@ public function testSoftFailsAreNotRecorded(): void
66
90
self ::markTestSkipped ('Messenger not supported in this environment. ' );
67
91
}
68
92
93
+ $ message = (object ) ['foo ' => 'bar ' ];
94
+ $ envelope = Envelope::wrap ($ message );
95
+
69
96
$ error = new \RuntimeException ();
97
+ $ wrappedError = new HandlerFailedException ($ envelope , [$ error ]);
70
98
71
99
$ this ->client ->captureException ($ error )->shouldNotBeCalled ();
72
100
$ this ->client ->flush ()->shouldNotBeCalled ();
73
101
74
102
$ listener = new MessengerListener ($ this ->client ->reveal (), false );
75
- $ message = (object ) ['foo ' => 'bar ' ];
76
- $ envelope = Envelope::wrap ($ message );
77
- $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ error , true );
103
+ $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ wrappedError , true );
78
104
79
105
$ listener ->onWorkerMessageFailed ($ event );
80
106
}
@@ -85,15 +111,17 @@ public function testHardFailsAreRecordedWithCaptureSoftDisabled(): void
85
111
self ::markTestSkipped ('Messenger not supported in this environment. ' );
86
112
}
87
113
114
+ $ message = (object ) ['foo ' => 'bar ' ];
115
+ $ envelope = Envelope::wrap ($ message );
116
+
88
117
$ error = new \RuntimeException ();
118
+ $ wrappedError = new HandlerFailedException ($ envelope , [$ error ]);
89
119
90
120
$ this ->client ->captureException ($ error )->shouldBeCalled ();
91
121
$ this ->client ->flush ()->shouldBeCalled ();
92
122
93
123
$ listener = new MessengerListener ($ this ->client ->reveal (), false );
94
- $ message = (object ) ['foo ' => 'bar ' ];
95
- $ envelope = Envelope::wrap ($ message );
96
- $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ error , false );
124
+ $ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ wrappedError , false );
97
125
98
126
$ listener ->onWorkerMessageFailed ($ event );
99
127
}
@@ -106,12 +134,14 @@ public function testHandlerFailedExceptionIsUnwrapped(): void
106
134
107
135
$ message = (object ) ['foo ' => 'bar ' ];
108
136
$ envelope = Envelope::wrap ($ message );
109
- $ error = new \RuntimeException ();
110
- $ wrappedError = new HandlerFailedException ($ envelope , [$ error ]);
137
+ $ error1 = new \RuntimeException ();
138
+ $ error2 = new \RuntimeException ();
139
+ $ wrappedError = new HandlerFailedException ($ envelope , [$ error1 , $ error2 ]);
111
140
112
141
$ event = $ this ->getMessageFailedEvent ($ envelope , 'receiver ' , $ wrappedError , false );
113
142
114
- $ this ->client ->captureException ($ error )->shouldBeCalled ();
143
+ $ this ->client ->captureException ($ error1 )->shouldBeCalled ();
144
+ $ this ->client ->captureException ($ error2 )->shouldBeCalled ();
115
145
$ this ->client ->flush ()->shouldBeCalled ();
116
146
117
147
$ listener = new MessengerListener ($ this ->client ->reveal ());
0 commit comments