Skip to content

Commit

Permalink
Update test for HTTP 413
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Oct 19, 2017
1 parent 96d43b6 commit d6b95a9
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions tests/Middleware/RequestBodyBufferMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use React\EventLoop\Factory;
use React\Tests\Http\TestCase;
use RingCentral\Psr7\BufferStream;
use Clue\React\Block;

final class RequestBodyBufferMiddlewareTest extends TestCase
{
Expand Down Expand Up @@ -70,33 +69,22 @@ public function testExcessiveSizeReturnsError413()
$loop = Factory::create();

$stream = new ThroughStream();
$stream->end('aa');
$serverRequest = new ServerRequest(
'GET',
'https://example.com/',
array(),
new HttpBodyStream($stream)
new HttpBodyStream($stream, 2)
);

$buffer = new RequestBodyBufferMiddleware(1);
$promise = $buffer(
$response = $buffer(
$serverRequest,
function (ServerRequestInterface $request) {
return $request;
}
);

$stream->write('aa');

$exposedResponse = null;
$promise->then(
function($response) use (&$exposedResponse) {
$exposedResponse = $response;
},
$this->expectCallableNever()
);

$this->assertSame(413, $exposedResponse->getStatusCode());

Block\await($promise, $loop);
$this->assertSame(413, $response->getStatusCode());
}
}

0 comments on commit d6b95a9

Please sign in to comment.