public function testProxyUriOverridesDefaultUrl() { $proxy = 'my_nice_proxy_around_that_server'; $this->fixture->setProxyApiUrl($proxy); $guzzle = \Mockery::mock(\GuzzleHttp\Client::class); $guzzle->shouldReceive('post')->once()->with($proxy, \Mockery::any())->andReturn(\Mockery::mock(Response::class)); $this->fixture->injectHttpClient($guzzle); $message = new Message(); $message->addRecipient(new Topic('test')); $this->fixture->send($message); }
/** * sends your notification to the google servers and returns a guzzle repsonse object * containing their answer. * * @param Message $message * * @return \Psr\Http\Message\ResponseInterface * @throws \GuzzleHttp\Exception\RequestException */ public function send(Message $message) { $headers = ['Authorization' => sprintf('key=%s', $this->apiKey), 'Content-Type' => 'application/json']; if (count($message->getEncryptionHeaders()) > 0) { $headers = array_merge($headers, $message->getEncryptionHeaders()); $body = $message->getEncryptedData(); } else { $body = json_encode($message); } return $this->guzzleClient->post($this->getApiUrl(), ['headers' => $headers, 'body' => $body]); }