forked from reactphp/http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRawBodyParserTest.php
More file actions
45 lines (40 loc) · 1.36 KB
/
Copy pathRawBodyParserTest.php
File metadata and controls
45 lines (40 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace React\Tests\Http\StreamingBodyParser;
use React\Http\StreamingBodyParser\RawBodyParser;
use React\Http\Request;
use React\Tests\Http\TestCase;
class RawBodyParserTest extends TestCase
{
public function testNoBufferingLength()
{
$body = '';
$request = new Request('POST', 'http://example.com/', [], 1.1, [
'content-length' => 3,
]);
$parser = new RawBodyParser($request);
$parser->on('end', $this->expectCallableNever());
$parser->on('body', function ($rawBody) use (&$body) {
$body = $rawBody;
});
$request->emit('data', ['abc']);
$this->assertSame('abc', $body);
$request->emit('data', ['def']);
$this->assertSame('def', $body);
}
public function testEndForward()
{
$request = new Request('POST', 'http://example.com/');
$parser = new RawBodyParser($request);
$parser->on('end', $this->expectCallableOnce());
$parser->on('body', $this->expectCallableNever());
$request->emit('end');
}
public function testEndOnCancel()
{
$request = new Request('POST', 'http://example.com/');
$parser = new RawBodyParser($request);
$parser->on('end', $this->expectCallableOnce());
$parser->on('body', $this->expectCallableNever());
$parser->cancel();
}
}