~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/guzzlehttp/guzzle/tests/Adapter/StreamingProxyAdapterTest.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
namespace GuzzleHttp\Tests\Adapter;
 
4
 
 
5
use GuzzleHttp\Adapter\StreamingProxyAdapter;
 
6
use GuzzleHttp\Adapter\Transaction;
 
7
use GuzzleHttp\Client;
 
8
use GuzzleHttp\Message\Request;
 
9
use GuzzleHttp\Message\Response;
 
10
 
 
11
/**
 
12
 * @covers GuzzleHttp\Adapter\StreamingProxyAdapter
 
13
 */
 
14
class StreamingProxyAdapterTest extends \PHPUnit_Framework_TestCase
 
15
{
 
16
    public function testSendsWithDefaultAdapter()
 
17
    {
 
18
        $response = new Response(200);
 
19
        $mock = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
 
20
            ->setMethods(['send'])
 
21
            ->getMockForAbstractClass();
 
22
        $mock->expects($this->once())
 
23
            ->method('send')
 
24
            ->will($this->returnValue($response));
 
25
        $streaming = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
 
26
            ->setMethods(['send'])
 
27
            ->getMockForAbstractClass();
 
28
        $streaming->expects($this->never())
 
29
            ->method('send');
 
30
 
 
31
        $s = new StreamingProxyAdapter($mock, $streaming);
 
32
        $this->assertSame($response, $s->send(new Transaction(new Client(), new Request('GET', '/'))));
 
33
    }
 
34
 
 
35
    public function testSendsWithStreamingAdapter()
 
36
    {
 
37
        $response = new Response(200);
 
38
        $mock = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
 
39
            ->setMethods(['send'])
 
40
            ->getMockForAbstractClass();
 
41
        $mock->expects($this->never())
 
42
            ->method('send');
 
43
        $streaming = $this->getMockBuilder('GuzzleHttp\Adapter\AdapterInterface')
 
44
            ->setMethods(['send'])
 
45
            ->getMockForAbstractClass();
 
46
        $streaming->expects($this->once())
 
47
            ->method('send')
 
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)));
 
53
    }
 
54
}