function AcquiaLiftWebTestTarget::testAssignVariations in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 tests/acquia_lift.test \AcquiaLiftWebTestTarget::testAssignVariations()
File
- tests/
acquia_lift.test, line 3351 - Integration tests for Acquia Lift module.
Class
Code
function testAssignVariations() {
module_load_include('inc', 'acquia_lift', 'acquia_lift.admin');
$agent = $this
->createTargetingAgent();
$this
->assertFalse(isset($agent->data['lift_targeting']));
$this
->resetAll();
list($option_set, ) = $this
->createOptionSet(0, array(
'plugin' => 'blocks',
'agent' => $agent->machine_name,
'option_ids' => array(
'first-choice',
'second-choice',
'third-choice',
),
), FALSE);
$this
->resetAll();
// Try to set up targeting with a non-existent audience.
$audience_name = personalize_generate_machine_name($this
->randomName(), NULL, '-');
$targeting = array(
$audience_name => array(
'second-choice',
'third-choice',
),
);
try {
acquia_lift_save_targeting_structure($agent, $targeting);
$this
->fail('Should not reach here');
} catch (AcquiaLiftException $e) {
$this
->assertEqual('Invalid audience', $e
->getMessage());
}
// Now create the audience and try again.
$this
->createTargetAudience($option_set, $audience_name);
$this
->resetAll();
try {
acquia_lift_save_targeting_structure($agent, $targeting);
} catch (AcquiaLiftException $e) {
$this
->fail('Exception thrown when none expected.');
}
$this
->assertEqual($targeting, $agent->data['lift_targeting']);
}