|
4 | 4 |
|
5 | 5 | use React\EventLoop\Factory;
|
6 | 6 | use React\EventLoop\Timer\TimerInterface;
|
7 |
| -use React\Http\MiddlewareRunner; |
8 | 7 | use React\Http\Server;
|
9 |
| -use React\Http\StreamingServer; |
10 | 8 | use Psr\Http\Message\ServerRequestInterface;
|
11 |
| -use React\Http\Response; |
12 | 9 | use React\Promise\Deferred;
|
13 | 10 | use Clue\React\Block;
|
14 |
| -use React\Stream\ThroughStream; |
15 |
| -use React\Promise\Promise; |
| 11 | +use React\Promise; |
16 | 12 |
|
17 | 13 | final class ServerTest extends TestCase
|
18 | 14 | {
|
@@ -81,6 +77,28 @@ public function testPostFileUpload()
|
81 | 77 | $this->assertSame("hello\r\n", (string)$files['file']->getStream());
|
82 | 78 | }
|
83 | 79 |
|
| 80 | + public function testForwardErrors() |
| 81 | + { |
| 82 | + $exception = new \Exception(); |
| 83 | + $capturedException = null; |
| 84 | + $server = new Server(function () use ($exception) { |
| 85 | + return Promise\reject($exception); |
| 86 | + }); |
| 87 | + $server->on('error', function ($error) use (&$capturedException) { |
| 88 | + $capturedException = $error; |
| 89 | + }); |
| 90 | + |
| 91 | + $server->listen($this->socket); |
| 92 | + $this->socket->emit('connection', array($this->connection)); |
| 93 | + |
| 94 | + $data = $this->createPostFileUploadRequest(); |
| 95 | + $this->connection->emit('data', array(implode('', $data))); |
| 96 | + |
| 97 | + $this->assertInstanceOf('RuntimeException', $capturedException); |
| 98 | + $this->assertInstanceOf('Exception', $capturedException->getPrevious()); |
| 99 | + $this->assertSame($exception, $capturedException->getPrevious()); |
| 100 | + } |
| 101 | + |
84 | 102 | private function createPostFileUploadRequest()
|
85 | 103 | {
|
86 | 104 | $boundary = "---------------------------5844729766471062541057622570";
|
|
0 commit comments