You are here

public function ExampleFixtureManagementTest::testUserCreation in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/testing_example/tests/src/Kernel/ExampleFixtureManagementTest.php \Drupal\Tests\testing_example\Kernel\ExampleFixtureManagementTest::testUserCreation()

Create a user account using createUser() from the UserCreation trait.

File

testing_example/tests/src/Kernel/ExampleFixtureManagementTest.php, line 111

Class

ExampleFixtureManagementTest
Demonstrate manipulating fixture data in a kernel test.

Namespace

Drupal\Tests\testing_example\Kernel

Code

public function testUserCreation() {

  // Create a user named 'extrauser'.
  $account = $this
    ->createUser([], 'extrauser');

  // Assert that this user exists.
  $this
    ->assertEquals('extrauser', $account
    ->getAccountName());

  // Assert that our auth user is not the same user as extrauser.
  $this
    ->assertNotEquals($this->owner
    ->getAccountName(), $account
    ->getAccountName());
}