public function createUserWithRoles(array $roles = ['authenticated'], $password = FALSE) {
    $faker = Faker::create();
    /** @var \Drupal\user\Entity\User $user */
    $user = User::create([
      'name' => $faker->userName,
      'mail' => $faker->email,
      'roles' => $roles,
      'pass' => $password ? $password : $faker->password(12, 14),
      'status' => 1,
    ]);

    $user->save();

    $this->users[] = $user->id();

    return $user;
  }
public function createUserWithRoles(array $roles = ['authenticated'], $password = FALSE) {
    $faker = Faker::create();
    /** @var \Drupal\user\Entity\User $user */
    $user = User::create([
      'name' => $faker->userName,
      'mail' => $faker->email,
      'roles' => $roles,
      'pass' => $password ? $password : $faker->password(12, 14),
      'status' => 1,
    ]);

    $user->save();

    $this->users[] = $user->id();

    return $user;
  }
public function createUserWithRoles ( array $ roles = [ 'authenticated' ] , $ password = FALSE ) { $ faker = Faker :: create ( ) ; /** @var \Drupal\user\Entity\User $user */ $ user = User :: create ( [ 'name' => $ faker -> userName , 'mail' => $ faker -> email , 'roles' => $ roles , 'pass' => $ password ? $ password : $ faker -> password ( 12 , 14 ) , 'status' => 1 , ] ) ; $ user -> save ( ) ; $ this -> users [ ] = $ user -> id ( ) ; return $ user ; }
Create test user with specified roles.

@param array $roles
List of user roles.
@param mixed $password
Password.

@return \Drupal\user\Entity\User
User object.
Create test user with specified roles .