Skip to content

Commit 544cfdd

Browse files
authored
Merge pull request #177 from jatitoam/user
[imp] Added function to create a new user
2 parents 3b3e9b6 + f7939be commit 544cfdd

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/JoomlaBrowser.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,4 +1225,52 @@ public function createCategory($title, $extension = '')
12251225
$this->see('Category saved', '#system-message-container');
12261226
$this->checkForPhpNoticesOrWarnings();
12271227
}
1228+
1229+
/**
1230+
* Create a user in the administrator site
1231+
*
1232+
* @param string $name Name
1233+
* @param string $username User name (login)
1234+
* @param string $password Password
1235+
* @param string $email Email
1236+
* @param string $userGroup Group id to attach to the user
1237+
*
1238+
* @return void
1239+
*
1240+
* @since 3.8.11
1241+
* @throws \Exception
1242+
*/
1243+
public function createUser($name, $username, $password, $email, $userGroup = 'Super Users')
1244+
{
1245+
$this->debug('User creation');
1246+
$this->doAdministratorLogin();
1247+
1248+
$this->amOnPage('administrator/index.php?option=com_users');
1249+
1250+
$this->waitForElement(array('class' => 'page-title'));
1251+
$this->checkForPhpNoticesOrWarnings();
1252+
1253+
$this->debug('Click new user button');
1254+
$this->click($this->locator->adminToolbarButtonNew);
1255+
1256+
$this->checkForPhpNoticesOrWarnings();
1257+
$this->debug('I fill up the new user information');
1258+
$this->fillField(array('id' => 'jform_name'), $name);
1259+
$this->fillField(array('id' => 'jform_username'), $username);
1260+
$this->fillField(array('id' => 'jform_password'), $password);
1261+
$this->fillField(array('id' => 'jform_password2'), $password);
1262+
$this->fillField(array('id' => 'jform_email'), $email);
1263+
1264+
$this->debug('I open the Assigned User Groups Tab and assign the user group');
1265+
$this->click(array('link' => 'Assigned User Groups'));
1266+
$this->click(array('xpath' => "//label[contains(text()[normalize-space()], '$userGroup')]"));
1267+
1268+
$this->debug('Click new user apply button');
1269+
$this->click($this->locator->adminToolbarButtonApply);
1270+
1271+
$this->debug('see a success message after saving the user');
1272+
1273+
$this->see('User saved', '#system-message-container');
1274+
$this->checkForPhpNoticesOrWarnings();
1275+
}
12281276
}

0 commit comments

Comments
 (0)