Skip to content

Commit

Permalink
[#212] Fixed When I go to my profile edit page.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Apr 26, 2024
1 parent f1db4ad commit 0fc63bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/UserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ public function userVisitProfile(string $name): void {
/**
* Visit edit page of the current user.
*
* @When I go to my edit profile page
* @When I go to my profile edit page
*/
public function userVisitOwnProfile(): void {
/** @var \Drupal\user\UserInterface $user */
$user = $this->getUserManager()->getCurrentUser();

if (!$user instanceof UserInterface) {
if ($user instanceof \stdClass) {
$id = $user->uid;
}
else {
throw new \RuntimeException('Require user to login before visiting profile page.');
}

$this->userVisitProfile($user->getAccountName());
$this->visitPath("/user/$id/edit");
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/behat/features/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Feature: Check that UserTrait works for or D9
When I edit user "authenticated_user" profile
Then I should get a 200 HTTP response

@api
Scenario: Assert "When I go to my profile edit page"
Given I am logged in as a user with the "administrator" role
When I go to my profile edit page
Then I should get a 200 HTTP response

@api
Scenario: Assert "Given no users:" by name
Given I am logged in as a user with the "administrator" role
Expand Down

0 comments on commit 0fc63bc

Please sign in to comment.