You are here

public function SmsUserWebTest::testSmsUserProfileView in SMS Framework 7

File

modules/sms_user/tests/sms_user.test, line 248
Contains tests for the functions in sms_user.module and user integration.

Class

SmsUserWebTest
Provides integration tests for the sms_user module.

Code

public function testSmsUserProfileView() {
  $user1 = $this
    ->drupalCreateUser(array(
    'receive sms',
    'access user profiles',
  ));
  $edit['sms_user']['status'] = SMS_USER_CONFIRMED;
  $edit['sms_user']['number'] = '1234567890';
  $account1 = user_load($user1->uid);
  user_save($account1, $edit, 'mobile');
  $user2 = $this
    ->drupalCreateUser(array(
    'receive sms',
  ));
  $account2 = user_load($user2->uid);
  $edit['sms_user']['number'] = '23456788901';
  user_save($account2, $edit, 'mobile');

  // Allow phone numbers to be displayed in profiles.
  variable_set('sms_user_sleep', FALSE);
  variable_set('sms_user_allow_opt_out', TRUE);

  // Test that $user1 can see his mobile number and $user2's number also.
  $this
    ->drupalLogin($user1);
  $this
    ->drupalGet('user');
  $this
    ->assertText('1234567890');
  $this
    ->drupalGet('user/' . $user2->uid);
  $this
    ->assertText('23456788901');
  $this
    ->assertResponse(200);

  // Test that $user2 can see his mobile number but not see $user1's number.
  $this
    ->drupalLogin($user2);
  $this
    ->drupalGet('user');
  $this
    ->assertText('23456788901');
  $this
    ->drupalGet('user/' . $user1->uid);
  $this
    ->assertNoText('1234567890');
  $this
    ->assertResponse(403);
}