|
1 | 1 | <?php namespace com\amazon\aws\lambda\unittest; |
2 | 2 |
|
3 | | -use com\amazon\aws\lambda\{Context, RuntimeApi, Lambda, Streaming}; |
| 3 | +use com\amazon\aws\lambda\{Context, RuntimeApi, Lambda, Stream, Streaming}; |
4 | 4 | use lang\IllegalArgumentException; |
5 | 5 | use test\{Assert, Expect, Test}; |
6 | 6 |
|
@@ -50,6 +50,24 @@ public function process($event, $context) { return 'Test'; } |
50 | 50 | Assert::equals('Test', ($invokeable->callable)(null, new Context($this->headers, []))); |
51 | 51 | } |
52 | 52 |
|
| 53 | + #[Test] |
| 54 | + public function return_streaming() { |
| 55 | + $runtime= new RuntimeApi('localhost:9000'); |
| 56 | + $invokeable= $runtime->invokeable(new class() implements Streaming { |
| 57 | + public function handle($event, $stream, $context) { $stream->write('Test'); } |
| 58 | + }); |
| 59 | + $stream= new class() implements Stream { |
| 60 | + public $written= ''; |
| 61 | + public function transmit($source, $mime= null) { /* NOOP */ } |
| 62 | + public function use($mime) { /** NOOP */ } |
| 63 | + public function write($bytes) { $this->written.= $bytes; } |
| 64 | + public function end() { /** NOOP */ } |
| 65 | + }; |
| 66 | + ($invokeable->callable)(null, $stream, new Context($this->headers, [])); |
| 67 | + |
| 68 | + Assert::equals('Test', $stream->written); |
| 69 | + } |
| 70 | + |
53 | 71 | #[Test, Expect(IllegalArgumentException::class)] |
54 | 72 | public function cannot_return_null() { |
55 | 73 | $runtime= new RuntimeApi('localhost:9000'); |
|
0 commit comments