You are here

protected function AcquiaLiftWebTestBase::createTargetAudience in Acquia Lift Connector 7.2

Helper that adds a target audience using two contexts AND'd together.

Parameters

$option_set:

null $machine_name:

Return value

null|string

5 calls to AcquiaLiftWebTestBase::createTargetAudience()
AcquiaLiftWebTestAgentAdmin::testAgentList in tests/acquia_lift.test
AcquiaLiftWebTestReports::testAudienceReportLogic in tests/acquia_lift.test
AcquiaLiftWebTestTarget::testAssignVariations in tests/acquia_lift.test
AcquiaLiftWebTestTarget::testAudienceChanges in tests/acquia_lift.test
AcquiaLiftWebTestTarget::testImplementTargetingStructure in tests/acquia_lift.test

File

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

Class

AcquiaLiftWebTestBase
@file Integration tests for Acquia Lift module.

Code

protected function createTargetAudience($option_set, $machine_name = NULL, $contexts = array()) {
  if (empty($machine_name)) {
    $label = $this
      ->randomName();
    $machine_name = personalize_generate_machine_name($label, NULL, '-');
  }
  if (empty($contexts)) {
    $contexts = array(
      array(
        'context' => implode(PERSONALIZE_TARGETING_ADMIN_SEPARATOR, array(
          'some_plugin',
          'some_context',
        )),
        'operator' => 'contains',
        'match' => 'ohai',
      ),
      array(
        'context' => implode(PERSONALIZE_TARGETING_ADMIN_SEPARATOR, array(
          'some_plugin',
          'some_other_context',
        )),
        'operator' => 'starts',
        'match' => 'stuff',
      ),
    );
  }
  module_load_include('inc', 'acquia_lift', 'acquia_lift.admin');
  acquia_lift_target_audience_save($machine_name, $option_set->agent, $contexts, 'AND');
  $this
    ->resetAll();
  return $machine_name;
}