You are here

class MailchimpTestHttpClient in Mailchimp 8

A dummy HTTP client used when running unit tests. Does not make any real API requests.

@package Mailchimp\Tests

Hierarchy

Expanded class hierarchy of MailchimpTestHttpClient

File

lib/mailchimp-api-php/tests/src/MailchimpTestHttpClient.php, line 16

Namespace

Mailchimp\Tests
View source
class MailchimpTestHttpClient implements MailchimpHttpClientInterface {
  public $method;
  public $uri;
  public $options;

  /**
   * @inheritdoc
   */
  public function handleRequest($method, $uri = '', $options = [], $parameters = [], $returnAssoc = FALSE) {
    if (!empty($parameters)) {
      if ($method == 'GET') {

        // Send parameters as query string parameters.
        $options['query'] = $parameters;
      }
      else {

        // Send parameters as JSON in request body.
        $options['json'] = (object) $parameters;
      }
    }
    $this->method = $method;
    $this->uri = $uri;
    $this->options = $options;
    return new MailchimpTestHttpResponse();
  }

}

Members