You are here

protected function AcquiaLiftWebTestBase::createTargetingAgentWithNestedTest in Acquia Lift Connector 7.2

7 calls to AcquiaLiftWebTestBase::createTargetingAgentWithNestedTest()
AcquiaLiftWebTestFundamentals::testBatchSyncOperations in tests/acquia_lift.test
Tests the function that gathers operations for syncing of agents and their components to Lift.
AcquiaLiftWebTestFundamentals::testSiteNamePrefixAttach in tests/acquia_lift.test
AcquiaLiftWebTestTarget::testNestedAgentAssets in tests/acquia_lift.test
AcquiaLiftWebTestTarget::testNestedAgentDeletion in tests/acquia_lift.test
AcquiaLiftWebTestTarget::testNestedAgentSettings in tests/acquia_lift.test

... See full list

File

tests/acquia_lift.test, line 134
Integration tests for Acquia Lift module.

Class

AcquiaLiftWebTestBase
@file Integration tests for Acquia Lift module.

Code

protected function createTargetingAgentWithNestedTest($num_options = 3, $index = 0) {
  module_load_include('inc', 'acquia_lift', 'acquia_lift.admin');

  // First, set up our agent, option set, audience and desired targeting
  // structure.
  $agent = $this
    ->createTargetingAgent();
  $this
    ->resetAll();
  $parent_option_set = $this
    ->createPersonalizedBlock($index, $agent, $num_options);
  if (empty($parent_option_set)) {
    $this
      ->fail('Could not create option set');
    return;
  }

  // Keep the option ids in an array.
  $option_ids = array();
  foreach ($parent_option_set->options as $option) {
    $option_ids[] = $option['option_id'];
  }
  $this
    ->resetAll();
  $targeting = array(
    ACQUIA_LIFT_TARGETING_EVERYONE_ELSE => $option_ids,
  );
  try {
    acquia_lift_save_targeting_structure($agent, $targeting);
  } catch (AcquiaLiftException $e) {
    $this
      ->fail('Exception thrown when none expected.');
  }

  // Now implement the targeting structure that is currently just stored in
  // the 'lift_targeting' property.
  AcquiaLiftAPI::setTestInstance();
  acquia_lift_implement_targeting($agent);
  return $agent;
}