From 3465f04b370242db2b7de73cf1bb03643f2dd3b8 Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 26 Apr 2016 16:07:52 +0100 Subject: [PATCH] [Behat] Fix User edit sentence fetches the first and last name of the User to select from the conten tree --- Features/Context/Users.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Features/Context/Users.php b/Features/Context/Users.php index 170a59073..39c2a777f 100644 --- a/Features/Context/Users.php +++ b/Features/Context/Users.php @@ -10,9 +10,36 @@ namespace EzSystems\PlatformUIBundle\Features\Context; use Behat\Gherkin\Node\TableNode; +use EzSystems\PlatformBehatBundle\Context\RepositoryContext; +use eZ\Publish\API\Repository\Repository; +use eZ\Publish\API\Repository\UserService; +use eZ\Publish\API\Repository\ContentService; class Users extends PlatformUI { + use RepositoryContext; + + /** + */ + protected $userService; + + /** + */ + protected $contentService; + + /** + * @injectService $repository @ezpublish.api.repository + * @injectService $userService @ezpublish.api.service.user + * @injectService $contentService @ezpublish.api.service.content + */ + public function __construct(Repository $repository, UserService $userService, ContentService $contentService) + { + parent::__construct(); + $this->setRepository($repository); + $this->userService = $userService; + $this->contentService = $contentService; + } + /** * @When I create a new User * @When I fill a new User fields with: @@ -51,8 +78,12 @@ public function goToUserPage($username) */ public function editUserUser($username) { - $this->clickOnTreePath("$username $username"); - $this->sleep(); //safegaurd for application delays + $user = $this->userService->loadUserByLogin($username); + $userObject = $this->contentService->loadContent($user->getUserId()); + $firstName = $userObject->getFieldValue('first_name'); + $lastName = $userObject->getFieldValue('last_name'); + $this->clickOnTreePath("$firstName $lastName"); + $this->sleep(); //safeguard for application delays $this->waitWhileLoading(); $this->clickActionBar('Edit'); } @@ -62,7 +93,7 @@ public function editUserUser($username) */ public function iSeeUsersPage() { - $this->sleep(); // safegaurd for application delays + $this->sleep(); // safeguard for application delays $this->iSeeTitle('Users'); }