The PUBSUB_EMULATOR_HOST environment variable from the gcloud SDK is
honored, otherwise the actual API endpoint will be used.
/** * @dataProvider methodProvider * @todo revisit this approach */ public function testCallBasicMethods($method) { $options = []; $request = new Request('GET', '/somewhere'); $response = new Response(200, [], $this->successBody); $requestBuilder = $this->prophesize(RequestBuilder::class); $requestBuilder->build(Argument::type('string'), Argument::type('string'), Argument::type('array'))->willReturn($request); $this->requestWrapper->send(Argument::type(RequestInterface::class), Argument::type('array'))->willReturn($response); $rest = new Rest(); $rest->setRequestBuilder($requestBuilder->reveal()); $rest->setRequestWrapper($this->requestWrapper->reveal()); $this->assertEquals(json_decode($this->successBody, true), $rest->{$method}($options)); }
public function __construct() { // call parent constructor parent::__construct(); // create the asyncronous curl handler $this->handler = new CurlMultiHandler(); $httpClient = new Client(['handler' => HandlerStack::create($this->handler)]); // have the request wrapper call guzzle asyncronously $this->setRequestWrapper(new RequestWrapper(['scopes' => PubSubClient::FULL_CONTROL_SCOPE, 'httpHandler' => function ($request, $options = []) use($httpClient) { return $httpClient->sendAsync($request, $options); }, 'authHttpHandler' => HttpHandlerFactory::build()])); }