@@ -1243,4 +1243,52 @@ public function createCategory($title, $extension = '')
12431243 $ this ->see ('Category saved ' , '#system-message-container ' );
12441244 $ this ->checkForPhpNoticesOrWarnings ();
12451245 }
1246+
1247+ /**
1248+ * Create a user in the administrator site
1249+ *
1250+ * @param string $name Name
1251+ * @param string $username User name (login)
1252+ * @param string $password Password
1253+ * @param string $email Email
1254+ * @param string $userGroup Group id to attach to the user
1255+ *
1256+ * @return void
1257+ *
1258+ * @since 3.8.11
1259+ * @throws \Exception
1260+ */
1261+ public function createUser ($ name , $ username , $ password , $ email , $ userGroup = 'Super Users ' )
1262+ {
1263+ $ this ->debug ('User creation ' );
1264+ $ this ->doAdministratorLogin ();
1265+
1266+ $ this ->amOnPage ('administrator/index.php?option=com_users ' );
1267+
1268+ $ this ->waitForElement (array ('class ' => 'page-title ' ));
1269+ $ this ->checkForPhpNoticesOrWarnings ();
1270+
1271+ $ this ->debug ('Click new user button ' );
1272+ $ this ->click ($ this ->locator ->adminToolbarButtonNew );
1273+
1274+ $ this ->checkForPhpNoticesOrWarnings ();
1275+ $ this ->debug ('I fill up the new user information ' );
1276+ $ this ->fillField (array ('id ' => 'jform_name ' ), $ name );
1277+ $ this ->fillField (array ('id ' => 'jform_username ' ), $ username );
1278+ $ this ->fillField (array ('id ' => 'jform_password ' ), $ password );
1279+ $ this ->fillField (array ('id ' => 'jform_password2 ' ), $ password );
1280+ $ this ->fillField (array ('id ' => 'jform_email ' ), $ email );
1281+
1282+ $ this ->debug ('I open the Assigned User Groups Tab and assign the user group ' );
1283+ $ this ->click (array ('link ' => 'Assigned User Groups ' ));
1284+ $ this ->click (array ('xpath ' => "//label[contains(text()[normalize-space()], ' $ userGroup')] " ));
1285+
1286+ $ this ->debug ('Click new user apply button ' );
1287+ $ this ->click ($ this ->locator ->adminToolbarButtonApply );
1288+
1289+ $ this ->debug ('see a success message after saving the user ' );
1290+
1291+ $ this ->see ('User saved ' , '#system-message-container ' );
1292+ $ this ->checkForPhpNoticesOrWarnings ();
1293+ }
12461294}
0 commit comments