You are here

protected function AcquiaLiftWebTestBase::createPersonalizedField in Acquia Lift Connector 7.2

Creates an article node with a personalized headline field.

3 calls to AcquiaLiftWebTestBase::createPersonalizedField()
AcquiaLiftWebTestCampaignWizardVariations::testWhatFieldsForm in tests/acquia_lift.test
Test the personalize fields view of the "What" campaign subform.
AcquiaLiftWebTestTarget::testAgentEditableMessaging in tests/acquia_lift.test
Tests messaging for available operations based on agent status.
AcquiaLiftWebTestWorkflow::testPersonalizeFieldsAutoCreateGoal in tests/acquia_lift.test
Tests automatic creation of a goal for personalized fields and auto- starting of the campaign.

File

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

Class

AcquiaLiftWebTestBase
@file Integration tests for Acquia Lift module.

Code

protected function createPersonalizedField() {
  AcquiaLiftAPI::setTestInstance();

  // Create a node which we will attach a fields-based option set to. We can't
  // do this via the form because of the way we alter the form, which makes the
  // "Add an option" button not findable by simpletest.
  $node = new stdClass();
  $node->type = 'article';
  $node->language = LANGUAGE_NONE;
  node_object_prepare($node);
  $node->title = $this
    ->randomName();
  $node->article_headline['und'][0] = array(
    'value' => 'first value',
  );
  $node->article_headline['und'][1] = array(
    'value' => 'second value',
  );
  node_save($node);

  // Now create the option set.
  $option_set = new stdClass();
  $option_set->is_new = TRUE;
  $option_set->data = array();
  $option_set->options = array();
  $option_set->plugin = 'fields';
  $option_set->new_agent_title = 'Article: Personalizable Headline';
  $option_set->options = array(
    array(
      'option_label' => personalize_fields_generate_option_label(0, array(
        'value' => 'first value',
      )),
    ),
    array(
      'option_label' => personalize_fields_generate_option_label(1, array(
        'value' => 'second value',
      )),
    ),
  );
  if (personalize_fields_option_set_prepare($option_set, 'node', $node->nid, $node, 'article_headline')) {
    personalize_fields_option_set_save($option_set, 'node', $node->nid, 'article_headline');
  }
  $this
    ->resetAll();
  $agent_name = $option_set->agent;
  return array(
    $node,
    $option_set,
    $agent_name,
  );
}