public function RealnameBasicTest::testRealnameUserUpdate in Real Name 8
Same name and namespace in other branches
- 2.x tests/src/Functional/RealnameBasicTest.php \Drupal\Tests\realname\Functional\RealnameBasicTest::testRealnameUserUpdate()
Test realname user update.
File
- tests/
src/ Functional/ RealnameBasicTest.php, line 164
Class
- RealnameBasicTest
- Test basic functionality of Realname module.
Namespace
Drupal\Tests\realname\FunctionalCode
public function testRealnameUserUpdate() {
$edit['realname_pattern'] = '[user:account-name]';
$this
->drupalGet('admin/config/people/realname');
$this
->submitForm($edit, 'Save configuration');
$user1 = User::load($this->adminUser
->id());
$realname1 = $user1->realname;
// Update user name.
$user1->name = $this
->randomMachineName();
$user1
->save();
// Reload the user.
$user2 = User::load($this->adminUser
->id());
$realname2 = $user2->realname;
// Check if realname changed.
$this
->assertNotEmpty($realname1);
$this
->assertNotEmpty($realname2);
$this
->assertNotEquals($realname1, $realname2, '[testRealnameUserUpdate]: Real name changed.');
}