public function createUsers(TableNode $usersTable)
    {
        foreach ($usersTable->getHash() as $userHash) {
            // Split out roles to process after user is created.
            $roles = array();
            if (isset($userHash['roles'])) {
                $roles = explode(',', $userHash['roles']);
                $roles = array_filter(array_map('trim', $roles));
                unset($userHash['roles']);
            }

            $user = (object) $userHash;
            // Set a password.
            if (!isset($user->pass)) {
                $user->pass = $this->getRandom()->name();
            }
            $this->userCreate($user);

            // Assign roles.
            foreach ($roles as $role) {
                $this->getDriver()->userAddRole($user, $role);
            }
        }
    }
public function createUsers(TableNode $usersTable)
    {
        foreach ($usersTable->getHash() as $userHash) {
            // Split out roles to process after user is created.
            $roles = array();
            if (isset($userHash['roles'])) {
                $roles = explode(',', $userHash['roles']);
                $roles = array_filter(array_map('trim', $roles));
                unset($userHash['roles']);
            }

            $user = (object) $userHash;
            // Set a password.
            if (!isset($user->pass)) {
                $user->pass = $this->getRandom()->name();
            }
            $this->userCreate($user);

            // Assign roles.
            foreach ($roles as $role) {
                $this->getDriver()->userAddRole($user, $role);
            }
        }
    }
public function createUsers ( TableNode $ usersTable ) { foreach ( $ usersTable -> getHash ( ) as $ userHash ) { // Split out roles to process after user is created. $ roles = array ( ) ; if ( isset ( $ userHash [ 'roles' ] ) ) { $ roles = explode ( ',' , $ userHash [ 'roles' ] ) ; $ roles = array_filter ( array_map ( 'trim' , $ roles ) ) ; unset ( $ userHash [ 'roles' ] ) ; } $ user = ( object ) $ userHash ; // Set a password. if ( ! isset ( $ user -> pass ) ) { $ user -> pass = $ this -> getRandom ( ) -> name ( ) ; } $ this -> userCreate ( $ user ) ; // Assign roles. foreach ( $ roles as $ role ) { $ this -> getDriver ( ) -> userAddRole ( $ user , $ role ) ; } } }
Creates multiple users.

Provide user data in the following format:

| name     | mail         | roles        |
| user foo | foo@bar.com  | role1, role2 |

@Given users:
Creates multiple users .