public function AcquiaLiftTest::testHasAutoTargetingRule in Acquia Lift Connector 7
Test AcquiaLiftAPI->testHasAutoTargetingRule()
File
- tests/
AcquiaLiftAPI.test, line 1071 - Unit tests for Acquia Lift module.
Class
- AcquiaLiftTest
- @file Unit tests for Acquia Lift module.
Code
public function testHasAutoTargetingRule() {
$lift_api = $this
->getAcquiaLiftAPI();
$agentName = 'some-agent-name';
$result = $lift_api
->hasAutoTargetingRule($agentName);
// Define the requests we expect to have been made to our dummy http
// client for this operation.
$requests = array(
array(
'type' => 'get',
'uri' => "{$lift_api->getApiUrl()}/{$lift_api->getOwnerCode()}/transforms-list?apikey={$lift_api->getAdminKey()}",
'headers' => array(
'Accept' => 'application/json',
),
'options' => array(),
'body' => NULL,
),
);
// Confirm the expected requests were made.
$this
->assertAPIRequests($requests);
// Confirm that we received a boolean false as the result.
$this
->assertTrue($result === FALSE);
$logs = array();
$this
->assertLogs($logs);
$lift_api = $this
->getAcquiaLiftAPI(TRUE);
$msg = 'Problem retrieving auto-targeting rules';
try {
$lift_api
->hasAutoTargetingRule($agentName);
$this
->fail("Should not reach here");
} catch (Exception $e) {
$this
->assertTrue($e instanceof AcquiaLiftException);
$this
->assertEqual($msg, $e
->getMessage());
}
// Confirm the expected requests were made.
$this
->assertAPIRequests($requests);
$logs = array(
array(
'level' => PersonalizeLogLevel::ERROR,
'message' => $msg,
),
);
$this
->assertLogs($logs);
}