function AcquiaLiftWebTestCampaignWizardTargeting::testWinnerSelectionAvailability in Acquia Lift Connector 7.2        
                          
                  
                        
File
 
   - tests/acquia_lift.test, line 3819
- Integration tests for Acquia Lift module.
Class
  
  - AcquiaLiftWebTestCampaignWizardTargeting 
Code
function testWinnerSelectionAvailability() {
  
  $user_profile_field_1 = $this
    ->createUserProfileField();
  $context_1 = str_replace('field_', '', $user_profile_field_1['field_name']);
  
  $agent = $this
    ->createTargetingAgent();
  $option_set = $this
    ->createOptionSet(1, array(
    'agent' => $agent->machine_name,
    'plugin' => 'type1',
    'num_options' => 3,
    'option_ids' => array(
      'option-A',
      'option-B',
      'option-C',
    ),
  ));
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  
  $this
    ->assertNoFieldById('acquia-lift-complete-everyone-else');
  
  $this
    ->drupalPostAJAX(NULL, array(), $this->addTargetAudienceElement);
  $edit = array(
    'audiences[new][0][details][name]' => 'Muppet fans',
    'audiences[new][0][details][mapping][contexts][0][context]' => 'user_profile_context' . PERSONALIZE_TARGETING_ADMIN_SEPARATOR . $context_1,
    'audiences[new][0][details][mapping][contexts][0][value][match]' => 'some value',
    'audiences[new][0][details][mapping][contexts][0][value][operator]' => 'equals',
  );
  $this
    ->drupalPost(NULL, $edit, $this
    ->getButton('wizard_next', array(
    'agent_name' => $agent->machine_name,
    'step' => 'targeting',
  )));
  
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $edit = array(
    'audiences[existing][muppet-fans][assignment_order]' => 'option-A',
    'audiences[existing][everyone-else][assignment_order]' => 'option-B,option-C',
  );
  $this
    ->drupalPost(NULL, $edit, $this
    ->getButton('wizard_next', array(
    'agent_name' => $agent->machine_name,
    'step' => 'targeting',
  )));
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $this
    ->assertNoFieldById('acquia-lift-complete-everyone-else');
  $this
    ->assertNoFieldById('acquia-lift-complete-muppet-fans');
  
  $this
    ->drupalPost('admin/structure/personalize/manage/' . $agent->machine_name . '/review', array(), $this
    ->getButton('wizard_start'));
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $this
    ->assertFieldById('acquia-lift-complete-everyone-else');
  $this
    ->assertNoFieldById('acquia-lift-complete-muppet-fans');
  
  personalize_agent_set_status($agent->machine_name, PERSONALIZE_STATUS_PAUSED);
  $this
    ->resetAll();
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $this
    ->assertFieldById('acquia-lift-complete-everyone-else');
  $this
    ->assertNoFieldById('acquia-lift-complete-muppet-fans');
  
  $edit = array(
    'audiences[existing][muppet-fans][assignment_order]' => 'option-A,option-B',
    'audiences[existing][everyone-else][assignment_order]' => 'option-B,option-C',
  );
  $this
    ->drupalPost(NULL, $edit, $this
    ->getButton('wizard_next', array(
    'agent_name' => $agent->machine_name,
    'step' => 'targeting',
  )));
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $this
    ->assertFieldById('acquia-lift-complete-everyone-else');
  $this
    ->assertNoFieldById('acquia-lift-complete-muppet-fans');
  
  $this
    ->drupalPost('admin/structure/personalize/manage/' . $agent->machine_name . '/review', array(), $this
    ->getButton('wizard_start'));
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $this
    ->assertFieldById('acquia-lift-complete-everyone-else');
  $this
    ->assertFieldById('acquia-lift-complete-muppet-fans-2');
  
  personalize_agent_set_status($agent->machine_name, PERSONALIZE_STATUS_PAUSED);
  $this
    ->resetAll();
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $this
    ->assertFieldById('acquia-lift-complete-everyone-else');
  $this
    ->assertFieldById('acquia-lift-complete-muppet-fans-2');
  $edit = array(
    'audiences[existing][muppet-fans-2][assignment_order]' => 'option-A,option-B',
    'audiences[existing][everyone-else][assignment_order]' => 'option-C',
  );
  $this
    ->drupalPost(NULL, $edit, $this
    ->getButton('wizard_next', array(
    'agent_name' => $agent->machine_name,
    'step' => 'targeting',
  )));
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $this
    ->assertNoFieldById('acquia-lift-complete-everyone-else');
  $this
    ->assertFieldById('acquia-lift-complete-muppet-fans-2');
  
  $this
    ->drupalPost('admin/structure/personalize/manage/' . $agent->machine_name . '/review', array(), $this
    ->getButton('wizard_start'));
  $this
    ->drupalGet('admin/structure/personalize/manage/' . $agent->machine_name . '/targeting');
  $this
    ->assertNoFieldById('acquia-lift-complete-everyone-else');
  $this
    ->assertFieldById('acquia-lift-complete-muppet-fans-2');
}