public function AcquiaLiftTest::testResetAgentData in Acquia Lift Connector 7
File
- tests/
AcquiaLiftAPI.test, line 1807 - Unit tests for Acquia Lift module.
Class
- AcquiaLiftTest
- @file Unit tests for Acquia Lift module.
Code
public function testResetAgentData() {
$lift_api = $this
->getAcquiaLiftAPI();
$agent_name = 'my-test-agent';
try {
$lift_api
->resetAgentData($agent_name);
} catch (Exception $e) {
$this
->fail('Exception thrown when none expected');
}
// Define the requests we expect to have been made to our dummy http
// client for this operation.
$requests = array(
array(
'type' => 'delete',
'uri' => "http://api.lift.acquia.com/{$this->liftOwnerCode}/{$agent_name}/data?apikey={$this->liftAdminKey}",
'headers' => NULL,
'options' => array(),
'body' => NULL,
),
);
// Confirm the expected requests were made.
$this
->assertAPIRequests($requests);
// Confirm the expected messages were logged.
$logs = array(
array(
'level' => PersonalizeLogLevel::INFO,
'message' => "The data for Acquia Lift campaign {$agent_name} was reset",
),
);
$this
->assertLogs($logs);
$this->logger
->clearLogs();
// Now try with a broken http client.
$lift_api = $this
->getAcquiaLiftAPI(TRUE);
try {
$lift_api
->resetAgentData($agent_name);
} catch (Exception $e) {
$this
->assertTrue($e instanceof AcquiaLiftException);
}
// Confirm the expected requests were made.
$this
->assertAPIRequests($requests);
// Confirm the expected messages were logged.
$logs = array(
array(
'level' => PersonalizeLogLevel::ERROR,
'message' => "Could not reset data for Acquia Lift campaign {$agent_name}",
),
);
$this
->assertLogs($logs);
$this->logger
->clearLogs();
}