[Behat][Account] Implement scenarios for registering when channel has disabled registration confirmation

This commit is contained in:
Grzegorz Sadowski 2017-02-21 09:27:01 +01:00
parent 05dbcccc7a
commit 251800303f
4 changed files with 49 additions and 14 deletions

View file

@ -19,7 +19,7 @@ Feature: Account registration
Then I should be notified that new account has been successfully created Then I should be notified that new account has been successfully created
But I should not be logged in But I should not be logged in
@ui @todo @ui
Scenario: Registering a new account with minimum information when channel has disabled registration verification Scenario: Registering a new account with minimum information when channel has disabled registration verification
Given on this channel registration verification is disabled Given on this channel registration verification is disabled
When I want to register a new account When I want to register a new account
@ -64,13 +64,13 @@ Feature: Account registration
Then I should be notified that new account has been successfully created Then I should be notified that new account has been successfully created
And a welcoming email should have been sent to "ghastly@bespoke.com" And a welcoming email should have been sent to "ghastly@bespoke.com"
@ui @email @todo @ui @email
Scenario: Receiving a verification email after registration Scenario: Receiving a verification email after registration
When I register with email "ghastly@bespoke.com" and password "suitsarelife" When I register with email "ghastly@bespoke.com" and password "suitsarelife"
Then I should be notified that new account has been successfully created Then I should be notified that new account has been successfully created
And a verification email should have been sent to "ghastly@bespoke.com" And a verification email should have been sent to "ghastly@bespoke.com"
@ui @email @todo @ui @email
Scenario: Not receiving a verification email after registration when channel has disabled registration verification Scenario: Not receiving a verification email after registration when channel has disabled registration verification
Given on this channel registration verification is disabled Given on this channel registration verification is disabled
When I register with email "ghastly@bespoke.com" and password "suitsarelife" When I register with email "ghastly@bespoke.com" and password "suitsarelife"

View file

@ -163,6 +163,26 @@ final class ChannelContext implements Context
$this->channelManager->flush(); $this->channelManager->flush();
} }
/**
* @Given /^on (this channel) shipping step is skipped if only a single shipping method is available$/
*/
public function onThisChannelShippingStepIsSkippedIfOnlyASingleShippingMethodIsAvailable(ChannelInterface $channel)
{
$channel->setSkippingShippingStepAllowed(true);
$this->channelManager->flush();
}
/**
* @Given /^on (this channel) registration verification is disabled$/
*/
public function onThisChannelRegistrationVerificationIsDisabled(ChannelInterface $channel)
{
$channel->setDisabledRegistrationVerification(true);
$this->channelManager->flush();
}
/** /**
* @param ChannelInterface $channel * @param ChannelInterface $channel
* @param bool $state * @param bool $state
@ -173,14 +193,4 @@ final class ChannelContext implements Context
$this->channelManager->flush(); $this->channelManager->flush();
$this->sharedStorage->set('channel', $channel); $this->sharedStorage->set('channel', $channel);
} }
/**
* @Given /^on (this channel) shipping step is skipped if only a single shipping method is available$/
*/
public function onThisChannelShippingStepIsSkippedIfOnlyASingleShippingMethodIsAvailable(ChannelInterface $channel)
{
$channel->setSkippingShippingStepAllowed(true);
$this->channelManager->flush();
}
} }

View file

@ -69,6 +69,22 @@ final class EmailContext implements Context
$this->assertEmailContainsMessageTo('Welcome to our store', $recipient); $this->assertEmailContainsMessageTo('Welcome to our store', $recipient);
} }
/**
* @Then a verification email should have been sent to :recipient
*/
public function aVerificationEmailShouldHaveBeenSentTo($recipient)
{
$this->assertEmailContainsMessageTo('To verify your email address', $recipient);
}
/**
* @Then a verification email should not have been sent to :recipient
*/
public function aVerificationEmailShouldNotHaveBeenSentTo($recipient)
{
$this->assertEmailNotContainsMessageTo('To verify your email address', $recipient);
}
/** /**
* @Then /^an email with the summary of (order placed by "([^"]+)") should be sent to him$/ * @Then /^an email with the summary of (order placed by "([^"]+)") should be sent to him$/
*/ */
@ -104,6 +120,15 @@ final class EmailContext implements Context
Assert::true($this->emailChecker->hasMessageTo($message, $recipient)); Assert::true($this->emailChecker->hasMessageTo($message, $recipient));
} }
/**
* @param string $message
* @param string $recipient
*/
private function assertEmailNotContainsMessageTo($message, $recipient)
{
Assert::false($this->emailChecker->hasMessageTo($message, $recipient));
}
/** /**
* @param OrderInterface $order * @param OrderInterface $order
* *

View file

@ -220,7 +220,7 @@ class RegistrationContext implements Context
public function iShouldBeNotifiedThatNewAccountHasBeenSuccessfullyCreated() public function iShouldBeNotifiedThatNewAccountHasBeenSuccessfullyCreated()
{ {
$this->notificationChecker->checkNotification( $this->notificationChecker->checkNotification(
'Thank you for registering, check your email to verify your account.', 'Thank you for registering. If you are not logged in, check your email to verify your account.',
NotificationType::success() NotificationType::success()
); );
} }