Open Journal Systems
3.3.0
IoEmittingEntityBodyTest.php
1
<?php
2
3
namespace
Guzzle\Tests\Http
;
4
5
use
Guzzle\Http\EntityBody
;
6
use
Guzzle\Http\IoEmittingEntityBody
;
7
11
class
IoEmittingEntityBodyTest
extends
\Guzzle\Tests\GuzzleTestCase
12
{
13
protected
$body
;
14
protected
$decorated
;
15
16
public
function
setUp
()
17
{
18
$this->decorated =
EntityBody::factory
(
'hello'
);
19
$this->body =
new
IoEmittingEntityBody
($this->decorated);
20
}
21
22
public
function
testEmitsReadEvents
()
23
{
24
$e =
null
;
25
$this->body->getEventDispatcher()->addListener(
'body.read'
,
function
($event) use (&$e) {
26
$e = $event;
27
});
28
$this->assertEquals(
'hel'
, $this->body->read(3));
29
$this->assertEquals(
'hel'
, $e[
'read'
]);
30
$this->assertEquals(3, $e[
'length'
]);
31
$this->assertSame($this->body, $e[
'body'
]);
32
}
33
34
public
function
testEmitsWriteEvents
()
35
{
36
$e =
null
;
37
$this->body->getEventDispatcher()->addListener(
'body.write'
,
function
($event) use (&$e) {
38
$e = $event;
39
});
40
$this->body->seek(0, SEEK_END);
41
$this->assertEquals(5, $this->body->write(
'there'
));
42
$this->assertEquals(
'there'
, $e[
'write'
]);
43
$this->assertEquals(5, $e[
'result'
]);
44
$this->assertSame($this->body, $e[
'body'
]);
45
$this->assertEquals(
'hellothere'
, (
string
) $this->body);
46
}
47
}
Guzzle\Tests\GuzzleTestCase
Definition:
GuzzleTestCase.php:22
Guzzle\Tests\Http\IoEmittingEntityBodyTest\$decorated
$decorated
Definition:
IoEmittingEntityBodyTest.php:14
Guzzle\Http\EntityBody\factory
static factory($resource='', $size=null)
Definition:
EntityBody.php:36
Guzzle\Http\EntityBody
Definition:
EntityBody.php:13
Guzzle\Tests\Http\IoEmittingEntityBodyTest\$body
$body
Definition:
IoEmittingEntityBodyTest.php:13
Guzzle\Http\IoEmittingEntityBody
Definition:
IoEmittingEntityBody.php:14
Guzzle\Tests\Http\IoEmittingEntityBodyTest\testEmitsReadEvents
testEmitsReadEvents()
Definition:
IoEmittingEntityBodyTest.php:22
Guzzle\Tests\Http\IoEmittingEntityBodyTest
Definition:
IoEmittingEntityBodyTest.php:11
Guzzle\Tests\Http\IoEmittingEntityBodyTest\testEmitsWriteEvents
testEmitsWriteEvents()
Definition:
IoEmittingEntityBodyTest.php:34
Guzzle\Tests\Http\IoEmittingEntityBodyTest\setUp
setUp()
Definition:
IoEmittingEntityBodyTest.php:16
Guzzle\Tests\Http
Definition:
AbstractEntityBodyDecoratorTest.php:3
plugins
paymethod
paypal
lib
vendor
guzzle
guzzle
tests
Guzzle
Tests
Http
IoEmittingEntityBodyTest.php
Generated on Fri Aug 28 2020 14:52:24 for Open Journal Systems by
1.8.17