1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 02:22:57 +01:00
guzzle/tests/Adapter/StreamingProxyAdapterTest.php
Michael Dowling 89a8e2ede1 Using PSR-4 and moving namespace from Guzzle to GuzzleHttp
- Moving various namespaces up a level
- Updating docs
- Renaming EventSubscriberInterface to SubscriberInterface
2014-02-16 20:42:45 -08:00

55 lines
1.9 KiB
PHP

<?php
namespace GuzzleHttp\Tests\Adapter;
use GuzzleHttp\Adapter\Transaction;
use GuzzleHttp\Client;
use GuzzleHttp\Message\Request;
use GuzzleHttp\Adapter\StreamingProxyAdapter;
use GuzzleHttp\Message\Response;
/**
* @covers GuzzleHttp\Adapter\StreamingProxyAdapter
*/
class StreamingProxyAdapterTest extends \PHPUnit_Framework_TestCase
{
public function testSendsWithDefaultAdapter()
{
$response = new Response(200);
$mock = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
->setMethods(['send'])
->getMockForAbstractClass();
$mock->expects($this->once())
->method('send')
->will($this->returnValue($response));
$streaming = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
->setMethods(['send'])
->getMockForAbstractClass();
$streaming->expects($this->never())
->method('send');
$s = new StreamingProxyAdapter($mock, $streaming);
$this->assertSame($response, $s->send(new Transaction(new Client(), new Request('GET', '/'))));
}
public function testSendsWithStreamingAdapter()
{
$response = new Response(200);
$mock = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
->setMethods(['send'])
->getMockForAbstractClass();
$mock->expects($this->never())
->method('send');
$streaming = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
->setMethods(['send'])
->getMockForAbstractClass();
$streaming->expects($this->once())
->method('send')
->will($this->returnValue($response));
$request = new Request('GET', '/');
$request->getConfig()->set('stream', true);
$s = new StreamingProxyAdapter($mock, $streaming);
$this->assertSame($response, $s->send(new Transaction(new Client(), $request)));
}
}