mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Behat] Checked whether a customer receives the welcoming email
This commit is contained in:
parent
a91d26e964
commit
9a9e3b4b28
2 changed files with 44 additions and 12 deletions
|
|
@ -47,3 +47,9 @@ Feature: Account registration
|
|||
Then I should be notified that new account has been successfully created
|
||||
And I should be logged in
|
||||
And my email should be "goodman@gmail.com"
|
||||
|
||||
@ui @email
|
||||
Scenario: Receiving a welcoming email after registration
|
||||
When I register with email "ghastly@bespoke.com" and password "suitsarelife"
|
||||
Then I should be notified that new account has been successfully created
|
||||
And a welcoming email should have been sent to "ghastly@bespoke.com"
|
||||
|
|
|
|||
|
|
@ -374,25 +374,19 @@ class RegistrationContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then it should be sent to :email
|
||||
* @Then it should be sent to :recipient
|
||||
*/
|
||||
public function verificationEmailShouldBeSentTo($email)
|
||||
public function anEmailShouldBeSentTo($recipient)
|
||||
{
|
||||
Assert::true(
|
||||
$this->emailChecker->hasRecipient($email),
|
||||
'The verification email should have been sent.'
|
||||
);
|
||||
$this->assertEmailHasRecipient($recipient);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then :count email(s) should be sent to :email
|
||||
* @Then :count email(s) should be sent to :recipient
|
||||
*/
|
||||
public function numberOfEmailsShouldBeSentTo($count, $email)
|
||||
public function numberOfEmailsShouldBeSentTo($count, $recipient)
|
||||
{
|
||||
Assert::true(
|
||||
$this->emailChecker->hasRecipient($email),
|
||||
sprintf('At least 1 email should have been sent to %s.', $email)
|
||||
);
|
||||
$this->assertEmailHasRecipient($recipient);
|
||||
|
||||
Assert::eq(
|
||||
$this->emailChecker->getMessagesCount(),
|
||||
|
|
@ -405,6 +399,38 @@ class RegistrationContext implements Context
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then a welcoming email should have been sent to :recipient
|
||||
*/
|
||||
public function aWelcomingEmailShouldHaveBeenSentTo($recipient)
|
||||
{
|
||||
$this->assertEmailHasRecipient($recipient);
|
||||
$this->assertEmailContainsMessage('Welcome to our store');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $recipient
|
||||
*/
|
||||
private function assertEmailHasRecipient($recipient)
|
||||
{
|
||||
Assert::true(
|
||||
$this->emailChecker->hasRecipient($recipient),
|
||||
'An email should have been sent to %s.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
private function assertEmailContainsMessage($message)
|
||||
{
|
||||
Assert::true(
|
||||
$this->emailChecker->hasMessage($message),
|
||||
sprintf('Message "%s" was not found in any email.', $message)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $element
|
||||
* @param string $expectedMessage
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue