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