function it_generates_the_expected_request_when_listing_notifications()
 {
     //---------------------------------
     // Test Setup
     $filters = ['status' => 'delivered', 'page' => '1', 'template_type' => 'sms'];
     $this->httpClient->sendRequest(Argument::type('Psr\\Http\\Message\\RequestInterface'))->willReturn(new Response(200, ['Content-type' => 'application/json'], json_encode(['notifications' => array()])));
     //---------------------------------
     // Perform action
     $this->listNotifications($filters);
     //---------------------------------
     // Check result
     // Check the expected Request was sent.
     $this->httpClient->sendRequest(Argument::that(function ($v) use($filters) {
         // Check a request was sent.
         if (!$v instanceof RequestInterface) {
             return false;
         }
         //---
         $url = new Uri(self::BASE_URL . Client::PATH_NOTIFICATION_LIST);
         foreach ($filters as $name => $value) {
             $url = URI::withQueryValue($url, $name, $value);
         }
         // With the correct URL
         if ($v->getUri() != $url) {
             return false;
         }
         //---
         // Include the correct token header
         if ($v->getHeader('Authorization') != ['Bearer ' . self::TEST_JWT_TOKEN]) {
             return false;
         }
         // And correct Content-type
         if ($v->getHeader('Content-type') != ['application/json']) {
             return false;
         }
         return true;
     }))->shouldHaveBeenCalled();
 }
 /**
  * Performs a GET against the Notify API.
  *
  * @param string $path
  * @param array  $query
  *
  * @return array|null
  * @throw Exception\NotifyException | Exception\ApiException | Exception\UnexpectedValueException
  */
 private function httpGet($path, array $query = array())
 {
     $url = new Uri($this->baseUrl . $path);
     foreach ($query as $name => $value) {
         $url = URI::withQueryValue($url, $name, $value);
     }
     //---
     $request = new Request('GET', $url, $this->buildHeaders());
     try {
         $response = $this->getHttpClient()->sendRequest($request);
     } catch (\RuntimeException $e) {
         throw new Exception\NotifyException($e->getMessage(), $e->getCode(), $e);
     }
     //---
     switch ($response->getStatusCode()) {
         case 200:
             return $this->handleResponse($response);
         case 404:
             return null;
         default:
             return $this->handleErrorResponse($response);
     }
 }