function ALProfilesWebTest::testALProfilesJSSettings in Acquia Lift Connector 7.2
Same name and namespace in other branches
- 7 acquia_lift_profiles/tests/acquia_lift_profiles.test \ALProfilesWebTest::testALProfilesJSSettings()
File
- acquia_lift_profiles/
tests/ acquia_lift_profiles.test, line 46 - Tests for Acquia Lift Profiles module.
Class
- ALProfilesWebTest
- Tests Acquia Lift Profiles functionality.
Code
function testALProfilesJSSettings() {
$this
->configureALProfiles();
// Register as a new user, identity should not be captured.
$user_name_1 = $this
->randomName();
$password_1 = $this
->randomName();
$new_user_fields = array(
'name' => $user_name_1,
'mail' => $user_name_1 . '@example.com',
'pass[pass1]' => $password_1,
'pass[pass2]' => $password_1,
);
$this
->drupalPost('user/register', $new_user_fields, t('Create new account'));
$settings = $this
->drupalGetSettings();
$this
->assertFalse($settings['acquia_lift_profiles']['captureIdentity']);
// Log out and log back in and there still shouldn't be any settings for
// capturing identity.
$this
->drupalLogout();
$this
->drupalPost('user/login', array(
'name' => $user_name_1,
'pass' => $password_1,
), t('Log in'));
$settings = $this
->drupalGetSettings();
$this
->assertFalse($settings['acquia_lift_profiles']['captureIdentity']);
$this
->drupalLogout();
// Login as admin again and set the "capture identity" setting.
$this
->drupalLogin($this->admin_user);
$edit = array(
'acquia_lift_profiles_identity[acquia_lift_profiles_capture_identity]' => TRUE,
);
$this
->drupalPost('admin/config/content/personalize/acquia_lift_profiles', $edit, t('Save'));
$this
->drupalLogout();
$this
->resetAll();
// Now log in as the first new user and check that we do have settings for
// capturing identity.
$this
->drupalPost('user/login', array(
'name' => $user_name_1,
'pass' => $password_1,
), t('Log in'));
$settings = $this
->drupalGetSettings();
$this
->assertTrue($settings['acquia_lift_profiles']['captureIdentity']);
$this
->assertEqual(array(
'form_submit',
'user_login',
), array_keys($settings['acquia_lift_profiles']['serverSideActions']));
$this
->drupalLogout();
// Register as another new user, identity should now be captured.
$user_name_2 = $this
->randomName();
$password_2 = $this
->randomName();
$new_user_fields = array(
'name' => $user_name_2,
'mail' => $user_name_2 . '@example.com',
'pass[pass1]' => $password_2,
'pass[pass2]' => $password_2,
);
$this
->drupalPost('user/register', $new_user_fields, t('Create new account'));
$settings = $this
->drupalGetSettings();
$this
->assertTrue($settings['acquia_lift_profiles']['captureIdentity']);
$this
->assertEqual(array(
'form_submit',
'user_login',
'user_register',
), array_keys($settings['acquia_lift_profiles']['serverSideActions']));
$this
->drupalLogout();
// When registration process requires user email verification,
// identity should not be captured.
variable_set('user_email_verification', TRUE);
$user_name_3 = $this
->randomName();
$new_user_fields = array(
'name' => $user_name_3,
'mail' => $user_name_3 . '@example.com',
);
$this
->drupalPost('user/register', $new_user_fields, t('Create new account'));
$settings = $this
->drupalGetSettings();
$this
->assertTrue($settings['acquia_lift_profiles']['captureIdentity']);
$this
->assertEqual(array(
'form_submit',
), array_keys($settings['acquia_lift_profiles']['serverSideActions']));
}