1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 02:22:57 +01:00
guzzle/tests/Event/RequestBeforeSendEventTest.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

30 lines
802 B
PHP

<?php
namespace GuzzleHttp\Tests\Event;
use GuzzleHttp\Adapter\Transaction;
use GuzzleHttp\Client;
use GuzzleHttp\Event\BeforeEvent;
use GuzzleHttp\Message\Request;
use GuzzleHttp\Message\Response;
/**
* @covers GuzzleHttp\Event\BeforeEvent
*/
class BeforeEventTest extends \PHPUnit_Framework_TestCase
{
public function testInterceptsWithEvent()
{
$response = new Response(200);
$res = null;
$t = new Transaction(new Client(), new Request('GET', '/'));
$t->getRequest()->getEmitter()->on('complete', function ($e) use (&$res) {
$res = $e;
});
$e = new BeforeEvent($t);
$e->intercept($response);
$this->assertTrue($e->isPropagationStopped());
$this->assertSame($res->getClient(), $e->getClient());
}
}