You are here

protected function AcquiaLiftTest::getAcquiaLiftAPI in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 tests/AcquiaLiftAPI.test \AcquiaLiftTest::getAcquiaLiftAPI()

Returns a AcquiaLiftAPI 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.

Return value

AcquiaLiftAPI A AcquiaLiftAPI instance.

30 calls to AcquiaLiftTest::getAcquiaLiftAPI()
AcquiaLiftTest::assertConfidenceReportAPI in tests/AcquiaLiftAPI.test
Helper function to call the confidence report endpoint and verify the API request.
AcquiaLiftTest::testDeleteChoice in tests/AcquiaLiftAPI.test
Test AcquiaLiftAPI->deleteChoice()
AcquiaLiftTest::testDeleteDecision in tests/AcquiaLiftAPI.test
Test AcquiaLiftAPI->deleteDecision()
AcquiaLiftTest::testDeleteGoal in tests/AcquiaLiftAPI.test
Test AcquiaLiftAPI->deleteGoal()
AcquiaLiftTest::testDeletePoint in tests/AcquiaLiftAPI.test
Test AcquiaLiftAPI->deletePoint()

... See full list

File

tests/AcquiaLiftAPI.test, line 2005
Unit tests for Acquia Lift module.

Class

AcquiaLiftTest
@file Unit tests for Acquia Lift module.

Code

protected function getAcquiaLiftAPI($broken = FALSE) {
  $lift_api = AcquiaLiftAPI::getInstance(array(
    'api_key' => $this->liftAPIKey,
    'admin_key' => $this->liftAdminKey,
    'owner_code' => $this->liftOwnerCode,
  ));

  // Create a dummy http client for the Acquia Lift API to use. All
  // requests to it will be logged and retrievable for checking later.
  $this->httpClient = new DummyAcquiaLiftHttpClient($broken);
  $lift_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();
  }
  else {
    $this->logger
      ->clearLogs();
  }
  $lift_api
    ->setLogger($this->logger);
  return $lift_api;
}