public function FeatureContext::assertAudienceHasVariation in Acquia Lift Connector 7.2
@Then :variation variation should be assigned to the :audience audience
File
- behat-tests/
features/ bootstrap/ FeatureContext.php, line 739
Class
- FeatureContext
- Defines application features from the specific context.
Code
public function assertAudienceHasVariation($variation_label, $audience_label) {
$escaped_variation = $this
->getSession()
->getSelectorsHandler()
->xpathLiteral($variation_label);
$audience_element = $this
->getAudienceElement($audience_label);
if (empty($audience_element)) {
throw new \Exception(sprintf('The "%s" audience container cannot be found on the page.', $audience_label));
}
$variation_select = $audience_element
->find('css', 'select[name*=assignment]');
$variation_option = $variation_select
->find('named', array(
'option',
$escaped_variation,
));
if (empty($variation_option)) {
throw new \Exception(sprintf('The "%s" variation cannot be found in the "%s" audience variation select options.', $variation_label, $audience_label));
}
if (!$variation_option
->isSelected()) {
throw new \Exception(sprintf('The "%s" variation is not selected for the "%s" audience.', $variation_label, $audience_label));
}
$variations_list = $audience_element
->find('css', '.acquia-lift-draggable-variations');
$variation_display = $variations_list
->find('named', array(
'content',
$escaped_variation,
));
if (empty($variation_display)) {
throw new \Exception(sprintf('The "%s" variation is not displayed for "%s" audience.', $variation_label, $audience_label));
}
}