@@ -31,12 +31,12 @@ protected function tearDown(): void
31
31
ob_end_clean ();
32
32
}
33
33
34
- public function test basic behavior ()
34
+ public function test basic behavior (): void
35
35
{
36
36
$ this ->givenAnEvent (['Hello ' => 'world! ' ]);
37
37
38
38
$ output = $ this ->lambda ->processNextEvent (new class implements Handler {
39
- public function handle ($ event , Context $ context )
39
+ public function handle ($ event , Context $ context ): array
40
40
{
41
41
return ['hello ' => 'world ' ];
42
42
}
@@ -46,12 +46,12 @@ public function handle($event, Context $context)
46
46
$ this ->assertInvocationResult (['hello ' => 'world ' ]);
47
47
}
48
48
49
- public function test handler receives context ()
49
+ public function test handler receives context (): void
50
50
{
51
51
$ this ->givenAnEvent (['Hello ' => 'world! ' ]);
52
52
53
53
$ this ->lambda ->processNextEvent (new class implements Handler {
54
- public function handle ($ event , Context $ context )
54
+ public function handle ($ event , Context $ context ): array
55
55
{
56
56
return ['hello ' => 'world ' , 'received-function-arn ' => $ context ->getInvokedFunctionArn ()];
57
57
}
@@ -63,7 +63,7 @@ public function handle($event, Context $context)
63
63
]);
64
64
}
65
65
66
- public function test exceptions in the handler result in an invocation error ()
66
+ public function test exceptions in the handler result in an invocation error (): void
67
67
{
68
68
$ this ->givenAnEvent (['Hello ' => 'world! ' ]);
69
69
@@ -79,7 +79,7 @@ public function handle($event, Context $context)
79
79
$ this ->assertErrorInLogs ('RuntimeException ' , 'This is an exception ' );
80
80
}
81
81
82
- public function test nested exceptions in the handler result in an invocation error ()
82
+ public function test nested exceptions in the handler result in an invocation error (): void
83
83
{
84
84
$ this ->givenAnEvent (['Hello ' => 'world! ' ]);
85
85
@@ -98,7 +98,7 @@ public function handle($event, Context $context)
98
98
]);
99
99
}
100
100
101
- public function test an error is thrown if the runtime API returns a wrong response ()
101
+ public function test an error is thrown if the runtime API returns a wrong response (): void
102
102
{
103
103
$ this ->expectExceptionMessage ('Failed to fetch next Lambda invocation: The requested URL returned error: 404 ' );
104
104
Server::enqueue ([
@@ -118,7 +118,7 @@ public function handle($event, Context $context)
118
118
});
119
119
}
120
120
121
- public function test an error is thrown if the invocation id is missing ()
121
+ public function test an error is thrown if the invocation id is missing (): void
122
122
{
123
123
$ this ->expectExceptionMessage ('Failed to determine the Lambda invocation ID ' );
124
124
Server::enqueue ([
@@ -136,7 +136,7 @@ public function handle($event, Context $context)
136
136
});
137
137
}
138
138
139
- public function test an error is thrown if the invocation body is empty ()
139
+ public function test an error is thrown if the invocation body is empty (): void
140
140
{
141
141
$ this ->expectExceptionMessage ('Empty Lambda runtime API response ' );
142
142
Server::enqueue ([
@@ -155,7 +155,7 @@ public function handle($event, Context $context)
155
155
});
156
156
}
157
157
158
- public function test a wrong response from the runtime API turns the invocation into an error ()
158
+ public function test a wrong response from the runtime API turns the invocation into an error (): void
159
159
{
160
160
Server::enqueue ([
161
161
new Response ( // lambda event
@@ -193,12 +193,12 @@ public function handle($event, Context $context)
193
193
$ this ->assertErrorInLogs ('Exception ' , 'Error while calling the Lambda runtime API: The requested URL returned error: 400 ' );
194
194
}
195
195
196
- public function test function results that cannot be encoded are reported as invocation errors ()
196
+ public function test function results that cannot be encoded are reported as invocation errors (): void
197
197
{
198
198
$ this ->givenAnEvent (['hello ' => 'world! ' ]);
199
199
200
200
$ this ->lambda ->processNextEvent (new class implements Handler {
201
- public function handle ($ event , Context $ context )
201
+ public function handle ($ event , Context $ context ): string
202
202
{
203
203
return "\xB1\x31" ;
204
204
}
@@ -213,7 +213,7 @@ public function handle($event, Context $context)
213
213
$ this ->assertErrorInLogs ('Exception ' , $ message );
214
214
}
215
215
216
- public function test generic event handler ()
216
+ public function test generic event handler (): void
217
217
{
218
218
$ handler = new class implements Handler {
219
219
public function handle ($ event , Context $ context )
@@ -244,7 +244,7 @@ private function givenAnEvent($event): void
244
244
]);
245
245
}
246
246
247
- private function assertInvocationResult ($ result )
247
+ private function assertInvocationResult ($ result ): void
248
248
{
249
249
$ requests = Server::received ();
250
250
$ this ->assertCount (2 , $ requests );
@@ -257,7 +257,7 @@ private function assertInvocationResult($result)
257
257
$ this ->assertEquals ($ result , json_decode ($ eventResponse ->getBody ()->__toString (), true ));
258
258
}
259
259
260
- private function assertInvocationErrorResult (string $ errorClass , string $ errorMessage )
260
+ private function assertInvocationErrorResult (string $ errorClass , string $ errorMessage ): void
261
261
{
262
262
$ requests = Server::received ();
263
263
$ this ->assertCount (2 , $ requests );
@@ -304,7 +304,7 @@ private function assertErrorInLogs(string $errorClass, string $errorMessage): vo
304
304
$ this ->assertIsArray ($ invocationResult ['stack ' ]);
305
305
}
306
306
307
- private function assertPreviousErrorsInLogs (array $ previousErrors )
307
+ private function assertPreviousErrorsInLogs (array $ previousErrors ): void
308
308
{
309
309
// Decode the logs from stdout
310
310
$ stdout = $ this ->getActualOutput ();
0 commit comments