diff --git a/features/account/customer_account/changing_password.feature b/features/account/customer_account/changing_password.feature index 375ceea072c9..29e32887388a 100644 --- a/features/account/customer_account/changing_password.feature +++ b/features/account/customer_account/changing_password.feature @@ -16,11 +16,8 @@ Feature: Changing a customer password And I save my changes Then I should be notified that my password has been successfully changed - @todo + @api @ui Scenario: Logging to store after password change Given I've changed my password from "whitehouse" to "blackhouse" - When I want to log in - And I specify the username as "francis@underwood.com" - And I specify the password as "blackhouse" - And I log in + When I log in as "francis@underwood.com" with "blackhouse" password Then I should be logged in diff --git a/src/Sylius/Behat/Context/Setup/UserContext.php b/src/Sylius/Behat/Context/Setup/UserContext.php index 82015546cf2c..6e01460ac1b5 100644 --- a/src/Sylius/Behat/Context/Setup/UserContext.php +++ b/src/Sylius/Behat/Context/Setup/UserContext.php @@ -13,13 +13,16 @@ namespace Sylius\Behat\Context\Setup; +use Behat\Behat\Tester\Exception\PendingException; use Behat\Behat\Context\Context; use Doctrine\Common\Persistence\ObjectManager; use Sylius\Behat\Service\SharedStorageInterface; +use Sylius\Bundle\ApiBundle\Command\ChangeShopUserPassword; use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface; use Sylius\Component\Core\Model\ShopUserInterface; use Sylius\Component\User\Model\UserInterface; use Sylius\Component\User\Repository\UserRepositoryInterface; +use Symfony\Component\Messenger\MessageBusInterface; final class UserContext implements Context { @@ -35,16 +38,21 @@ final class UserContext implements Context /** @var ObjectManager */ private $userManager; + /** @var MessageBusInterface */ + private $messageBus; + public function __construct( SharedStorageInterface $sharedStorage, UserRepositoryInterface $userRepository, ExampleFactoryInterface $userFactory, - ObjectManager $userManager + ObjectManager $userManager, + MessageBusInterface $messageBus ) { $this->sharedStorage = $sharedStorage; $this->userRepository = $userRepository; $this->userFactory = $userFactory; $this->userManager = $userManager; + $this->messageBus = $messageBus; } /** @@ -166,4 +174,16 @@ private function prepareUserPasswordResetToken(UserInterface $user): void $this->userManager->flush(); } + + /** + * @Given /^(I)'ve changed my password from "([^"]+)" to "([^"]+)"$/ + */ + public function iveChangedMyPasswordFromTo(UserInterface $user, string $currentPassword, string $newPassword): void + { + $changeShopUserPassword = new ChangeShopUserPassword($newPassword, $newPassword, $currentPassword); + + $changeShopUserPassword->setShopUserId($user->getId()); + + $this->messageBus->dispatch($changeShopUserPassword); + } } diff --git a/src/Sylius/Behat/Context/Ui/Shop/HomepageContext.php b/src/Sylius/Behat/Context/Ui/Shop/HomepageContext.php index 93e777d69819..2c998eb8bdb5 100644 --- a/src/Sylius/Behat/Context/Ui/Shop/HomepageContext.php +++ b/src/Sylius/Behat/Context/Ui/Shop/HomepageContext.php @@ -80,4 +80,13 @@ public function iShouldNotSeeAndInTheMenu(string ...$menuItems): void } } } + + /** + * @Then I should be logged in + */ + public function iShouldBeLoggedIn(): void + { + $this->homePage->verify(); + Assert::true($this->homePage->hasLogoutButton()); + } } diff --git a/src/Sylius/Behat/Resources/config/services/contexts/setup.xml b/src/Sylius/Behat/Resources/config/services/contexts/setup.xml index f0cc65577dde..badc19787e90 100644 --- a/src/Sylius/Behat/Resources/config/services/contexts/setup.xml +++ b/src/Sylius/Behat/Resources/config/services/contexts/setup.xml @@ -276,6 +276,7 @@ + diff --git a/src/Sylius/Behat/Resources/config/suites/ui/account/customer.yml b/src/Sylius/Behat/Resources/config/suites/ui/account/customer.yml index 86ca9c55ad7b..c5905e405839 100644 --- a/src/Sylius/Behat/Resources/config/suites/ui/account/customer.yml +++ b/src/Sylius/Behat/Resources/config/suites/ui/account/customer.yml @@ -34,6 +34,7 @@ default: - sylius.behat.context.setup.zone - sylius.behat.context.ui.channel + - sylius.behat.context.ui.email - sylius.behat.context.ui.shop.account - sylius.behat.context.ui.shop.cart - sylius.behat.context.ui.shop.checkout @@ -42,7 +43,7 @@ default: - sylius.behat.context.ui.shop.checkout.payment - sylius.behat.context.ui.shop.checkout.shipping - sylius.behat.context.ui.shop.currency - - sylius.behat.context.ui.email + - sylius.behat.context.ui.shop.homepage filters: tags: "@customer_account && @ui"