Skip to content

Commit f89de92

Browse files
committed
QA: Simplify test code
1 parent 310237c commit f89de92

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/test/php/com/amazon/aws/lambda/unittest/RuntimeApiTest.class.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,25 @@ public function endpoint_timeout_is_15_minutes() {
3636

3737
#[Test]
3838
public function return_function() {
39-
$runtime= new RuntimeApi('localhost:9000');
40-
$invokeable= $runtime->invokeable(function($event, $context) { return 'Test'; });
39+
$invokeable= (new RuntimeApi('localhost:9000'))->invokeable(function($event, $context) {
40+
return 'Test';
41+
});
42+
4143
Assert::equals('Test', ($invokeable->callable)(null, new Context($this->headers, [])));
4244
}
4345

4446
#[Test]
4547
public function return_lambda() {
46-
$runtime= new RuntimeApi('localhost:9000');
47-
$invokeable= $runtime->invokeable(new class() implements Lambda {
48+
$invokeable= (new RuntimeApi('localhost:9000'))->invokeable(new class() implements Lambda {
4849
public function process($event, $context) { return 'Test'; }
4950
});
51+
5052
Assert::equals('Test', ($invokeable->callable)(null, new Context($this->headers, [])));
5153
}
5254

5355
#[Test]
5456
public function return_streaming() {
55-
$runtime= new RuntimeApi('localhost:9000');
56-
$invokeable= $runtime->invokeable(new class() implements Streaming {
57+
$invokeable= (new RuntimeApi('localhost:9000'))->invokeable(new class() implements Streaming {
5758
public function handle($event, $stream, $context) { $stream->write('Test'); }
5859
});
5960
$stream= new class() implements Stream {
@@ -63,14 +64,13 @@ public function use($mime) { /** NOOP */ }
6364
public function write($bytes) { $this->written.= $bytes; }
6465
public function end() { /** NOOP */ }
6566
};
66-
($invokeable->callable)(null, $stream, new Context($this->headers, []));
6767

68+
($invokeable->callable)(null, $stream, new Context($this->headers, []));
6869
Assert::equals('Test', $stream->written);
6970
}
7071

7172
#[Test, Expect(IllegalArgumentException::class)]
7273
public function cannot_return_null() {
73-
$runtime= new RuntimeApi('localhost:9000');
74-
$runtime->invokeable(null);
74+
(new RuntimeApi('localhost:9000'))->invokeable(null);
7575
}
7676
}

0 commit comments

Comments
 (0)