/** * @covers PusherSignature::signRequest */ public function testCanSignRequest() { $request = new HttpRequest('POST', '/apps/3/events'); // We set variables in query to have always the same result $request->getQuery()->replace(array('auth_key' => $this->credentials->getKey(), 'auth_timestamp' => '1353088179', 'auth_version' => '1.0', 'body_md5' => 'ec365a775a4cd0599faeb73354201b6f')); $request->setResponseBody('{"name":"foo","channels":["project-3"],"data":"{\\"some\\":\\"data\\"}"}'); $this->pusherSignature->signRequest($request, $this->credentials); $this->assertEquals('auth_key=278d425bdf160c739803&auth_timestamp=1353088179&auth_version=1.0&body_md5=ec365a775a4cd0599faeb73354201b6f&auth_signature=da454824c97ba181a32ccc17a72625ba02771f50b50e1e7430e47a1f3f457e6c', $request->getQuery('auth_signature')); }
/** * Users sometimes want to use a custom stream when receiving a response body. * Because of the various potential for retrying failed requests, the stream * specified by the user should only be written to in the event that a * successful response was received. Otherwise, a new temp stream is created * to store the body of the failed request. * * @covers Guzzle\Http\Message\Request::receiveResponseHeader */ public function testReceivingUnsuccessfulResponseUsesOtherResponseBody() { $request = new Request('GET', $this->getServer()->getUrl()); $body = EntityBody::factory(); $request->setResponseBody($body); $request->receiveResponseHeader('HTTP/1.1 503 Service Unavailable'); $this->assertNotSame($body, $request->getResponse()->getBody()); }