Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/JoomlaBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1225,4 +1225,52 @@ public function createCategory($title, $extension = '')
$this->see('Category saved', '#system-message-container');
$this->checkForPhpNoticesOrWarnings();
}

/**
* Create a user in the administrator site
*
* @param string $name Name
* @param string $username User name (login)
* @param string $password Password
* @param string $email Email
* @param string $userGroup Group id to attach to the user
*
* @return void
*
* @since 3.8.11
* @throws \Exception
*/
public function createUser($name, $username, $password, $email, $userGroup = 'Super Users')
{
$this->debug('User creation');
$this->doAdministratorLogin();

$this->amOnPage('administrator/index.php?option=com_users');

$this->waitForElement(array('class' => 'page-title'));
$this->checkForPhpNoticesOrWarnings();

$this->debug('Click new user button');
$this->click($this->locator->adminToolbarButtonNew);

$this->checkForPhpNoticesOrWarnings();
$this->debug('I fill up the new user information');
$this->fillField(array('id' => 'jform_name'), $name);
$this->fillField(array('id' => 'jform_username'), $username);
$this->fillField(array('id' => 'jform_password'), $password);
$this->fillField(array('id' => 'jform_password2'), $password);
$this->fillField(array('id' => 'jform_email'), $email);

$this->debug('I open the Assigned User Groups Tab and assign the user group');
$this->click(array('link' => 'Assigned User Groups'));
$this->click(array('xpath' => "//label[contains(text()[normalize-space()], '$userGroup')]"));

$this->debug('Click new user apply button');
$this->click($this->locator->adminToolbarButtonApply);

$this->debug('see a success message after saving the user');

$this->see('User saved', '#system-message-container');
$this->checkForPhpNoticesOrWarnings();
}
}