protected function AcquiaLiftWebTestWorkflow::createPersonalizedField in Acquia Lift Connector 7
Creates an article node with a personalized headline field.
1 call to AcquiaLiftWebTestWorkflow::createPersonalizedField()
- 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 3179 - Integration tests for Acquia Lift module.
Class
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,
);
}