public function AcquiaLiftTest::testDeleteGoal in Acquia Lift Connector 7
Test AcquiaLiftAPI->deleteGoal()
File
- tests/
AcquiaLiftAPI.test, line 644 - Unit tests for Acquia Lift module.
Class
- AcquiaLiftTest
- @file Unit tests for Acquia Lift module.
Code
public function testDeleteGoal() {
$lift_api = $this
->getAcquiaLiftAPI();
$agentName = 'some-test-agent';
$goalName = 'goal-1';
$lift_api
->deleteGoal($agentName, $goalName);
// Define the requests we expect to have been made to our dummy http
// client for this operation.
$requests = array(
array(
'type' => 'delete',
'uri' => "{$lift_api->getApiUrl()}/{$lift_api->getOwnerCode()}/agent-api/{$agentName}/goals/{$goalName}?apikey={$lift_api->getAdminKey()}",
'headers' => NULL,
'options' => array(),
'body' => NULL,
),
);
// Confirm the expected requests were made.
$this
->assertAPIRequests($requests);
$logs = array(
array(
'level' => PersonalizeLogLevel::INFO,
'message' => "The goal {$goalName} was deleted from the Acquia Lift campaign {$agentName}",
),
);
$this
->assertLogs($logs);
$lift_api = $this
->getAcquiaLiftAPI(TRUE);
try {
$lift_api
->deleteGoal($agentName, $goalName);
} catch (Exception $e) {
$this
->assertTrue($e instanceof AcquiaLiftException);
}
// Confirm the expected requests were made.
$this
->assertAPIRequests($requests);
$logs = array(
array(
'level' => PersonalizeLogLevel::ERROR,
'message' => "Could not delete the goal {$goalName} from the Acquia Lift campaign {$agentName}",
),
);
$this
->assertLogs($logs);
}