You are here

protected function ALProfilesAPITest::getALProfilesAPI in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7 acquia_lift_profiles/tests/acquia_lift_profiles_unit.test \ALProfilesAPITest::getALProfilesAPI()

Returns a ALProfilesAPI instance that can be used to test methods.

Parameters

bool $broken: Whether the HTTP client used by the API class should be broken, simulating 500 responses from Acquia Lift Profiles.

Return value

ALProfilesAPI A ALProfilesAPI instance.

4 calls to ALProfilesAPITest::getALProfilesAPI()
ALProfilesAPITest::testCanonicalizeRequest in acquia_lift_profiles/tests/acquia_lift_profiles_unit.test
Tests the method that canonicalizes a request into a string for signing.
ALProfilesAPITest::testDeleteEvent in acquia_lift_profiles/tests/acquia_lift_profiles_unit.test
Test ALProfilesAPI->deleteEvent()
ALProfilesAPITest::testGetSegments in acquia_lift_profiles/tests/acquia_lift_profiles_unit.test
ALProfilesAPITest::testSaveEvent in acquia_lift_profiles/tests/acquia_lift_profiles_unit.test
Test ALProfilesAPI->saveEvent()

File

acquia_lift_profiles/tests/acquia_lift_profiles_unit.test, line 400
Unit tests for Acquia Lift Profiles module.

Class

ALProfilesAPITest
@file Unit tests for Acquia Lift Profiles module.

Code

protected function getALProfilesAPI($broken = FALSE) {

  // Make sure calls to variable_get() for the customer site return an empty string.
  global $conf;
  $original_conf = $conf;
  $conf['acquia_lift_profiles_site_name'] = '';
  $acquia_lift_profiles_api = ALProfilesAPI::getInstance($this->accountName, $this->customerSite, $this->apiUrl, $this->accessKey, $this->secretKey);
  $conf = $original_conf;

  // Create a dummy http client for the Acquia Lift Profiles API to use. All
  // requests to it will be logged and retrievable for checking later.
  $this->httpClient = new DummyALProfilesHttpClient($broken);
  $acquia_lift_profiles_api
    ->setHttpClient($this->httpClient);
  if ($this->logger === NULL) {

    // Create a dummy logger instance which will maintain a log in memory
    // that we can retrieve for checking later.
    $this->logger = new AcquiaLiftTestLogger(FALSE);
  }
  $acquia_lift_profiles_api
    ->setLogger($this->logger);
  return $acquia_lift_profiles_api;
}