Add acceptance test for creating a user with a custom display name

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-04-19 00:24:34 +02:00
Родитель ab6688fe0b
Коммит 029b33a664
2 изменённых файлов: 62 добавлений и 0 удалений

Просмотреть файл

@ -44,6 +44,14 @@ class UsersSettingsContext implements Context, ActorAwareInterface {
describedAs("User name field for new user in Users Settings"); describedAs("User name field for new user in Users Settings");
} }
/**
* @return Locator
*/
public static function displayNameFieldForNewUser() {
return Locator::forThe()->field("newdisplayname")->
describedAs("Display name field for new user in Users Settings");
}
/** /**
* @return Locator * @return Locator
*/ */
@ -96,6 +104,13 @@ class UsersSettingsContext implements Context, ActorAwareInterface {
describedAs("$cell input for user $user in Users Settings"); describedAs("$cell input for user $user in Users Settings");
} }
/**
* @return Locator
*/
public static function displayNameCellForUser($user) {
return self::inputForUserInCell("displayName", $user);
}
/** /**
* @return Locator * @return Locator
*/ */
@ -161,6 +176,34 @@ class UsersSettingsContext implements Context, ActorAwareInterface {
$this->actor->find(self::actionsMenuOf($user))->click(); $this->actor->find(self::actionsMenuOf($user))->click();
} }
/**
* @When I set the user name for the new user to :user
*/
public function iSetTheUserNameForTheNewUserTo($user) {
$this->actor->find(self::userNameFieldForNewUser(), 10)->setValue($user);
}
/**
* @When I set the display name for the new user to :displayName
*/
public function iSetTheDisplayNameForTheNewUserTo($displayName) {
$this->actor->find(self::displayNameFieldForNewUser(), 10)->setValue($displayName);
}
/**
* @When I set the password for the new user to :password
*/
public function iSetThePasswordForTheNewUserTo($password) {
$this->actor->find(self::passwordFieldForNewUser(), 10)->setValue($password);
}
/**
* @When I create the new user
*/
public function iCreateTheNewUser() {
$this->actor->find(self::createNewUserButton(), 10)->click();
}
/** /**
* @When I create user :user with password :password * @When I create user :user with password :password
*/ */
@ -242,6 +285,13 @@ class UsersSettingsContext implements Context, ActorAwareInterface {
$this->actor->find(self::inputForUserInCell($field, $user), 10)->getValue(), $value); $this->actor->find(self::inputForUserInCell($field, $user), 10)->getValue(), $value);
} }
/**
* @Then I see that the display name for the user :user is :displayName
*/
public function iSeeThatTheDisplayNameForTheUserIs($user, $displayName) {
PHPUnit_Framework_Assert::assertEquals($displayName, $this->actor->find(self::displayNameCellForUser($user), 10)->getValue());
}
/** /**
* @Then I see that the :cell cell for user :user is done loading * @Then I see that the :cell cell for user :user is done loading
*/ */

Просмотреть файл

@ -9,6 +9,18 @@ Feature: users
When I create user unknownUser with password 123456acb When I create user unknownUser with password 123456acb
Then I see that the list of users contains the user unknownUser Then I see that the list of users contains the user unknownUser
Scenario: create a new user with a custom display name
Given I am logged in as the admin
And I open the User settings
When I click the New user button
And I see that the new user form is shown
And I set the user name for the new user to "test"
And I set the display name for the new user to "Test display name"
And I set the password for the new user to "123456acb"
And I create the new user
Then I see that the list of users contains the user "test"
And I see that the display name for the user "test" is "Test display name"
Scenario: delete a user Scenario: delete a user
Given I act as Jane Given I act as Jane
And I am logged in as the admin And I am logged in as the admin