function ALProfilesAPITest::testGetSegements in Acquia Lift Connector 7
File
- acquia_lift_profiles/tests/acquia_lift_profiles_unit.test, line 112
- Unit tests for Acquia Lift Profiles module.
Class
- ALProfilesAPITest
- @file
Unit tests for Acquia Lift Profiles module.
Code
function testGetSegements() {
$acquia_lift_profiles_api = $this
->getALProfilesAPI();
$acquia_lift_profiles_api
->getSegments();
$canonicalRequest = "GET\naccept:application/json\n/dashboard/rest/{$acquia_lift_profiles_api->getAccountName()}/segments";
$hmac = base64_encode(hash_hmac('sha1', $canonicalRequest, $this->secretKey, TRUE));
$auth_header = 'HMAC ' . $this->accessKey . ':' . $hmac;
$requests = array(
array(
'type' => 'get',
'uri' => "{$acquia_lift_profiles_api->getApiUrl()}/dashboard/rest/{$acquia_lift_profiles_api->getAccountName()}/segments",
'headers' => array(
'Authorization' => $auth_header,
'Accept' => 'application/json',
),
'options' => array(),
'body' => NULL,
),
);
$this
->assertAPIRequests($requests);
$logs = array();
$this
->assertLogs($logs);
$acquia_lift_profiles_api = $this
->getALProfilesAPI(TRUE);
try {
$acquia_lift_profiles_api
->getSegments();
$this
->fail('Exception should have been thrown');
} catch (Exception $e) {
}
$this
->assertAPIRequests($requests);
$logs = array(
array(
'level' => 'error',
'message' => 'Could not get segments from Acquia Lift Profiles "500 Internal Server Error"',
),
);
$this
->assertLogs($logs);
ALProfilesAPI::reset();
}