public function FeatureContext::assignVariationToAudience in Acquia Lift Connector 7.2
@When I :action the :variation variation from the :from_audience audience to the :to_audience audience
File
- behat-tests/
features/ bootstrap/ FeatureContext.php, line 708
Class
- FeatureContext
- Defines application features from the specific context.
Code
public function assignVariationToAudience($action, $variation, $from_audience, $to_audience) {
$valid_actions = array(
'move',
'copy',
);
if (!in_array($action, $valid_actions)) {
throw new \Exception(sprintf('Invalid action "%s" supplied for variation assignment. Valid actions are: %s.', $action, implode(', ', $valid_actions)));
}
$from_audience_element = $this
->getAudienceElement($from_audience);
$to_audience_element = $this
->getAudienceElement($to_audience);
if (empty($from_audience_element)) {
throw new \Exception(sprintf('The "%s" audience cannot be found on the current page.', $from_audience));
}
if (empty($to_audience_element)) {
throw new \Exception(sprintf('The "%s" audience cannot be found on the current page.', $to_audience));
}
$from_variations_list = $from_audience_element
->findAll('css', '.acquia-lift-draggable-variations li');
foreach ($from_variations_list as $variation_element) {
$variation_list_item = $variation_element
->getText();
if (strpos($variation_list_item, $variation) === 0) {
$variation_draggable = $action == 'move' ? $variation_element : $variation_element
->find('css', '.acquia-lift-targeting-duplicate-icon');
break;
}
}
if (empty($variation_draggable)) {
throw new \Exception(sprintf('The "%s" variation cannot be found in the list of variations for "%s" audience as a draggable option.', $variation, $from_audience));
}
$to_audience_drop_zone = $to_audience_element
->find('css', '.acquia-lift-targeting-droppable');
$variation_draggable
->dragTo($to_audience_drop_zone);
}