Skip to content

Commit c11790c

Browse files
authored
Allow the creation of a new user with the default user group. (#206)
1 parent a17dae8 commit c11790c

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/JoomlaBrowser.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* @package JoomlaBrowser
4-
*
53
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
64
* @license GNU General Public License version 2 or later; see LICENSE.txt
75
*/
@@ -1280,9 +1278,12 @@ public function createUser($name, $username, $password, $email, $userGroup = 'Su
12801278
$this->fillField(array('id' => 'jform_password2'), $password);
12811279
$this->fillField(array('id' => 'jform_email'), $email);
12821280

1283-
$this->debug('I open the Assigned User Groups Tab and assign the user group');
1284-
$this->click(array('link' => 'Assigned User Groups'));
1285-
$this->click(array('xpath' => "//label[contains(text()[normalize-space()], '$userGroup')]"));
1281+
if (!empty($userGroup))
1282+
{
1283+
$this->debug('I open the Assigned User Groups Tab and assign the user group');
1284+
$this->click($this->locator->adminManageUsersUserGroupAssignmentTab);
1285+
$this->click($this->locator->adminManageUsersUserGroupAssignmentCheckbox($userGroup));
1286+
}
12861287

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

src/Locators/Locators.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* @package JoomlaBrowser
4-
*
53
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
64
* @license GNU General Public License version 2 or later; see LICENSE.txt
75
*/
@@ -136,4 +134,25 @@ class Locators
136134
* @since 3.7.5
137135
*/
138136
public $adminControlPanelText = 'Control Panel';
137+
138+
/**
139+
* Manage User - User Group Assignment Tab
140+
*
141+
* @var string
142+
* @since 3.9.1
143+
*/
144+
public $adminManageUsersUserGroupAssignmentTab = array('link' => 'Assigned User Groups');
145+
146+
/**
147+
* Manage User - User Group Assignment Tab - User Group checkbox
148+
*
149+
* @param string $userGroup display name of the user group
150+
* @return array
151+
* @since 3.9.1
152+
*/
153+
public function adminManageUsersUserGroupAssignmentCheckbox($userGroup)
154+
{
155+
return array('xpath' => "//label[contains(text()[normalize-space()], '$userGroup')]");
156+
}
157+
139158
}

0 commit comments

Comments
 (0)