diff --git a/src/UserTrait.php b/src/UserTrait.php index 99905048..3364ada6 100644 --- a/src/UserTrait.php +++ b/src/UserTrait.php @@ -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"); } /** diff --git a/tests/behat/features/user.feature b/tests/behat/features/user.feature index d5c0a576..9fb286ee 100644 --- a/tests/behat/features/user.feature +++ b/tests/behat/features/user.feature @@ -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