You are here

function ALProfilesWebTest::testIdentityParams in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 acquia_lift_profiles/tests/acquia_lift_profiles.test \ALProfilesWebTest::testIdentityParams()

Tests identity param configuration and js settings.

File

acquia_lift_profiles/tests/acquia_lift_profiles.test, line 221
Tests for Acquia Lift Profiles module.

Class

ALProfilesWebTest
Tests Acquia Lift Profiles functionality.

Code

function testIdentityParams() {
  $this
    ->configureALProfiles();
  $this
    ->drupalLogin($this->admin_user);

  // Test specifying a querystring param to use for capturing identity.
  $this
    ->drupalPost('admin/config/content/personalize/acquia_lift_profiles', array(
    'acquia_lift_profiles_identity[acquia_lift_profiles_identity_param]' => 'ali',
  ), t('Save'));
  $this
    ->drupalLogout();

  // Now visit the site as anon without passing any querystring params.
  $this
    ->drupalGet('');
  $settings = $this
    ->drupalGetSettings();
  $alp_settings = $settings['acquia_lift_profiles'];
  $this
    ->assertFalse(isset($alp_settings['identity']));

  // Now pass the configured identity param
  $my_id = 'ohai';
  $this
    ->drupalGet('', array(
    'query' => array(
      'ali' => $my_id,
    ),
  ));
  $settings = $this
    ->drupalGetSettings();
  $alp_settings = $settings['acquia_lift_profiles'];
  $this
    ->assertEqual($alp_settings['identity'], $my_id);
  $this
    ->assertEqual($alp_settings['identityType'], ACQUIA_LIFT_PROFILES_DEFAULT_IDENTITY_TYPE_DEFAULT);

  // Set the identity type param
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalPost('admin/config/content/personalize/acquia_lift_profiles', array(
    'acquia_lift_profiles_identity[acquia_lift_profiles_identity_type_param]' => 'alit',
  ), t('Save'));
  $this
    ->drupalLogout();

  // Pass the configured identity param and the identity_type param
  $my_type = 'socialtastic';
  $this
    ->drupalGet('', array(
    'query' => array(
      'ali' => $my_id,
      'alit' => $my_type,
    ),
  ));
  $settings = $this
    ->drupalGetSettings();
  $alp_settings = $settings['acquia_lift_profiles'];
  $this
    ->assertEqual($alp_settings['identity'], $my_id);
  $this
    ->assertEqual($alp_settings['identityType'], $my_type);

  // Pass the configured identity type param without the identity param
  $this
    ->drupalGet('', array(
    'query' => array(
      'alit' => $my_type,
    ),
  ));
  $settings = $this
    ->drupalGetSettings();
  $alp_settings = $settings['acquia_lift_profiles'];
  $this
    ->assertFalse(isset($alp_settings['identity']));
  $this
    ->assertFalse(isset($alp_settings['identityType']));

  // Set the default identity type
  $default_type = 'tknr';
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalPost('admin/config/content/personalize/acquia_lift_profiles', array(
    'acquia_lift_profiles_identity[acquia_lift_profiles_default_identity_type]' => $default_type,
  ), t('Save'));
  $this
    ->drupalLogout();

  // Pass the configured identity param but without the identity_type param
  $this
    ->drupalGet('', array(
    'query' => array(
      'ali' => $my_id,
    ),
  ));
  $settings = $this
    ->drupalGetSettings();
  $alp_settings = $settings['acquia_lift_profiles'];
  $this
    ->assertEqual($alp_settings['identity'], $my_id);
  $this
    ->assertEqual($alp_settings['identityType'], $default_type);

  // Pass the configured identity param and with the identity_type param
  $this
    ->drupalGet('', array(
    'query' => array(
      'ali' => $my_id,
      'alit' => $my_type,
    ),
  ));
  $settings = $this
    ->drupalGetSettings();
  $alp_settings = $settings['acquia_lift_profiles'];
  $this
    ->assertEqual($alp_settings['identity'], $my_id);
  $this
    ->assertEqual($alp_settings['identityType'], $my_type);
}