You are here

public function FacebookTrackingPixelTestCaseUser::testFacebookTrackingPixelUserRegistrationGlobal in Facebook Tracking Pixel 7

Same name and namespace in other branches
  1. 8 tests/facebook_tracking_pixel.user.test \FacebookTrackingPixelTestCaseUser::testFacebookTrackingPixelUserRegistrationGlobal()

Test to enable user tracking on global base code.

File

tests/facebook_tracking_pixel.user.test, line 74
Contains tests for the Facebook Tracking Pixel module.

Class

FacebookTrackingPixelTestCaseUser

Code

public function testFacebookTrackingPixelUserRegistrationGlobal() {

  // Turn on user registration and select test global base code.
  $edit = [];
  $this
    ->drupalGet('admin/config/system/facebook_tracking_pixel/user_registration');
  $edit['facebook_tracking_pixel_user_registration_enable'] = TRUE;
  $this
    ->drupalPostAJAX(NULL, $edit, 'facebook_tracking_pixel_user_registration_enable');
  $edit['facebook_tracking_pixel_user_registration_basecode'] = $this->baseCodeID;
  $this
    ->drupalPost(NULL, $edit, t('Save configuration'));
  $this
    ->assertText(t('User tracking settings saved.'), t('User registration tracking enabled.'), 'FBTrkPx');

  // Logout and drop into creating a normal user to test user registration.
  $this
    ->drupalLogout();
  variable_set('user_email_verification', 0);
  variable_set('user_register', 1);
  $this
    ->drupalGet('user/register');
  $edit = [];
  $edit['name'] = $this
    ->randomName(8);
  $edit['mail'] = $edit['name'] . '@example.com';
  $pass = user_password(12);
  $edit['pass[pass1]'] = $pass;
  $edit['pass[pass2]'] = $pass;
  $this
    ->drupalPost(NULL, $edit, t('Create new account'));
  $this
    ->assertText(t('Registration successful. You are now logged in.'), t('Created a user using the UI and logged in.'), 'FBTrkPx');
  $this
    ->assertRaw('facebook_tracking_pixel/registrationtracking/fb_trk_user_registration.js', t('Path tracking code JS found in head.'), 'FBTrkPx');
}