You are here

public function RealnameEntityTest::testRealnameUserUpdate in Real Name 7

Test realname user update hook.

File

tests/realname_entity.test, line 41
Test file for Realname module.

Class

RealnameEntityTest
Test entity related functionality.

Code

public function testRealnameUserUpdate() {
  variable_set('realname_pattern', '[user:name-raw]');
  $uid = $this->user->uid;
  $wrapper1 = entity_metadata_wrapper('user', $uid);
  $realname1 = $wrapper1
    ->label();

  // Update user name via entity_metadata_wrapper.
  $wrapper1->name = $this
    ->randomName();
  $wrapper1
    ->save();

  // Reload the user via entity_metadata_wrapper.
  $wrapper2 = entity_metadata_wrapper('user', $uid);
  $realname2 = $wrapper2
    ->label();

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