class AcquiaLiftWebTestCampaignWizardVariations in Acquia Lift Connector 7.2
Hierarchy
- class \DrupalTestCase
Expanded class hierarchy of AcquiaLiftWebTestCampaignWizardVariations
File
- tests/
acquia_lift.test, line 2932 - Integration tests for Acquia Lift module.
View source
class AcquiaLiftWebTestCampaignWizardVariations extends AcquiaLiftWebTestCampaignWizardBase {
public static function getInfo() {
return array(
'name' => t('Acquia Lift Web Tests - Personalization Wizard Variations'),
'description' => t('Tests functionality related to the personalization management wizard variation sets.'),
'group' => t('Personalize'),
);
}
function testVariationTypeSelect() {
$variation_input_name = key($this->addVariationSetElement);
$variation_input_value = reset($this->addVariationSetElement);
$block_title_name = 'variations[editing][new][0][block][content][title]';
$element_url_name = 'variations[editing][new][0][element][content][url]';
$option_set_type_name = 'variations[editing][new][0][option_set_type]';
$block_type_id = 'edit-variations-editing-new-0-option-set-type-block';
$element_type_id = 'edit-variations-editing-new-0-option-set-type-element';
$this
->drupalLogin($this->managerUser);
$agent = $this
->createTargetingAgent();
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
// Make sure the type selection is shown by default without any selections.
$this
->assertFieldByName($option_set_type_name);
$this
->assertNoFieldChecked($block_type_id);
$this
->assertNoFieldChecked($element_type_id);
// Actual forms should not be shown yet.
$this
->assertNoFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
// Button to add a new variation set should still be available.
$this
->assertFieldByName($variation_input_name, $variation_input_value);
// Cancel variation set creation.
$this
->drupalPostAJAX(NULL, array(), array(
'cancel_option_set_0' => t('Cancel'),
));
$this
->assertFieldByName($variation_input_name, $variation_input_value);
$this
->assertNoFieldByName($option_set_type_name);
$this
->assertNoFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
// Select a block variation set.
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
$this
->assertFieldByName($option_set_type_name);
$this
->assertNoFieldChecked($block_type_id);
$this
->assertNoFieldChecked($element_type_id);
$this
->assertNoFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
$this
->assertFieldByName($variation_input_name, $variation_input_value);
$edit = array(
$option_set_type_name => 'block',
);
$this
->drupalPostAJAX(NULL, $edit, $option_set_type_name);
$this
->assertFieldByName($variation_input_name, $variation_input_value);
$this
->assertNoFieldByName($option_set_type_name);
$this
->assertFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
// Change the type
$this
->drupalPostAJAX(NULL, array(), $this->changeTypeElement);
$this
->assertFieldByName($option_set_type_name);
$this
->assertNoFieldChecked($block_type_id);
$this
->assertNoFieldChecked($element_type_id);
$this
->assertNoFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
$this
->assertFieldByName($variation_input_name, $variation_input_value);
// Select block again.
$edit = array(
$option_set_type_name => 'block',
);
$this
->drupalPostAJAX(NULL, $edit, $option_set_type_name);
$this
->assertFieldByName($variation_input_name, $variation_input_value);
$this
->assertNoFieldByName($option_set_type_name);
$this
->assertFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
// Cancel the creation of the variation set.
$this
->drupalPostAJAX(NULL, array(), array(
'cancel_block_option_set_0' => t('Cancel'),
));
$this
->assertFieldByname($variation_input_name, $variation_input_value);
$this
->assertNoFieldByName($option_set_type_name);
$this
->assertNoFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
// Select an element variation set.
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
$this
->assertFieldByName($option_set_type_name);
$this
->assertNoFieldChecked($block_type_id);
$this
->assertNoFieldChecked($element_type_id);
$this
->assertNoFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
$this
->assertFieldByName($variation_input_name, $variation_input_value);
$edit = array(
$option_set_type_name => 'element',
);
$this
->drupalPostAJAX(NULL, $edit, $option_set_type_name);
$this
->assertFieldByName($variation_input_name, $variation_input_value);
$this
->assertNoFieldByName($option_set_type_name);
$this
->assertNoFieldByName($block_title_name);
$this
->assertFieldByName($element_url_name);
// Change the type.
$this
->drupalPostAJAX(NULL, array(), $this->changeTypeElement);
$this
->assertFieldByName($option_set_type_name);
$this
->assertNoFieldChecked($block_type_id);
$this
->assertNoFieldChecked($element_type_id);
$this
->assertNoFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
$this
->assertFieldByName($variation_input_name, $variation_input_value);
// Select element again.
$edit = array(
$option_set_type_name => 'element',
);
$this
->drupalPostAJAX(NULL, $edit, $option_set_type_name);
$this
->assertFieldByName($variation_input_name, $variation_input_value);
$this
->assertNoFieldByName($option_set_type_name);
$this
->assertNoFieldByName($block_title_name);
$this
->assertFieldByName($element_url_name);
// Cancel the creation of the variation set.
$this
->drupalPostAJAX(NULL, array(), array(
'cancel_element_option_set_0' => t('Cancel'),
));
$this
->assertFieldByname($variation_input_name, $variation_input_value);
$this
->assertNoFieldByName($option_set_type_name);
$this
->assertNoFieldByName($block_title_name);
$this
->assertNoFieldByName($element_url_name);
// Now test the selection process when there is an existing option set.
/* Temporarily removed: https://www.drupal.org/node/2505247
$this->createPersonalizedBlock(1, $agent);
// Set the variation set handling
$this->drupalget('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this->assertNoFieldByName($block_title_name);
$this->assertNoFieldByName($element_url_name);
$this->assertNoFieldByName('variations[add_variation][option_set_type]');
$this->assertFieldByName('variations[add_variation][variation_set_handling]');
$edit = array(
'variations[add_variation][variation_set_handling]' => ACQUIA_LIFT_DECISION_LOCKSTEP,
);
$this->drupalPostAJAX(NULL, $edit, 'variations[add_variation][variation_set_handling]');
// Now we can set the type of option set to create.
$edit = array(
'variations[add_variation][option_set_type]' => 'block',
);
$this->drupalPostAJAX(NULL, $edit, 'variations[add_variation][option_set_type]');
// And finally there should be the new block form.
$this->assertFieldByName($block_title_name);
// Finally test adding option sets once they are already multiple.
$this->createPersonalizedBlock(2, $agent);
$agent->data['variation_set_handling'] = ACQUIA_LIFT_DECISION_LOCKSTEP;
personalize_agent_save($agent);
$this->drupalget('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this->assertText('Variation sets (Lock step)');
$this->assertFieldByName('variations[add_variation][option_set_type]');
$this->assertNoFieldByName('variations[add_variation][variation_set_handling]');
$this->assertNoFieldByName($block_title_name);
$this->assertNoFieldByName($element_url_name);
$edit = array(
'variations[add_variation][option_set_type]' => 'block',
);
$this->drupalPostAJAX(NULL, $edit, 'variations[add_variation][option_set_type]');
// The new block form should display without selecting variation handling.
$this->assertFieldByName($block_title_name);
*/
}
/**
* Test block variation set creation.
*/
function testWhatBlockForm() {
$this
->drupalLogin($this->managerUser);
$agent = $this
->createTargetingAgent();
// Create a personalized block from existing blocks.
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
// Indicate a block variation set type.
$edit = array(
'variations[editing][new][0][option_set_type]' => 'block',
);
$this
->drupalPostAJAX(NULL, $edit, 'variations[editing][new][0][option_set_type]');
$edit = array(
'variations[editing][new][0][block][content][title]' => 'Muppets',
'variations[editing][new][0][block][content][pblock_wrapper][blocks][0][option_label]' => 'My variation 1',
'variations[editing][new][0][block][content][pblock_wrapper][blocks][0][block][bid]' => 'comment_delta_recent',
'variations[editing][new][0][block][content][pblock_wrapper][blocks][1][option_label]' => 'My variation 2',
'variations[editing][new][0][block][content][pblock_wrapper][blocks][1][block][bid]' => 'node_delta_recent',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_next', array(
'agent_name' => $agent->machine_name,
'step' => 'variations',
)));
$option_sets = personalize_option_set_load_by_agent($agent->machine_name);
$this
->assertEqual(count($option_sets), 1);
$option_set = reset($option_sets);
$this
->assertEqual(count($option_set->options), 2);
$this
->assertEqual($option_set->label, t('Muppets'));
$this
->assertEqual($option_set->options[0]['option_label'], 'My variation 1');
$this
->assertEqual($option_set->options[0]['bid'], 'comment_delta_recent');
$this
->assertEqual($option_set->options[1]['option_label'], 'My variation 2');
$this
->assertEqual($option_set->options[1]['bid'], 'node_delta_recent');
// Now go to the variations page and verify the new option set is available.
$this
->resetAll();
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->assertFieldByName('variations[editing][option_sets][option_set_' . $option_set->osid . '][content][title]', 'Muppets');
$this
->assertOptionSelected('edit-variations-editing-option-sets-option-set-' . $option_set->osid . '-content-pblock-wrapper-blocks-0-block-bid', 'comment_delta_recent');
$this
->assertOptionSelected('edit-variations-editing-option-sets-option-set-' . $option_set->osid . '-content-pblock-wrapper-blocks-1-block-bid', 'node_delta_recent');
// Edit the variation set title change the second block to a new block
// created inline.
$edit = array(
'variations[editing][option_sets][option_set_' . $option_set->osid . '][content][title]' => 'Great Muppet Caper',
'variations[editing][option_sets][option_set_' . $option_set->osid . '][content][pblock_wrapper][blocks][0][block][bid]' => 'comment_delta_recent',
'variations[editing][option_sets][option_set_' . $option_set->osid . '][content][pblock_wrapper][blocks][1][block][block_type]' => 'add',
'variations[editing][option_sets][option_set_' . $option_set->osid . '][content][pblock_wrapper][blocks][1][block][add][title]' => 'Kermit',
'variations[editing][option_sets][option_set_' . $option_set->osid . '][content][pblock_wrapper][blocks][1][block][add][info]' => 'Piggy',
'variations[editing][option_sets][option_set_' . $option_set->osid . '][content][pblock_wrapper][blocks][1][block][add][body][value]' => 'complicated',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_next', array(
'agent_name' => $agent->machine_name,
'step' => 'variations',
)));
$option_sets = personalize_option_set_load_by_agent($agent->machine_name, TRUE);
$this
->assertEqual(count($option_sets), 1);
$option_set = reset($option_sets);
$this
->assertEqual(count($option_set->options), 2);
$this
->assertEqual($option_set->label, 'Great Muppet Caper');
$this
->assertEqual($option_set->options[1]['bid'], 'block_delta_1');
// Now go to the variations page test the advanced options
$this
->resetAll();
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$edit = array(
'variations[editing][option_sets][option_set_' . $option_set->osid . '][advanced][stateful]' => 1,
'variations[editing][option_sets][option_set_' . $option_set->osid . '][advanced][preview_link]' => 'invalid url',
'variations[editing][option_sets][option_set_' . $option_set->osid . '][advanced][executor]' => 'callback',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_next', array(
'agent_name' => $agent->machine_name,
'step' => 'variations',
)));
$this
->assertText('You have specified an invalid path');
$edit['variations[editing][option_sets][option_set_' . $option_set->osid . '][advanced][preview_link]'] = '<front>';
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_next', array(
'agent_name' => $agent->machine_name,
'step' => 'variations',
)));
$option_sets = personalize_option_set_load_by_agent($agent->machine_name, TRUE);
$this
->assertEqual(count($option_sets), 1);
$option_set = reset($option_sets);
$this
->assertEqual(count($option_set->options), 2);
$this
->assertEqual($option_set->label, 'Great Muppet Caper');
$this
->assertEqual($option_set->stateful, 1);
$this
->assertEqual($option_set->preview_link, '<front>');
$this
->assertEqual($option_set->executor, 'callback');
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$osid = $option_set->osid;
foreach ($option_set->options as $option) {
$preview_link = url('<front>', array(
'query' => array(
PERSONALIZE_PRESELECTION_PARAM => 'osid-' . $osid . '--' . $option['option_id'],
),
));
$this
->assertLinkByHref($preview_link);
}
}
/**
* Test element variation set creation.
*/
function testWhatElementForm() {
$admin_user = $this
->drupalCreateUser(array(
'access administration pages',
'manage personalized content',
'use advanced personalize elements features',
));
$this
->drupalLogin($admin_user);
$agent = $this
->createTargetingAgent();
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
// Indicate an element variation set type.
$edit = array(
'variations[editing][new][0][option_set_type]' => 'element',
);
$this
->drupalPostAJAX(NULL, $edit, 'variations[editing][new][0][option_set_type]');
// Invalid url
$edit = array(
'variations[editing][new][0][element][content][url]' => 'invalid url',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_element_navigate'));
$this
->assertText('You have specified an invalid path');
// Valid external url
$edit = array(
'variations[editing][new][0][element][content][url]' => 'http://www.google.com',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_element_navigate'));
$this
->assertNoText('You have specified an invalid path');
// Adjust the current url to match expected URLs across environments.
$current_url = $this->url;
if (substr($current_url, -1) != '/') {
$current_url .= '/';
}
// Assert current url's prefix a google url (but possibly already redirected by IP's country).
$current_url_expected_prefix = 'http://www.google.';
$current_url_expected_prefix_length = strlen($current_url_expected_prefix);
$this
->assertTrue(substr($current_url, 0, $current_url_expected_prefix_length) === $current_url_expected_prefix);
// Valid url by alias
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
$edit = array(
'variations[editing][new][0][option_set_type]' => 'element',
);
$this
->drupalPostAJAX(NULL, $edit, 'variations[editing][new][0][option_set_type]');
$edit = array(
'variations[editing][new][0][element][content][url]' => 'admin/structure',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_element_navigate'));
$this
->assertNoText('You have specified an invalid path');
$this
->assertUrl('admin/structure');
// Valid url by path
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
// Indicate an element variation set type.
$edit = array(
'variations[editing][new][0][option_set_type]' => 'element',
);
$this
->drupalPostAJAX(NULL, $edit, 'variations[editing][new][0][option_set_type]');
$edit = array(
'variations[editing][new][0][element][content][url]' => 'node',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_element_navigate'));
$this
->assertNoText('You have specified an invalid path');
$this
->assertUrl('node');
// Check the settings for toolbar integration.
$settings = $this
->drupalGetSettings();
$this
->assertEqual($settings['acquia_lift']['toolbarEditMode'], 'element');
// Now navigate to another page and make sure that the settings are gone.
$this
->drupalGet('admin/structure/personalize');
$settings = $this
->drupalGetSettings();
$this
->assertTrue(empty($settings['acquia_lift']['toolbarEditMode']));
// Create an element variation for our agent.
$option_set = $this
->createPersonalizeElementsOptionSet($agent->machine_name, array(
'num_options' => 1,
'add_control' => TRUE,
'pages' => 'node',
));
// Go to the edit page and verify that this option set is displayed and
// links to its "pages" page for editing.
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->assertText('Element test set 1');
// Check the preview links are displayed.
$osid = $option_set->osid;
foreach ($option_set->options as $option) {
$this
->assertLinkByHref(url('node', array(
PERSONALIZE_PRESELECTION_PARAM => 'osid-' . $osid . '--' . $option['option_id'],
)));
}
// Now verify that the edit link goes to the node page as well.
$this
->clickLink(t('Edit variations in context'));
$this
->assertUrl('node');
// Settings should include indicators for deleting and editing option sets.
$js_osid = personalize_stringify_osid($option_set->osid);
$settings = $this
->drupalGetSettings();
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid][PERSONALIZE_CONTROL_OPTION_ID]['editable']);
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid][PERSONALIZE_CONTROL_OPTION_ID]['deletable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-A']['editable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-A']['deletable']);
// Start the campaign and the elements should not be deletable.
$this
->createTestFromOptionSet($agent, $option_set);
$this
->drupalPost('admin/structure/personalize/manage/' . $agent->machine_name . '/review', array(), t('Start'));
$this
->drupalGet('');
$settings = $this
->drupalGetSettings();
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid][PERSONALIZE_CONTROL_OPTION_ID]['editable']);
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid][PERSONALIZE_CONTROL_OPTION_ID]['deletable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-A']['editable']);
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid]['option-A']['deletable']);
// Add another option to the option set that is not targeted.
$option_set->options[] = array(
'option_id' => 'option-B',
'option_label' => 'Option B',
'personalize_elements_content' => 'Yaaaaaay!',
);
$option_set = personalize_option_set_save($option_set);
$this
->resetAll();
// The new option should be deletable.
$this
->drupalGet('');
$settings = $this
->drupalGetSettings();
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid][PERSONALIZE_CONTROL_OPTION_ID]['editable']);
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid][PERSONALIZE_CONTROL_OPTION_ID]['deletable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-A']['editable']);
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid]['option-A']['deletable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-B']['editable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-B']['deletable']);
// Pause the agent and all options should be editable and deletable.
personalize_agent_set_status($agent->machine_name, PERSONALIZE_STATUS_PAUSED);
$this
->drupalGet('');
$settings = $this
->drupalGetSettings();
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid][PERSONALIZE_CONTROL_OPTION_ID]['editable']);
$this
->assertFalse($settings['acquia_lift']['option_sets'][$js_osid][PERSONALIZE_CONTROL_OPTION_ID]['deletable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-A']['editable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-A']['deletable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-B']['editable']);
$this
->assertTrue($settings['acquia_lift']['option_sets'][$js_osid]['option-B']['deletable']);
// Verify that the elements variation can have general edits made from
// the campaign workflow.
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$edit = array(
'variations[editing][option_sets][option_set_' . $option_set->osid . '][content][label]' => 'Element test set 1 - EDIT',
'variations[editing][option_sets][option_set_' . $option_set->osid . '][content][options][option-A][option_label]' => 'Option A - EDIT',
'variations[editing][option_sets][option_set_' . $option_set->osid . '][advanced][pages_all]' => 0,
'variations[editing][option_sets][option_set_' . $option_set->osid . '][advanced][pages]' => "node\nadmin/*",
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_next', array(
'agent_name' => $agent->machine_name,
'step' => 'variations',
)));
$option_set = personalize_option_set_load($option_set->osid, TRUE);
$this
->assertTrue('Element test set 1 - EDIT', $option_set->label);
foreach ($option_set->options as $option) {
if ($option['option_id'] == 'option-A') {
$this
->assertTrue('Option A - EDIT', $option_set->label);
}
}
$this
->assertEqual($option_set->data['pages'], "node\nadmin/*");
$this
->assertEqual($option_set->preview_link, 'node');
// Now add a javascript personalize elements variation.
$js_option_set = $this
->createPersonalizeElementsOptionSet($agent->machine_name, array(
'type' => 'runJS',
'selector' => '',
'add_control' => TRUE,
'num_options' => 2,
));
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->clickLink('Edit variations');
$this
->assertOptionSelected('edit-variation-type', 'runJS');
$edit = array(
'title' => 'JavaScript variation set',
);
$this
->drupalPost(NULL, $edit, t('Save'));
// Should be redirected back to the "What" page
$this
->assertUrl('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->assertFieldByName('variations[editing][option_sets][option_set_' . $js_option_set->osid . '][content][label]', 'JavaScript variation set');
}
/**
* Test the personalize fields view of the "What" campaign subform.
*/
function testWhatFieldsForm() {
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.
$this
->createPersonalizedArticleField();
list($node, $os, $agent_name) = $this
->createPersonalizedField();
$this
->drupalGet("admin/structure/personalize/manage/{$agent_name}/variations");
// Text should be shown in preview.
$this
->assertText('first value');
$this
->assertText('second value');
// Basic variation editing should be available.
$edit = array(
'variations[editing][option_sets][option_set_' . $os->osid . '][content][label]' => 'Fields test edit',
'variations[editing][option_sets][option_set_' . $os->osid . '][content][options][first-value][option_label]' => 'Option A - EDIT',
'variations[editing][option_sets][option_set_' . $os->osid . '][content][options][second-value][option_label]' => 'Option B - EDIT',
'variations[editing][option_sets][option_set_' . $os->osid . '][advanced][preview_link]' => 'node/' . $node->nid,
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_next', array(
'agent_name' => $agent_name,
'step' => 'variations',
)));
// Go back and verify the changes.
$this
->drupalGet("admin/structure/personalize/manage/{$agent_name}/variations");
$this
->assertFieldByName('variations[editing][option_sets][option_set_' . $os->osid . '][content][label]', 'Fields test edit');
$this
->assertFieldByName('variations[editing][option_sets][option_set_' . $os->osid . '][content][options][first-value][option_label]', 'Option A - EDIT');
$this
->assertFieldByName('variations[editing][option_sets][option_set_' . $os->osid . '][content][options][second-value][option_label]', 'Option B - EDIT');
$this
->assertText('first value');
$this
->assertText('second value');
$this
->assertLinkByHref(url('node/' . $node->nid, array(
'query' => array(
PERSONALIZE_PRESELECTION_PARAM => personalize_stringify_osid($os->osid) . '--first-value',
),
)));
$this
->assertLinkByHref(url('node/' . $node->nid, array(
'query' => array(
PERSONALIZE_PRESELECTION_PARAM => personalize_stringify_osid($os->osid) . '--second-value',
),
)));
// Check the link to edit in context.
$this
->clickLink(t('Edit variations in context'));
$this
->assertUrl('node/' . $node->nid . '/edit', array(
'query' => array(
'destination' => "admin/structure/personalize/manage/{$agent_name}/variations",
),
));
$this
->drupalPost(NULL, array(), t('Save'));
$this
->assertUrl("admin/structure/personalize/manage/{$agent_name}/variations");
}
/**
* Test lock-step combinations of variation sets.
*/
function testWhatLockStep() {
$error_heading = "Let's fix this";
$error_message = 'Variation sets must contain an equal number of variations.';
$this
->drupalLogin($this->managerUser);
$agent = $this
->createTargetingAgent();
// Create a personalized block from existing blocks.
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
$this
->assertNoText($error_heading);
$this
->assertNoText($error_message);
// Add two variation sets.
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
$this
->drupalPostAJAX(NULL, array(), $this->addVariationSetElement);
$edit = array(
'variations[editing][new][0][option_set_type]' => 'block',
);
$this
->drupalPostAJAX(NULL, $edit, 'variations[editing][new][0][option_set_type]');
$edit = array(
'variations[editing][new][1][option_set_type]' => 'block',
);
$this
->drupalPostAJAX(NULL, $edit, 'variations[editing][new][1][option_set_type]');
$this
->drupalPostAJAX(NULL, array(), 'blocks_add_variation_add_1');
$edit = array(
'variations[editing][new][0][block][content][title]' => 'Muppets',
'variations[editing][new][0][block][content][pblock_wrapper][blocks][0][option_label]' => 'Muppets variation 1',
'variations[editing][new][0][block][content][pblock_wrapper][blocks][0][block][bid]' => 'comment_delta_recent',
'variations[editing][new][0][block][content][pblock_wrapper][blocks][1][option_label]' => 'Muppets variation 2',
'variations[editing][new][0][block][content][pblock_wrapper][blocks][1][block][bid]' => 'node_delta_recent',
'variations[editing][new][1][block][content][title]' => 'Sesame',
'variations[editing][new][1][block][content][pblock_wrapper][blocks][0][option_label]' => 'Sesame variation 1',
'variations[editing][new][1][block][content][pblock_wrapper][blocks][0][block][bid]' => 'system_delta_powered-by',
'variations[editing][new][1][block][content][pblock_wrapper][blocks][1][option_label]' => 'Sesme variation 2',
'variations[editing][new][1][block][content][pblock_wrapper][blocks][1][block][bid]' => 'system_delta_help',
'variations[editing][new][1][block][content][pblock_wrapper][blocks][2][option_label]' => 'Sesame variation 3',
'variations[editing][new][1][block][content][pblock_wrapper][blocks][2][block][bid]' => 'user_delta_new',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_next', array(
'agent_name' => $agent->machine_name,
'step' => 'variations',
)));
$this
->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/variations');
// Should still be on the variations page only now there should be a
// warning message.
$this
->assertText($error_heading);
$this
->assertText($error_message);
// Remove the extra variation.
$option_sets = personalize_option_set_load_by_agent($agent->machine_name);
$second_os = end($option_sets);
$edit = array(
'variations[editing][option_sets][option_set_' . $second_os->osid . '][content][pblock_wrapper][blocks][2][block][bid]' => '',
);
$this
->drupalPost(NULL, $edit, $this
->getButton('wizard_save'));
// Verify that the error message is gone.
$this
->assertNoText($error_heading);
$this
->assertNoText($error_message);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiaLiftWebTestBase:: |
protected | property | ||
AcquiaLiftWebTestBase:: |
protected static | property | ||
AcquiaLiftWebTestBase:: |
protected | property | The string to use as the JavaScript path. | |
AcquiaLiftWebTestBase:: |
protected | property | ||
AcquiaLiftWebTestBase:: |
protected | function | Helper method to configure an Acquia Lift account. | |
AcquiaLiftWebTestBase:: |
protected | function | ||
AcquiaLiftWebTestBase:: |
protected | function | Adds a personalizable field to the article node type. | |
AcquiaLiftWebTestBase:: |
protected | function | Creates the required number of custom blocks. | |
AcquiaLiftWebTestBase:: |
protected | function | Creates an article node with a personalized headline field. | |
AcquiaLiftWebTestBase:: |
protected | function | Create personalize element option set. | |
AcquiaLiftWebTestBase:: |
protected | function | Helper that adds a target audience using two contexts AND'd together. | |
AcquiaLiftWebTestBase:: |
protected | function | A helper function to create an acquia_lift_target agent. | |
AcquiaLiftWebTestBase:: |
protected | function | ||
AcquiaLiftWebTestBase:: |
protected | function | Helper function to create an agent. | |
AcquiaLiftWebTestBase:: |
function | 1 | ||
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 |
Delete created files and temporary files directory, delete the tables created by setUp(),
and reset the database prefix. Overrides DrupalWebTestCase:: |
|
AcquiaLiftWebTestCampaignWizardBase:: |
protected | property | ||
AcquiaLiftWebTestCampaignWizardBase:: |
protected | property | ||
AcquiaLiftWebTestCampaignWizardBase:: |
protected | property | ||
AcquiaLiftWebTestCampaignWizardBase:: |
protected | property | ||
AcquiaLiftWebTestCampaignWizardBase:: |
public | function |
Sets up a Drupal site for running functional and integration tests. Overrides AcquiaLiftWebTestBase:: |
|
AcquiaLiftWebTestCampaignWizardVariations:: |
public static | function | ||
AcquiaLiftWebTestCampaignWizardVariations:: |
function | |||
AcquiaLiftWebTestCampaignWizardVariations:: |
function | Test block variation set creation. | ||
AcquiaLiftWebTestCampaignWizardVariations:: |
function | Test element variation set creation. | ||
AcquiaLiftWebTestCampaignWizardVariations:: |
function | Test the personalize fields view of the "What" campaign subform. | ||
AcquiaLiftWebTestCampaignWizardVariations:: |
function | Test lock-step combinations of variation sets. | ||
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 |