Skip to content

Commit 8ac0a6c

Browse files
committed
[imp] Added function to create a new user
1 parent 3b3e9b6 commit 8ac0a6c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/JoomlaBrowser.php

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

0 commit comments

Comments
 (0)