You are here

private function FeatureContext::getAudienceElement in Acquia Lift Connector 7.2

Helper function to retrieve a specific audience targeting element for the current campaign.

Parameters

$audience_label: The audience label assigned.

Return value

NodeElement|null The element found for the audience container or null if not found.

Throws

Exception If the audience is not part of the current campaign.

4 calls to FeatureContext::getAudienceElement()
FeatureContext::assertAudienceHasNoVariation in behat-tests/features/bootstrap/FeatureContext.php
@Then :variation variation should not be assigned to the :audience audience
FeatureContext::assertAudienceHasVariation in behat-tests/features/bootstrap/FeatureContext.php
@Then :variation variation should be assigned to the :audience audience
FeatureContext::assignVariationFromUnassigned in behat-tests/features/bootstrap/FeatureContext.php
@When I move the :variation variation to the :audience audience
FeatureContext::assignVariationToAudience in behat-tests/features/bootstrap/FeatureContext.php
@When I :action the :variation variation from the :from_audience audience to the :to_audience audience

File

behat-tests/features/bootstrap/FeatureContext.php, line 1021

Class

FeatureContext
Defines application features from the specific context.

Code

private function getAudienceElement($audience_label) {
  $agent_name = $this
    ->getCurrentCampaign();
  module_load_include('inc', 'acquia_lift', 'acquia_lift.admin');
  $option_set = acquia_lift_get_option_set_for_targeting($agent_name);
  if (!isset($option_set->targeting)) {
    throw new \Exception(sprintf('The current agent "%s" does not have any audiences available.', $agent_name));
  }
  $audiences = array();
  foreach ($option_set->targeting as $audience_id => $audience) {
    $audiences[$audience['label']] = $audience_id;
  }
  if (!isset($audiences[$audience_label])) {
    throw new \Exception(sprintf('The current agent "%s" does not have an audience named "%s".', $agent_name, $audience_label));
  }
  return $this
    ->findElementInRegion('#edit-audiences-existing-' . $audiences[$audience_label], 'campaign_workflow_form');
}