You are here

protected function AcquiaLiftWebTestBase::createTestAgent in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7 tests/acquia_lift.test \AcquiaLiftWebTestBase::createTestAgent()

Helper function to create an agent.

3 calls to AcquiaLiftWebTestBase::createTestAgent()
AcquiaLiftWebTestFundamentals::testMachineNameValidation in tests/acquia_lift.test
Tests that new agents on the site cannot override existing agents in Lift.
AcquiaLiftWebTestReports::testWinnerLogic in tests/acquia_lift.test
AcquiaLiftWebTestVariationSets::testPersonalizeBlockRedirection in tests/acquia_lift.test

File

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

Class

AcquiaLiftWebTestBase
@file Integration tests for Acquia Lift module.

Code

protected function createTestAgent($label = NULL, $options = array(), $type = 'test_agent') {
  if ($type == 'acquia_lift') {
    $options += array(
      'decision_style' => 'adaptive',
      'control_rate' => 10,
      'explore_rate' => 20,
    );
  }
  else {
    module_enable(array(
      'personalize_test',
    ));
  }
  if (empty($label)) {
    $label = $this
      ->randomName();
  }
  $agent = new stdClass();
  $agent->label = $label;
  $agent->plugin = $type;
  $agent->data = $options;
  $agent->machine_name = personalize_generate_machine_name($label, 'personalize_agent_machine_name_exists');
  $agent = personalize_agent_save($agent);
  $this
    ->resetAll();
  $agent_instance = personalize_agent_load_agent($agent->machine_name, TRUE);
  return $agent_instance;
}