forked from Sylius/SyliusDemo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Describe displaying verification link in after-registration flash
- Loading branch information
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
features/displaying_verification_link_after_registration.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@customer_registration | ||
Feature: Displaying verification link after registration | ||
In order to be able to use registered account | ||
As a Visitor | ||
I want to have account verification link displayed rather than sent by email | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
|
||
@ui | ||
Scenario: Seeing account verification link in flash message after registration | ||
When I want to register a new account | ||
And I specify the first name as "Gandalf" | ||
And I specify the last name as "The White" | ||
And I specify the email as "gandalf@middle-earth.com" | ||
And I specify the password as "go!go!gondor!" | ||
And I confirm this password | ||
And I register this account | ||
Then I should have account verification link for "gandalf@middle-earth.com" displayed in flash message | ||
But I should not be logged in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Behat\Context\Ui\Shop; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Sylius\Behat\NotificationType; | ||
use Sylius\Behat\Service\NotificationCheckerInterface; | ||
use Sylius\Component\Core\Model\ShopUserInterface; | ||
use Sylius\Component\Resource\Repository\RepositoryInterface; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class RegistrationContext implements Context | ||
{ | ||
/** @var NotificationCheckerInterface */ | ||
private $notificationChecker; | ||
|
||
/** @var UrlGeneratorInterface */ | ||
private $urlGenerator; | ||
|
||
/** @var RepositoryInterface */ | ||
private $shopUserRepository; | ||
|
||
public function __construct( | ||
NotificationCheckerInterface $notificationChecker, | ||
UrlGeneratorInterface $urlGenerator, | ||
RepositoryInterface $shopUserRepository | ||
) { | ||
$this->notificationChecker = $notificationChecker; | ||
$this->urlGenerator = $urlGenerator; | ||
$this->shopUserRepository = $shopUserRepository; | ||
} | ||
|
||
/** | ||
* @Then I should have account verification link for :email displayed in flash message | ||
*/ | ||
public function iShouldHaveAccountVerificationLinkDisplayedInFlashMessage(string $email): void | ||
{ | ||
/** @var ShopUserInterface $shopUser */ | ||
$shopUser = $this->shopUserRepository->findOneBy(['username' => $email]); | ||
Assert::notNull($shopUser); | ||
|
||
$verificationLink = $this->urlGenerator->generate( | ||
'sylius_shop_user_verification', | ||
['_locale' => 'en_US', 'token' => $shopUser->getEmailVerificationToken()] | ||
); | ||
|
||
$this->notificationChecker->checkNotification( | ||
sprintf('For demo purposes you can visit http://localhost:8080%s to verify the account.', $verificationLink), | ||
NotificationType::success() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters