|
16 | 16 | use Psr\Http\Message\StreamInterface; |
17 | 17 | use Psr\Http\Message\UploadedFileFactoryInterface; |
18 | 18 | use Psr\Http\Message\UploadedFileInterface; |
| 19 | +use Workerman\Connection\TcpConnection as WorkermanTcpConnection; |
19 | 20 | use Workerman\Protocols\Http\Request as WorkermanRequest; |
20 | 21 |
|
21 | 22 | /** |
@@ -70,6 +71,12 @@ public function testInvoke(): void |
70 | 71 | Call::create('rawBody')->with()->willReturn('This is the body.'), |
71 | 72 | ]); |
72 | 73 |
|
| 74 | + /** @var MockObject|WorkermanTcpConnection $workermanTcpConnection */ |
| 75 | + $workermanTcpConnection = $this->getMockByCalls(WorkermanTcpConnection::class, [ |
| 76 | + Call::create('getRemoteIp')->with()->willReturn('172.16.89.64'), |
| 77 | + Call::create('getRemotePort')->with()->willReturn(10817), |
| 78 | + ]); |
| 79 | + |
73 | 80 | /** @var MockObject|StreamInterface $requestBody */ |
74 | 81 | $requestBody = $this->getMockByCalls(StreamInterface::class, [ |
75 | 82 | Call::create('write')->with('This is the body.'), |
@@ -157,11 +164,11 @@ static function (array $uploadedFiles) use ($uploadedFile1, $uploadedFile2, $upl |
157 | 164 | /** @var MockObject|ServerRequestFactoryInterface $serverRequestFactory */ |
158 | 165 | $serverRequestFactory = $this->getMockByCalls(ServerRequestFactoryInterface::class, [ |
159 | 166 | Call::create('createServerRequest') |
160 | | - ->with('POST', '/application', []) |
| 167 | + ->with('POST', '/application', ['REMOTE_ADDR' => '172.16.89.64', 'REMOTE_PORT' => '10817']) |
161 | 168 | ->willReturn($request), |
162 | 169 | ]); |
163 | 170 |
|
164 | 171 | $psrRequestFactory = new PsrRequestFactory($serverRequestFactory, $streamFactory, $uploadedFileFactory); |
165 | | - $psrRequestFactory->create($workermanRequest); |
| 172 | + $psrRequestFactory->create($workermanTcpConnection, $workermanRequest); |
166 | 173 | } |
167 | 174 | } |
0 commit comments