3
namespace GuzzleHttp\Tests\Adapter;
5
use GuzzleHttp\Adapter\StreamingProxyAdapter;
6
use GuzzleHttp\Adapter\Transaction;
8
use GuzzleHttp\Message\Request;
9
use GuzzleHttp\Message\Response;
12
* @covers GuzzleHttp\Adapter\StreamingProxyAdapter
14
class StreamingProxyAdapterTest extends \PHPUnit_Framework_TestCase
16
public function testSendsWithDefaultAdapter()
18
$response = new Response(200);
19
$mock = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
20
->setMethods(['send'])
21
->getMockForAbstractClass();
22
$mock->expects($this->once())
24
->will($this->returnValue($response));
25
$streaming = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
26
->setMethods(['send'])
27
->getMockForAbstractClass();
28
$streaming->expects($this->never())
31
$s = new StreamingProxyAdapter($mock, $streaming);
32
$this->assertSame($response, $s->send(new Transaction(new Client(), new Request('GET', '/'))));
35
public function testSendsWithStreamingAdapter()
37
$response = new Response(200);
38
$mock = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
39
->setMethods(['send'])
40
->getMockForAbstractClass();
41
$mock->expects($this->never())
43
$streaming = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
44
->setMethods(['send'])
45
->getMockForAbstractClass();
46
$streaming->expects($this->once())
48
->will($this->returnValue($response));
49
$request = new Request('GET', '/');
50
$request->getConfig()->set('stream', true);
51
$s = new StreamingProxyAdapter($mock, $streaming);
52
$this->assertSame($response, $s->send(new Transaction(new Client(), $request)));