You are here

public function RealnameBasicTest::testRealnameUserUpdate in Real Name 7

Test realname user update.

File

tests/realname.test, line 130
Test file for Realname module.

Class

RealnameBasicTest
Test basic functionality of Realname module.

Code

public function testRealnameUserUpdate() {
  $edit['realname_pattern'] = '[user:name-raw]';
  $this
    ->drupalPost('admin/config/people/realname', $edit, t('Save configuration'));
  $user1 = user_load($this->admin_user->uid);
  $realname1 = $user1->realname;

  // Update user name.
  $user1->name = $this
    ->randomName();
  user_save($user1);

  // Reload the user.
  $user2 = user_load($this->admin_user->uid);
  $realname2 = $user2->realname;

  // Check if realname changed.
  $this
    ->assertTrue($realname1);
  $this
    ->assertTrue($realname2);
  $this
    ->assertNotEqual($realname1, $realname2, '[testRealnameUserUpdate]: Real name changed.');
}