class AcquiaLiftWebTestWorkflow in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 tests/acquia_lift.test \AcquiaLiftWebTestWorkflow
Hierarchy
- class \DrupalTestCase
- class \DrupalWebTestCase
- class \AcquiaLiftWebTestBase
- class \AcquiaLiftWebTestWorkflow
- class \AcquiaLiftWebTestBase
- class \DrupalWebTestCase
Expanded class hierarchy of AcquiaLiftWebTestWorkflow
File
- tests/
acquia_lift.test, line 2494 - Integration tests for Acquia Lift module.
View source
class AcquiaLiftWebTestWorkflow extends AcquiaLiftWebTestBase {
public static function getInfo() {
return array(
'name' => t('Acquia Lift Web Tests - Workflows'),
'description' => t('Tests functionality related to particular campaign workflows.'),
'group' => t('Personalize'),
);
}
/**
* Tests automatic creation of a goal for personalized fields and auto-
* starting of the campaign.
*/
public function testPersonalizeFieldsAutoCreateGoal() {
$this
->resetAll();
module_enable(array(
'personalize_fields',
));
$this
->resetAll();
$admin_user = $this
->drupalCreateUser(array(
'access administration pages',
'administer site configuration',
'access content',
'administer content types',
'administer nodes',
'bypass node access',
'manage personalized content',
));
$this
->drupalLogin($admin_user);
// Add personalizable field to the article node type.
$field = array(
'type' => 'text',
'field_name' => 'article_headline',
'cardinality' => -1,
'settings' => array(
'personalize' => array(
'enabled' => 1,
'agent_type' => 'acquia_lift',
'options' => array(
'acquia_lift' => array(
'control_rate' => 10,
'decision_style' => 'adaptive',
'explore_rate' => 25,
),
),
'create_goal' => 1,
'auto_start' => 1,
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'article_headline',
'entity_type' => 'node',
'label' => 'Personalizable Headline',
'bundle' => 'article',
'required' => FALSE,
);
field_create_instance($instance);
list($node1, $os1, $agent_name) = $this
->createPersonalizedField();
$first_osid = 'osid-' . $os1->osid;
$goals = personalize_goal_load_by_conditions(array(
'agent' => $agent_name,
));
$this
->assertEqual(1, count($goals));
$goal = reset($goals);
$action = visitor_actions_custom_load($goal->action);
$this
->assertEqual('click', $action['event']);
$this
->assertEqual('[data-personalize=osid-1]', $action['identifier']);
$action_name = personalize_generate_machine_name(t('Clicks @option_set', array(
'@option_set' => $os1->label,
)), NULL, '_');
$this
->assertEqual($action_name, $action['machine_name']);
$this
->assertTrue($action['limited_use']);
$expected_queue_items = array(
array(
'method' => 'saveAgent',
'args' => array(
$agent_name,
'Article: Personalizable Headline 1',
'adaptive',
PERSONALIZE_STATUS_NOT_STARTED,
10 / 100,
25 / 100,
true,
),
'agent' => $agent_name,
),
array(
'method' => 'savePoint',
'args' => array(
$agent_name,
$first_osid,
),
'agent' => $agent_name,
),
array(
'method' => 'saveDecision',
'args' => array(
$agent_name,
$first_osid,
$first_osid,
),
'agent' => $agent_name,
),
array(
'method' => 'saveChoice',
'args' => array(
$agent_name,
$first_osid,
$first_osid,
'first-value',
),
'agent' => $agent_name,
),
array(
'method' => 'saveChoice',
'args' => array(
$agent_name,
$first_osid,
$first_osid,
'second-value',
),
'agent' => $agent_name,
),
array(
'method' => 'saveGoal',
'args' => array(
$agent_name,
$action_name,
),
'agent' => $agent_name,
),
array(
'callback' => 'personalize_agent_set_status',
'args' => array(
$agent_name,
PERSONALIZE_STATUS_RUNNING,
),
),
);
$this
->assertQueueItems($expected_queue_items);
// Manually set the agent's status to running, bypassing the verification check.
variable_set(_personalize_agent_get_status_variable($agent_name), PERSONALIZE_STATUS_RUNNING);
$this
->resetAll();
$expected_action_listeners = array(
$action_name => array(
array(
'agent' => $agent_name,
'value' => 1,
),
),
);
// Confirm that the goal is in the js settings on the /user page.
$this
->drupalGet('user');
$settings = $this
->drupalGetSettings();
$this
->assertEqual($expected_action_listeners, $settings['personalize']['actionListeners']);
// Change the field settings to specify particular pages for the goal.
$edit = array(
'field[settings][personalize][goal_pages]' => "node",
);
$this
->drupalPost('admin/structure/types/manage/article/fields/article_headline', $edit, t('Save settings'));
$this
->resetAll();
// Create another personalized field on a new node.
list($node2, $os2, $second_agent) = $this
->createPersonalizedField();
// Manually set the agent's status to running, bypassing the verification check.
variable_set(_personalize_agent_get_status_variable($second_agent), PERSONALIZE_STATUS_RUNNING);
$this
->resetAll();
$goals = personalize_goal_load_by_conditions(array(
'agent' => $second_agent,
));
$this
->assertEqual(1, count($goals));
$goal = reset($goals);
// Confirm that the goal is *not* in the js settings on the user page but is
// on the node page.
$this
->drupalGet('user');
$settings = $this
->drupalGetSettings();
$this
->assertFalse(isset($settings['personalize']['actionListeners'][$goal->action]));
$this
->drupalGet('node');
$settings = $this
->drupalGetSettings();
$expected_action_listeners[$goal->action] = array(
array(
'agent' => $second_agent,
'value' => 1,
),
);
$this
->assertEqual($expected_action_listeners, $settings['personalize']['actionListeners']);
$this->personalizedQueue
->deleteQueue();
// Now change the field settings to not auto-create a goal.
$edit = array(
'field[settings][personalize][create_goal]' => FALSE,
);
$this
->drupalPost('admin/structure/types/manage/article/fields/article_headline', $edit, t('Save settings'));
list($node3, $os3, $third_agent) = $this
->createPersonalizedField();
$third_osid = 'osid-' . $os3->osid;
$this
->resetAll();
// Confirm that our agent and option set were created.
$option_set = personalize_option_set_load($os3->osid);
$this
->assertEqual($third_agent, $option_set->agent);
// There should be no goal for this agent.
$goals = personalize_goal_load_by_conditions(array(
'agent' => $third_agent,
));
$this
->assertTrue(empty($goals));
// We should only have items in the queue for saving the agent and the
// option set.
$expected_queue_items = array(
array(
'method' => 'saveAgent',
'args' => array(
$third_agent,
'Article: Personalizable Headline 3',
'adaptive',
PERSONALIZE_STATUS_NOT_STARTED,
10 / 100,
25 / 100,
true,
),
'agent' => $third_agent,
),
array(
'method' => 'savePoint',
'args' => array(
$third_agent,
$third_osid,
),
'agent' => $third_agent,
),
array(
'method' => 'saveDecision',
'args' => array(
$third_agent,
$third_osid,
$third_osid,
),
'agent' => $third_agent,
),
array(
'method' => 'saveChoice',
'args' => array(
$third_agent,
$third_osid,
$third_osid,
'first-value',
),
'agent' => $third_agent,
),
array(
'method' => 'saveChoice',
'args' => array(
$third_agent,
$third_osid,
$third_osid,
'second-value',
),
'agent' => $third_agent,
),
);
$this
->assertQueueItems($expected_queue_items);
}
/**
* Tests the logic of AcquiaLiftAgent's stopNow() implementation in the
* simplest use case.
*/
function testAutoStop() {
// Create a new agent via the UI.
$agent = $this
->createTestAgent(array(
'control_rate' => 10,
'explore_rate' => 30,
'auto_stop' => 1,
), TRUE, FALSE);
$machine_name = $agent
->getMachineName();
$agent_data = personalize_agent_load($machine_name, TRUE);
// Set the start time of the agent to 2 minutes ago.
$agent_data->started = time() - 120;
// Most basic case - a single option set with 2 options.
list($option_set, $new_queue_items) = $this
->createOptionSet(0, array(
'agent' => $machine_name,
'plugin' => 'type1',
'num_options' => 3,
));
$osid = 'osid-' . $option_set->osid;
// Generate the reporting data to be returned by the dummy http client for this
// agent.
$points = array(
$osid => array(
$osid . ':option-A',
$osid . ':option-B',
$osid . ':option-C',
),
);
$test_data = array(
'reports' => array(
$machine_name => array(
// Generate a fake confidence report with no clear winner.
'confidence' => AcquiaLiftTestReports::generateConfidenceReportWithWinners($machine_name, $points),
),
),
);
variable_set('acquia_lift_web_test_data', $test_data);
// Ensure no other criteria are used to determine whether we should stop.
variable_set('acquia_lift_min_decisions', 0);
variable_set('acquia_lift_min_runtime_num', 0);
$this
->resetAll();
// Make sure we are using a test instance of the API client.
AcquiaLiftAPI::setTestInstance();
$stop = $agent
->stopNow();
// The call should return FALSE as neither minimum runtime nor minimum decisions
// has been configured as a basis on which to stop.
$this
->assertFalse($stop);
// No winner should have been set on the option set.
$option_set = personalize_option_set_load(1, TRUE);
$this
->assertNull($option_set->winner);
// Set min decisions to 30 and we should get option C set as the winner (just
// because the test data is set up to give higher values to later options
// if not otherwise specified.)
variable_set('acquia_lift_min_decisions', 30);
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
$stop = $agent_instance
->stopNow();
$this
->assertTrue($stop);
// Confirm the winner has been set on the option set.
$option_set = personalize_option_set_load($option_set->osid, TRUE);
$this
->assertEqual('option-C', $option_set->winner);
// Now generate a report where option B has the highest estimated value.
$test_data = array(
'reports' => array(
$machine_name => array(
'confidence' => AcquiaLiftTestReports::generateConfidenceReportWithWinners($machine_name, $points, array(
$osid => $osid . ':option-B',
)),
),
),
);
variable_set('acquia_lift_web_test_data', $test_data);
$this
->resetAll();
AcquiaLiftAPI::setTestInstance();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
$stop = $agent_instance
->stopNow();
$this
->assertTrue($stop);
// Confirm the winner has been set on the option set.
$option_set = personalize_option_set_load($option_set->osid, TRUE);
$this
->assertEqual('option-B', $option_set->winner);
// Setting the minimum number of decisions to 100 will mean we won't have enough
// decisions so we should get FALSE.
variable_set('acquia_lift_min_decisions', 100);
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
$stop = $agent_instance
->stopNow();
$this
->assertFalse($stop);
// Setting it to 30 should get TRUE again.
variable_set('acquia_lift_min_decisions', 30);
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
$stop = $agent_instance
->stopNow();
$this
->assertTrue($stop);
// Setting the minimum runtime to 1 day should give us FALSE.
variable_set('acquia_lift_min_runtime_num', 1);
variable_set('acquia_lift_min_runtime_unit', 'day');
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
$stop = $agent_instance
->stopNow();
$this
->assertFalse($stop);
// Setting the minimum runtime to 1 minute should give us TRUE again.
variable_set('acquia_lift_min_runtime_unit', 'minute');
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
$stop = $agent_instance
->stopNow();
$this
->assertTrue($stop);
}
/**
* Tests the logic of AcquiaLiftAgent's stopNow() implementation when the agent
* has mulitple decision points including an MVT.
*/
function testAutoStopMultiplePoints() {
// Create a new agent.
$agent = $this
->createTestAgent(array(
'control_rate' => 10,
'explore_rate' => 30,
'auto_stop' => 1,
), TRUE, FALSE);
$machine_name = $agent
->getMachineName();
// This time we'll add 3 option sets.
$option_set_values = array(
array(
'agent' => $machine_name,
'plugin' => 'type1',
'num_options' => 3,
),
array(
'agent' => $machine_name,
'plugin' => 'type2',
'num_options' => 2,
),
array(
'agent' => $machine_name,
'plugin' => 'type2',
'num_options' => 3,
),
);
$option_sets = array();
foreach ($option_set_values as $i => $values) {
list($option_set, $new_queue_items) = $this
->createOptionSet($i, $values);
$option_sets[] = $option_set;
}
$first_osid = 'osid-' . $option_sets[0]->osid;
$second_osid = 'osid-' . $option_sets[1]->osid;
$third_osid = 'osid-' . $option_sets[2]->osid;
// Create an MVT and add two of the option sets to it.
$mvt_label = $this
->randomName();
$mvt_machine_name = personalize_generate_machine_name($mvt_label, 'personalize_mvt_machine_name_exists');
$edit = array(
'mvt[add][mvt_basic_info][label]' => $mvt_machine_name,
'mvt[add][mvt_basic_info][option_sets][]' => array(
$option_sets[1]->osid,
$option_sets[2]->osid,
),
);
$this
->drupalPost("admin/structure/personalize/manage/{$machine_name}/edit", $edit, $this
->getButton('mvt'));
// Generate the reporting data to be returned by the dummy http client for this
// agent. All possible choices at each decision point need to be accounted for in
// the report.
$points = array(
$first_osid => array(
$first_osid . ':option-A',
$first_osid . ':option-B',
$first_osid . ':option-C',
),
$mvt_machine_name => array(
$second_osid . ':option-A,' . $third_osid . ':option-A',
$second_osid . ':option-A,' . $third_osid . ':option-B',
$second_osid . ':option-A,' . $third_osid . ':option-C',
$second_osid . ':option-B,' . $third_osid . ':option-A',
$second_osid . ':option-B,' . $third_osid . ':option-B',
$second_osid . ':option-B,' . $third_osid . ':option-C',
),
);
$test_data = array(
'reports' => array(
$machine_name => array(
// We'll specify a winner at each decision point - for option set 1 it will be
// Option B and for the MVT it will be the combination of Option A and Option C
// in Option Sets 2 and 3 respectively.
'confidence' => AcquiaLiftTestReports::generateConfidenceReportWithWinners($machine_name, $points, array(
$first_osid => $first_osid . ':option-B',
$mvt_machine_name => $second_osid . ':option-A,' . $third_osid . ':option-C',
)),
),
),
);
variable_set('acquia_lift_web_test_data', $test_data);
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
// Set the minimum number of decisions to 30, and the minium runtime to 0 so
// that we know we'll get passed these two checks.
variable_set('acquia_lift_min_decisions', 30);
variable_set('acquia_lift_min_runtime_num', 0);
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
$stop = $agent_instance
->stopNow();
$this
->assertTrue($stop);
// CHeck that the winner has been set on each option set.
$option_sets = personalize_option_set_load_by_agent($machine_name, TRUE);
$osids = array_keys($option_sets);
$this
->assertEqual('option-B', $option_sets[$osids[0]]->winner);
$this
->assertEqual('option-A', $option_sets[$osids[1]]->winner);
$this
->assertEqual('option-C', $option_sets[$osids[2]]->winner);
// Setting the minimum number of decisions to 70 will mean the first decision point
// won't satisfy this so we should get FALSE from teh stopNow() call.
variable_set('acquia_lift_min_decisions', 70);
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
$stop = $agent_instance
->stopNow();
$this
->assertFalse($stop);
// Setting it to 60 should get TRUE again.
variable_set('acquia_lift_min_decisions', 60);
$this
->resetAll();
$agent_instance = personalize_agent_load_agent($machine_name, TRUE);
AcquiaLiftAPI::setTestInstance();
$stop = $agent_instance
->stopNow();
$this
->assertTrue($stop);
}
/**
* Tests campaign javascript settings.
*/
function testCampaignSettings() {
module_enable(array(
'personalize_test_extra_agent',
));
$this
->resetAll();
$this
->resetAll();
$admin_user = $this
->drupalCreateUser(array(
'access administration pages',
'manage personalized content',
));
$this
->drupalLogin($admin_user);
// Create two agents of different types.
$first_agent_name = $this
->randomName();
$first_agent_machine_name = personalize_generate_machine_name($first_agent_name, 'personalize_agent_machine_name_exists');
$second_agent_name = $this
->randomName();
$second_agent_machine_name = personalize_generate_machine_name($second_agent_name, 'personalize_agent_machine_name_exists');
$agents = array(
array(
'label' => $first_agent_name,
'machine_name' => $first_agent_machine_name,
'agent_type' => 'test_agent',
),
array(
'label' => $second_agent_name,
'machine_name' => $second_agent_machine_name,
'agent_type' => 'test_extra_agent',
),
);
foreach ($agents as $agent) {
$edit = array(
'agent_basic_info[title]' => $agent['label'],
'agent_basic_info[machine_name]' => $agent['machine_name'],
'agent_basic_info[agent_type]' => $agent['agent_type'],
);
$this
->drupalPost('admin/structure/personalize/add', $edit, $this
->getButton('agent'));
}
$expected = array(
$first_agent_machine_name => array(
'name' => $first_agent_machine_name,
'label' => $first_agent_name,
'type' => 'test_agent',
'status' => PERSONALIZE_STATUS_NOT_STARTED,
'nextStatus' => array(
'status' => PERSONALIZE_STATUS_RUNNING,
'text' => t('Start'),
),
'links' => array(
'edit' => url('admin/structure/personalize/manage/' . $first_agent_machine_name . '/edit'),
'report' => '',
'view' => url('admin/structure/personalize/manage/' . $first_agent_machine_name),
),
'supportsGoals' => TRUE,
'optionSetTypes' => array(),
'goals' => NULL,
'verified' => TRUE,
),
$second_agent_machine_name => array(
'name' => $second_agent_machine_name,
'label' => $second_agent_name,
'type' => 'test_extra_agent',
'status' => PERSONALIZE_STATUS_NOT_STARTED,
'nextStatus' => array(
'status' => PERSONALIZE_STATUS_RUNNING,
'text' => t('Start'),
),
'links' => array(
'edit' => url('admin/structure/personalize/manage/' . $second_agent_machine_name . '/edit'),
'report' => '',
'view' => url('admin/structure/personalize/manage/' . $second_agent_machine_name),
),
'supportsGoals' => FALSE,
'optionSetTypes' => array(),
'goals' => NULL,
'verified' => TRUE,
),
);
$settings = $this
->drupalGetSettings();
$this
->assertEqual($settings['acquia_lift']['campaigns'][$first_agent_machine_name], $expected[$first_agent_machine_name]);
$this
->assertEqual($settings['acquia_lift']['campaigns'][$second_agent_machine_name], $expected[$second_agent_machine_name]);
// Click the "start" button for the first agent.
$html_id_first_agent = "personalize-change-status-{$first_agent_machine_name}-form";
$this
->drupalPost('admin/structure/personalize', array(), t('Start'), array(), array(), $html_id_first_agent);
// As soon as the agent is started, we are able to access its reports.
$expected[$first_agent_machine_name]['links']['report'] = url('admin/structure/personalize/manage/' . $first_agent_machine_name . '/report');
$expected[$first_agent_machine_name]['status'] = PERSONALIZE_STATUS_RUNNING;
$expected[$first_agent_machine_name]['nextStatus'] = array(
'status' => PERSONALIZE_STATUS_PAUSED,
'text' => t('Pause'),
);
$settings = $this
->drupalGetSettings();
$this
->assertEqual($settings['acquia_lift']['campaigns'][$first_agent_machine_name], $expected[$first_agent_machine_name]);
$this
->assertEqual($settings['acquia_lift']['campaigns'][$second_agent_machine_name], $expected[$second_agent_machine_name]);
// Add a goal to the agent.
AcquiaLiftAPI::setTestInstance();
personalize_goal_save($first_agent_machine_name, 'user_login', 3);
$this
->drupalGet('/');
$settings = $this
->drupalGetSettings();
$expected[$first_agent_machine_name]['goals'] = array(
'user_login' => 'logs in',
);
$this
->assertEqual($settings['acquia_lift']['campaigns'][$first_agent_machine_name], $expected[$first_agent_machine_name]);
$this
->assertEqual($settings['acquia_lift']['campaigns'][$second_agent_machine_name], $expected[$second_agent_machine_name]);
}
/**
* Tests the effect of the acquia_lift_unibar_allow_status_change variable to
* prevent verification checks on every page load.
*/
function testVerificationChecks() {
module_load_include('inc', 'acquia_lift', 'acquia_lift.ui');
AcquiaLiftAPI::setTestInstance();
// Create a bunch of agents.
$num_agents = 10;
for ($i = 0; $i < $num_agents; $i++) {
$this
->createTestAgent(array(
'control_rate' => 10,
'explore_rate' => 30,
));
}
$this
->resetAll();
DummyAcquiaLiftHttpClient::clearLoggedRequests();
$page = array(
'page_top' => array(),
);
acquia_lift_build_page($page);
// There should be 3 requests per agent, and there are 11 agents (the 10 we
// just created plus the default.)
$requests = DummyAcquiaLiftHttpClient::getLoggedRequests();
$this
->assertEqual(count($requests), 3 + 3 * $num_agents);
// Don't clear cache but clear logged requests and call the function again,
// there shouldn't be any new requests.
DummyAcquiaLiftHttpClient::clearLoggedRequests();
acquia_lift_build_page($page);
$requests = DummyAcquiaLiftHttpClient::getLoggedRequests();
$this
->assertEqual(count($requests), 0);
// Clear the cache and confirm they are made again.
$this
->resetAll();
DummyAcquiaLiftHttpClient::clearLoggedRequests();
acquia_lift_build_page($page);
$requests = DummyAcquiaLiftHttpClient::getLoggedRequests();
$this
->assertEqual(count($requests), 3 + 3 * $num_agents);
// Now disable allowing status changes from the unibar.
variable_set('acquia_lift_unibar_allow_status_change', 0);
$this
->resetAll();
DummyAcquiaLiftHttpClient::clearLoggedRequests();
acquia_lift_build_page($page);
$requests = DummyAcquiaLiftHttpClient::getLoggedRequests();
$this
->assertEqual(count($requests), 0);
}
// Tests changing the status of an agent via AJAX.
function testAgentStatusChangeAJAX() {
module_enable(array(
'personalize_test_extra_agent',
));
$this
->resetAll();
// Need to call resetAll again to force ctools to load the class files.
$this
->resetAll();
$admin_user = $this
->drupalCreateUser(array(
'access administration pages',
'manage personalized content',
));
$this
->drupalLogin($admin_user);
// Create two agents of different types.
$first_agent_name = $this
->randomName();
$first_agent_machine_name = personalize_generate_machine_name($first_agent_name, 'personalize_agent_machine_name_exists');
$second_agent_name = $this
->randomName();
$second_agent_machine_name = personalize_generate_machine_name($second_agent_name, 'personalize_agent_machine_name_exists');
$agents = array(
array(
'label' => $first_agent_name,
'machine_name' => $first_agent_machine_name,
'agent_type' => 'test_agent',
),
array(
'label' => $second_agent_name,
'machine_name' => $second_agent_machine_name,
'agent_type' => 'test_invalid_agent',
),
);
foreach ($agents as $agent) {
$edit = array(
'agent_basic_info[title]' => $agent['label'],
'agent_basic_info[machine_name]' => $agent['machine_name'],
'agent_basic_info[agent_type]' => $agent['agent_type'],
);
$this
->drupalPost('admin/structure/personalize/add', $edit, $this
->getButton('agent'));
}
// Now test the ajax callback.
// Expected case to update to next status.
$expected = array(
'success' => TRUE,
'nextStatus' => array(
'status' => PERSONALIZE_STATUS_PAUSED,
'text' => t('Pause'),
),
'currentStatus' => PERSONALIZE_STATUS_RUNNING,
);
$result = $this
->drupalGetAjax('admin/structure/personalize/manage/' . $first_agent_machine_name . '/ajax_status/' . PERSONALIZE_STATUS_RUNNING);
$this
->assertEqual($expected, $result);
// Try an update that doesn't change the status.
$result = $this
->drupalGetAjax('admin/structure/personalize/manage/' . $first_agent_machine_name . '/ajax_status/' . PERSONALIZE_STATUS_RUNNING);
$this
->assertEqual($expected, $result);
// Try to update an agent that cannot be verified.
$expected = array(
'success' => FALSE,
);
$result = $this
->drupalGetAjax('admin/structure/personalize/manage/' . $second_agent_machine_name . '/ajax_status/' . PERSONALIZE_STATUS_RUNNING);
$this
->assertEqual($expected, $result);
// Try to call the path without the proper permissions.
$this
->drupalLogout();
$this
->drupalGet('admin/structure/personalize/manage/' . $first_agent_machine_name . '/ajax_status/' . PERSONALIZE_STATUS_RUNNING);
$this
->assertText(t('Access denied'));
}
/**
* Creates an article node with a personalized headline field.
*/
protected function createPersonalizedField() {
AcquiaLiftAPI::setTestInstance();
// Create a node which we will attach a fields-based option set to. We can't
// do this via the form because of the way we alter the form, which makes the
// "Add an option" button not findable by simpletest.
$node = new stdClass();
$node->type = 'article';
$node->language = LANGUAGE_NONE;
node_object_prepare($node);
$node->title = $this
->randomName();
$node->article_headline['und'][0] = array(
'value' => 'first value',
);
$node->article_headline['und'][1] = array(
'value' => 'second value',
);
node_save($node);
// Now create the option set.
$option_set = new stdClass();
$option_set->is_new = TRUE;
$option_set->data = array();
$option_set->options = array();
$option_set->plugin = 'fields';
$option_set->new_agent_title = 'Article: Personalizable Headline';
$option_set->options = array(
array(
'option_label' => personalize_fields_generate_option_label(0, array(
'value' => 'first value',
)),
),
array(
'option_label' => personalize_fields_generate_option_label(1, array(
'value' => 'second value',
)),
),
);
if (personalize_fields_option_set_prepare($option_set, 'node', $node->nid, $node, 'article_headline')) {
personalize_fields_option_set_save($option_set, 'node', $node->nid, 'article_headline');
}
$this
->resetAll();
$agent_name = $option_set->agent;
return array(
$node,
$option_set,
$agent_name,
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiaLiftWebTestBase:: |
protected | property | ||
AcquiaLiftWebTestBase:: |
protected | property | The string to use as the admin API key. | |
AcquiaLiftWebTestBase:: |
protected | property | The string to use as the owner code. | |
AcquiaLiftWebTestBase:: |
protected | property | The string to use as the runtime API key. | |
AcquiaLiftWebTestBase:: |
protected | property | The string to use as the admin API URL. | |
AcquiaLiftWebTestBase:: |
protected | property | ||
AcquiaLiftWebTestBase:: |
protected | property | ||
AcquiaLiftWebTestBase:: |
protected | function | Asserts that the expected items are in the queue. | |
AcquiaLiftWebTestBase:: |
protected | function | Helper method to configure an Acquia Lift account. | |
AcquiaLiftWebTestBase:: |
protected | function | ||
AcquiaLiftWebTestBase:: |
protected | function | Creates the required number of custom blocks. | |
AcquiaLiftWebTestBase:: |
protected | function | Help function to create and test queue creation of Personalize Agent | |
AcquiaLiftWebTestBase:: |
protected | function | Creates a user profile field which can be used for targeting. | |
AcquiaLiftWebTestBase:: |
protected | function | Helper method to move buttons names to one pace to simplify it's maintaining | |
AcquiaLiftWebTestBase:: |
public | function |
Sets up a Drupal site for running functional and integration tests. Overrides DrupalWebTestCase:: |
1 |
AcquiaLiftWebTestBase:: |
public | function |
Delete created files and temporary files directory, delete the tables created by setUp(),
and reset the database prefix. Overrides DrupalWebTestCase:: |
|
AcquiaLiftWebTestWorkflow:: |
protected | function | Creates an article node with a personalized headline field. | |
AcquiaLiftWebTestWorkflow:: |
public static | function | ||
AcquiaLiftWebTestWorkflow:: |
function | |||
AcquiaLiftWebTestWorkflow:: |
function | Tests the logic of AcquiaLiftAgent's stopNow() implementation in the simplest use case. | ||
AcquiaLiftWebTestWorkflow:: |
function | Tests the logic of AcquiaLiftAgent's stopNow() implementation when the agent has mulitple decision points including an MVT. | ||
AcquiaLiftWebTestWorkflow:: |
function | Tests campaign javascript settings. | ||
AcquiaLiftWebTestWorkflow:: |
public | function | Tests automatic creation of a goal for personalized fields and auto- starting of the campaign. | |
AcquiaLiftWebTestWorkflow:: |
function | Tests the effect of the acquia_lift_unibar_allow_status_change variable to prevent verification checks on every page load. | ||
DrupalTestCase:: |
protected | property | Assertions thrown in that test case. | |
DrupalTestCase:: |
protected | property | The database prefix of this test run. | |
DrupalTestCase:: |
protected | property | The original file directory, before it was changed for testing purposes. | |
DrupalTestCase:: |
public | property | Current results of this test case. | |
DrupalTestCase:: |
protected | property | Flag to indicate whether the test has been set up. | |
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | This class is skipped when looking for the source of an assertion. | |
DrupalTestCase:: |
protected | property | The test run ID. | |
DrupalTestCase:: |
protected | property | Time limit for the test. | |
DrupalTestCase:: |
public | property | Whether to cache the installation part of the setUp() method. | |
DrupalTestCase:: |
public | property | Whether to cache the modules installation part of the setUp() method. | |
DrupalTestCase:: |
protected | property | URL to the verbose output file directory. | |
DrupalTestCase:: |
protected | function | Internal helper: stores the assert. | |
DrupalTestCase:: |
protected | function | Check to see if two values are equal. | |
DrupalTestCase:: |
protected | function | Check to see if a value is false (an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
protected | function | Check to see if two values are identical. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not equal. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not identical. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not false (not an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
public static | function | Delete an assertion record by message ID. | |
DrupalTestCase:: |
protected | function | Fire an error assertion. | 1 |
DrupalTestCase:: |
public | function | Handle errors during test runs. | 1 |
DrupalTestCase:: |
protected | function | Handle exceptions. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always negative. | |
DrupalTestCase:: |
public static | function | Converts a list of possible parameters into a stack of permutations. | |
DrupalTestCase:: |
protected | function | Cycles through backtrace until the first non-assertion method is found. | |
DrupalTestCase:: |
public static | function | Returns the database connection to the site running Simpletest. | |
DrupalTestCase:: |
public static | function | Store an assertion from outside the testing context. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always positive. | |
DrupalTestCase:: |
public static | function | Generates a random string containing letters and numbers. | |
DrupalTestCase:: |
public static | function | Generates a random string of ASCII characters of codes 32 to 126. | |
DrupalTestCase:: |
public | function | Run all tests in this class. | |
DrupalTestCase:: |
protected | function | Logs a verbose message in a text file. | |
DrupalWebTestCase:: |
protected | property | Additional cURL options. | |
DrupalWebTestCase:: |
protected | property | The content of the page currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | property | The current cookie file used by cURL. | |
DrupalWebTestCase:: |
protected | property | The cookies of the page currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | property | The handle of the current cURL connection. | |
DrupalWebTestCase:: |
protected | property | The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | property | The parsed version of the page. | |
DrupalWebTestCase:: |
protected | property | Whether the files were copied to the test files directory. | |
DrupalWebTestCase:: |
protected | property | The headers of the page currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | property | HTTP authentication credentials (<username>:<password>). | |
DrupalWebTestCase:: |
protected | property | HTTP authentication method | |
DrupalWebTestCase:: |
protected | property | The current user logged in using the internal browser. | |
DrupalWebTestCase:: |
protected | property | The original shutdown handlers array, before it was cleaned for testing purposes. | |
DrupalWebTestCase:: |
protected | property | The original user, before it was changed to a clean uid = 1 for testing purposes. | |
DrupalWebTestCase:: |
protected | property | The content of the page currently loaded in the internal browser (plain text version). | |
DrupalWebTestCase:: |
protected | property | The profile to install as a basis for testing. | 20 |
DrupalWebTestCase:: |
protected | property | The number of redirects followed during the handling of a request. | |
DrupalWebTestCase:: |
protected | property | The current session ID, if available. | |
DrupalWebTestCase:: |
protected | property | The current session name, if available. | |
DrupalWebTestCase:: |
protected | property | The URL currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field exists with the given name or ID. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field exists in the current page with the given ID and value. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field exists in the current page with the given name and value. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
DrupalWebTestCase:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
DrupalWebTestCase:: |
protected | function | Pass if a link with the specified label is found, and optional with the specified index. | |
DrupalWebTestCase:: |
protected | function | Pass if a link containing a given href (part) is found. | |
DrupalWebTestCase:: |
protected | function | Asserts that the most recently sent e-mail message has the given value. | |
DrupalWebTestCase:: |
protected | function | Asserts that the most recently sent e-mail message has the pattern in it. | |
DrupalWebTestCase:: |
protected | function | Asserts that the most recently sent e-mail message has the string in it. | |
DrupalWebTestCase:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field doesn't exist or its value doesn't match, by XPath. | |
DrupalWebTestCase:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
DrupalWebTestCase:: |
protected | function | Pass if a link with the specified label is not found. | |
DrupalWebTestCase:: |
protected | function | Pass if a link containing a given href (part) is not found. | |
DrupalWebTestCase:: |
protected | function | Asserts that a select option in the current page is not checked. | |
DrupalWebTestCase:: |
protected | function | Will trigger a pass if the perl regex pattern is not present in raw content. | |
DrupalWebTestCase:: |
protected | function | Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated. | |
DrupalWebTestCase:: |
protected | function | Asserts the page did not return the specified response code. | |
DrupalWebTestCase:: |
protected | function | Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents. | |
DrupalWebTestCase:: |
protected | function | Pass if the page title is not the given string. | |
DrupalWebTestCase:: |
protected | function | Pass if the text is found MORE THAN ONCE on the text version of the page. | |
DrupalWebTestCase:: |
protected | function | Asserts that a select option in the current page is checked. | |
DrupalWebTestCase:: |
protected | function | Will trigger a pass if the Perl regex pattern is found in the raw content. | |
DrupalWebTestCase:: |
protected | function | Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated. | |
DrupalWebTestCase:: |
protected | function | Asserts the page responds with the specified response code. | |
DrupalWebTestCase:: |
protected | function | Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents. | |
DrupalWebTestCase:: |
protected | function | Helper for assertText and assertNoText. | |
DrupalWebTestCase:: |
protected | function | Asserts themed output. | |
DrupalWebTestCase:: |
protected | function | Pass if the page title is the given string. | |
DrupalWebTestCase:: |
protected | function | Pass if the text is found ONLY ONCE on the text version of the page. | |
DrupalWebTestCase:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
DrupalWebTestCase:: |
protected | function | Pass if the internal browser's URL matches the given path. | |
DrupalWebTestCase:: |
protected | function | Builds an XPath query. | |
DrupalWebTestCase:: |
protected | function | Changes the database connection to the prefixed one. | |
DrupalWebTestCase:: |
protected | function | Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive. | |
DrupalWebTestCase:: |
protected | function | Check to make sure that the array of permissions are valid. | |
DrupalWebTestCase:: |
protected | function | Follows a link by name. | |
DrupalWebTestCase:: |
protected | function | Helper function: construct an XPath for the given set of attributes and value. | |
DrupalWebTestCase:: |
protected | function | Copy the setup cache from/to another table and files directory. | |
DrupalWebTestCase:: |
protected | function | Runs cron in the Drupal installed by Simpletest. | |
DrupalWebTestCase:: |
protected | function | Close the cURL handler and unset the handler. | |
DrupalWebTestCase:: |
protected | function | Initializes and executes a cURL request. | |
DrupalWebTestCase:: |
protected | function | Reads headers and registers errors received from the tested site. | |
DrupalWebTestCase:: |
protected | function | Initializes the cURL connection. | |
DrupalWebTestCase:: |
protected | function | Compare two files based on size and file name. | |
DrupalWebTestCase:: |
protected | function | Creates a custom content type based on default settings. | |
DrupalWebTestCase:: |
protected | function | Creates a node based on default settings. | |
DrupalWebTestCase:: |
protected | function | Creates a role with specified permissions. | |
DrupalWebTestCase:: |
protected | function | Create a user with a given set of permissions. | |
DrupalWebTestCase:: |
protected | function | Retrieves a Drupal path or an absolute path. | |
DrupalWebTestCase:: |
protected | function | Retrieve a Drupal path or an absolute path and JSON decode the result. | |
DrupalWebTestCase:: |
protected | function | Gets the current raw HTML of requested page. | |
DrupalWebTestCase:: |
protected | function | Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed… | |
DrupalWebTestCase:: |
protected | function | Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the… | |
DrupalWebTestCase:: |
protected | function | Gets an array containing all e-mails sent during this test case. | |
DrupalWebTestCase:: |
function | Get a node from the database based on its title. | ||
DrupalWebTestCase:: |
protected | function | Gets the value of the Drupal.settings JavaScript variable for the currently loaded page. | |
DrupalWebTestCase:: |
protected | function | Get a list files that can be used in tests. | |
DrupalWebTestCase:: |
protected | function | Generate a token for the currently logged in user. | |
DrupalWebTestCase:: |
protected | function | Retrieves only the headers for a Drupal path or an absolute path. | |
DrupalWebTestCase:: |
protected | function | Log in a user with the internal browser. | |
DrupalWebTestCase:: |
protected | function | ||
DrupalWebTestCase:: |
protected | function | Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser. | |
DrupalWebTestCase:: |
protected | function | Execute an Ajax submission. | |
DrupalWebTestCase:: |
protected | function | Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page. | |
DrupalWebTestCase:: |
protected | function | Sets the value of the Drupal.settings JavaScript variable for the currently loaded page. | |
DrupalWebTestCase:: |
protected | function | Takes a path and returns an absolute path. | |
DrupalWebTestCase:: |
protected | function | Get all option elements, including nested options, in a select. | |
DrupalWebTestCase:: |
protected | function | Get the selected value from a select field. | |
DrupalWebTestCase:: |
protected | function | Returns the cache key used for the setup caching. | |
DrupalWebTestCase:: |
protected | function | Get the current URL from the cURL handler. | |
DrupalWebTestCase:: |
protected | function | Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type. | |
DrupalWebTestCase:: |
protected | function | Copies the cached tables and files for a cached installation setup. | |
DrupalWebTestCase:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
DrupalWebTestCase:: |
protected | function | Preload the registry from the testing site. | |
DrupalWebTestCase:: |
protected | function | Generates a database prefix for running tests. | |
DrupalWebTestCase:: |
protected | function | Prepares the current environment for running the test. | |
DrupalWebTestCase:: |
protected | function | Recursively copy one directory to another. | |
DrupalWebTestCase:: |
protected | function | Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread. | 1 |
DrupalWebTestCase:: |
protected | function | Reset all data structures after having enabled new modules. | |
DrupalWebTestCase:: |
protected | function | Store the installation setup to a cache. | |
DrupalWebTestCase:: |
protected | function | Outputs to verbose the most recent $count emails sent. | |
DrupalWebTestCase:: |
protected | function | Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page. | |
DrupalWebTestCase:: |
function |
Constructor for DrupalWebTestCase. Overrides DrupalTestCase:: |
1 |