~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/guzzlehttp/guzzle/tests/Event/RequestBeforeSendEventTest.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\Event;
 
4
 
 
5
use GuzzleHttp\Adapter\Transaction;
 
6
use GuzzleHttp\Client;
 
7
use GuzzleHttp\Event\BeforeEvent;
 
8
use GuzzleHttp\Message\Request;
 
9
use GuzzleHttp\Message\Response;
 
10
 
 
11
/**
 
12
 * @covers GuzzleHttp\Event\BeforeEvent
 
13
 */
 
14
class BeforeEventTest extends \PHPUnit_Framework_TestCase
 
15
{
 
16
    public function testInterceptsWithEvent()
 
17
    {
 
18
        $response = new Response(200);
 
19
        $res = null;
 
20
        $t = new Transaction(new Client(), new Request('GET', '/'));
 
21
        $t->getRequest()->getEmitter()->on('complete', function ($e) use (&$res) {
 
22
            $res = $e;
 
23
        });
 
24
        $e = new BeforeEvent($t);
 
25
        $e->intercept($response);
 
26
        $this->assertTrue($e->isPropagationStopped());
 
27
        $this->assertSame($res->getClient(), $e->getClient());
 
28
    }
 
29
}