public function AcquiaLiftWebTestFundamentals::testBatchSyncOperations in Acquia Lift Connector 7.2
Same name and namespace in other branches
- 7 tests/acquia_lift.test \AcquiaLiftWebTestFundamentals::testBatchSyncOperations()
Tests the function that gathers operations for syncing of agents and their components to Lift.
File
- tests/
acquia_lift.test, line 888 - Integration tests for Acquia Lift module.
Class
Code
public function testBatchSyncOperations() {
AcquiaLiftAPI::setTestInstance();
module_load_include('inc', 'acquia_lift', 'acquia_lift.batch');
// Create a targeting agent with a single nested test.
$agent = $this
->createTargetingAgentWithNestedTest(4);
personalize_goal_save($agent->machine_name, 'user_login', 1);
$this
->resetAll();
$test_agents = personalize_agent_load_by_type(ACQUIA_LIFT_TESTING_AGENT);
$test_agent = reset($test_agents);
$os = personalize_option_set_load_by_agent($test_agent->machine_name);
$sub_option_set = reset($os);
// Add a couple of tests for deletion to ensure they show up in the batch
// operations.
$agent->tests_to_delete = array(
'first-test',
'second-test',
);
$operations = acquia_lift_get_sync_operations_for_agent($agent);
$decision_name = 'drupal-osid-' . $sub_option_set->osid;
$expected_operations = array(
array(
'method' => 'deleteAgent',
'args' => array(
'first-test',
),
),
array(
'method' => 'deleteAgent',
'args' => array(
'second-test',
),
),
array(
'method' => 'saveDecisionSet',
'args' => array(
$decision_name,
'Sub-test for ' . $agent->label,
array(
array(
'option_id' => 'option-1',
),
array(
'option_id' => 'option-2',
),
array(
'option_id' => 'option-3',
),
array(
'option_id' => 'option-4',
),
),
),
),
array(
'method' => 'saveGoal',
'args' => array(
'drupal-clicks_option_set_1',
),
),
array(
'method' => 'saveGoal',
'args' => array(
'drupal-user_login',
),
),
array(
'method' => 'saveCampaign',
'args' => array(
$test_agent->machine_name,
'Sub-test for ' . $agent->label,
$decision_name,
array(
'drupal-clicks_option_set_1',
'drupal-user_login',
),
FALSE,
0,
1,
),
),
);
$this
->assertEqual($expected_operations, $operations);
}