You are here

public function FeatureContext::afterScenarioCampaign in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7 behat-tests/features/bootstrap/FeatureContext.php \FeatureContext::afterScenarioCampaign()

Delete any campaigns, option sets, goals, etc. created during the scenario.

@AfterScenario @campaign

File

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

Class

FeatureContext
Defines application features from the specific context.

Code

public function afterScenarioCampaign(AfterScenarioScope $event) {
  $original_campaigns = $this->campaigns;
  $all_campaigns = personalize_agent_load_multiple(array(), array(), TRUE);
  foreach ($all_campaigns as $name => $campaign) {
    if (!isset($original_campaigns[$name])) {
      $option_sets = personalize_option_set_load_by_agent($name);
      foreach ($option_sets as $option_set) {
        personalize_option_set_delete($option_set->osid);
      }
      personalize_agent_delete($name);
    }
  }
  $original_actions = $this->actions;
  $all_actions = visitor_actions_custom_load_multiple(array(), FALSE, TRUE);
  foreach ($all_actions as $name => $action) {
    if (!isset($original_actions[$name])) {
      visitor_actions_delete_action($name);
    }
  }
}