You are here

protected function AcquiaLiftWebTestBase::createPersonalizedBlock in Acquia Lift Connector 7.2

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

Creates the required number of custom blocks.

Parameters

int $num: The number of blocks to create.

Return value

array An array of block deltas for use in personalized blocks.

10 calls to AcquiaLiftWebTestBase::createPersonalizedBlock()
AcquiaLiftWebTestAgentAdmin::testAgentList in tests/acquia_lift.test
AcquiaLiftWebTestBase::createTargetingAgentWithNestedTest in tests/acquia_lift.test
AcquiaLiftWebTestCampaignWizardReview::testReviewFormStatus in tests/acquia_lift.test
Tests review form status changes.
AcquiaLiftWebTestReports::testAudienceReportLogic in tests/acquia_lift.test
AcquiaLiftWebTestReports::testReportEndDate in tests/acquia_lift.test

... See full list

File

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

Class

AcquiaLiftWebTestBase
@file Integration tests for Acquia Lift module.

Code

protected function createPersonalizedBlock($index, $agent, $num_options = 2) {
  $option_set = array(
    'plugin' => 'block',
    'label' => 'Option Set ' . ($index + 1),
    'agent' => $agent->machine_name,
    'data' => array(
      'block_title' => 'Personalized Block ' . ($index + 1),
    ),
  );
  $options = array();
  module_load_include('inc', 'personalize_blocks', 'personalize_blocks.admin');
  for ($i = 1; $i <= $num_options; $i++) {
    $title = t('Custom block @num from @index', array(
      '@num' => $i,
      '@index' => $index,
    ));
    $values = array(
      'title' => $title,
      'info' => $title,
      'body' => array(
        'format' => 'filtered_html',
        'value' => 'Some value',
      ),
    );
    $option = array(
      'option_label' => 'Option ' . $i,
      'option_id' => 'option-' . $i,
      'bid' => _personalize_blocks_add_custom_block($values),
    );
    $options[] = $option;
  }
  $option_set['options'] = $options;
  $option_set = (object) $option_set;
  try {
    personalize_option_set_save($option_set);
  } catch (PersonalizeException $e) {
    $this
      ->fail('Exception thrown with message: . ' . $e
      ->getMessage());
    return NULL;
  }
  return $option_set;
}