function AcquiaLiftWebTestCampaignWizardReview::testReviewSubmit in Acquia Lift Connector 7.2
Tests the submission of the review form which results in nested tests being created.
File
- tests/
acquia_lift.test, line 4298 - Integration tests for Acquia Lift module.
Class
Code
function testReviewSubmit() {
// Provide context options to enable targeting page.
module_enable(array(
'personalize_url_context',
));
$this
->resetAll();
$this
->resetAll();
$parent_settings = array(
'control_rate' => 20,
'explore_rate' => 40,
'decision_style' => 'random',
'cache_decisions' => 0,
);
$agent = $this
->createTargetingAgent($this
->randomName(), $parent_settings);
$option_set = $this
->createOptionSet(1, array(
'agent' => $agent->machine_name,
'plugin' => 'type1',
'num_options' => 2,
));
// Add the new options to a test.
$this
->createTestFromOptionSet($agent, $option_set);
// Start the agent.
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/review');
$this
->assertNoText(t('Next steps'));
$this
->drupalPost(NULL, array(), $this
->getButton('wizard_start'));
// Confirm message and next steps block.
$this
->assertText(t('Congratulations! You have started your personalization.'));
$this
->assertText(t('Need help?'));
// Confirm settings are propagated.
$this
->resetAll();
$agent = personalize_agent_load($agent->machine_name, TRUE);
$status = personalize_agent_get_status($agent->machine_name);
$this
->assertEqual($status, PERSONALIZE_STATUS_RUNNING);
foreach ($parent_settings as $setting => $value) {
$this
->assertEqual($agent->data[$setting], $value);
}
$nested_tests = acquia_lift_get_nested_tests($agent);
$nested_settings = $parent_settings;
// The cache_decisions setting should be 1 instead of 0.
$nested_settings['cache_decisions'] = 1;
// Explore rate should be set to 1;
$nested_settings['explore_rate'] = 100;
$nested1 = personalize_agent_load($nested_tests[0]);
foreach ($nested_settings as $setting => $value) {
$this
->assertEqual($nested1->data[$setting], $value);
}
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/review');
module_load_include('inc', 'acquia_lift', 'acquia_lift.admin');
acquia_lift_target_set_status($agent, PERSONALIZE_STATUS_PAUSED);
$this
->resetAll();
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/review');
// Confirm that the next steps still show even after pausing.
$this
->assertText(t('Need help?'));
$changes = array(
'control_rate' => 30,
'explore_rate' => 60,
'decision_style' => 'adaptive',
);
$this
->drupalPost('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting', $changes, $this
->getButton('wizard_next', array(
'agent_name' => $agent->machine_name,
'step' => 'targeting',
)));
$this
->drupalPost('admin/structure/personalize/manage/' . $agent->machine_name . '/review', array(), $this
->getButton('wizard_start'));
$this
->assertText(t('Congratulations! You have started your personalization.'));
$this
->assertText(t('Need help?'));
$this
->resetAll();
$agent = personalize_agent_load($agent->machine_name, TRUE);
// Confirm the changes propagated to the nested test.
$parent_settings['control_rate'] = $nested_settings['control_rate'] = 30;
$parent_settings = array_merge($parent_settings, $changes);
$nested_settings = array_merge($nested_settings, $changes);
$this
->assertEqual($agent->data['control_rate'], $parent_settings['control_rate']);
$this
->assertEqual($agent->data['explore_rate'], $parent_settings['explore_rate']);
$this
->assertEqual($agent->data['explore_rate'], $parent_settings['explore_rate']);
$nested1 = personalize_agent_load($nested1->machine_name, TRUE);
foreach ($nested_settings as $setting => $value) {
$this
->assertEqual($nested1->data[$setting], $value);
}
}