mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Account] Fix approach after PR review
This commit is contained in:
parent
e68dacad5c
commit
368675e2b0
4 changed files with 13 additions and 40 deletions
|
|
@ -63,16 +63,3 @@ Feature: Account 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"
|
||||
|
||||
@ui @email
|
||||
Scenario: Receiving a verification 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 verification email should have been sent to "ghastly@bespoke.com"
|
||||
|
||||
@ui @email
|
||||
Scenario: Not receiving a verification email after registration when channel has disabled registration verification
|
||||
Given on this channel registration verification is disabled
|
||||
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 verification email should not have been sent to "ghastly@bespoke.com"
|
||||
|
|
|
|||
|
|
@ -69,22 +69,6 @@ final class EmailContext implements Context
|
|||
$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$/
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -96,9 +96,7 @@ final class UserRegistrationListener
|
|||
/** @var ChannelInterface $channel */
|
||||
$channel = $this->channelContext->getChannel();
|
||||
if ($channel->isDisabledRegistrationVerification()) {
|
||||
$this->verifyAndLogin($user);
|
||||
|
||||
return;
|
||||
$this->enableAndLogin($user);
|
||||
}
|
||||
|
||||
$this->sendVerificationEmail($user);
|
||||
|
|
@ -121,14 +119,10 @@ final class UserRegistrationListener
|
|||
/**
|
||||
* @param ShopUserInterface $user
|
||||
*/
|
||||
private function verifyAndLogin(ShopUserInterface $user)
|
||||
private function enableAndLogin(ShopUserInterface $user)
|
||||
{
|
||||
$user->setVerifiedAt(new \DateTime());
|
||||
$user->setEnabled(true);
|
||||
|
||||
$this->userManager->persist($user);
|
||||
$this->userManager->flush();
|
||||
|
||||
$this->userLogin->login($user, $this->firewallContextName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,8 +82,10 @@ final class UserRegistrationListenerSpec extends ObjectBehavior
|
|||
$this->handleUserVerification($event);
|
||||
}
|
||||
|
||||
function it_verifies_and_signs_in_user(
|
||||
function it_enables_and_signs_in_user(
|
||||
ObjectManager $userManager,
|
||||
GeneratorInterface $tokenGenerator,
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
ChannelContextInterface $channelContext,
|
||||
UserLoginInterface $userLogin,
|
||||
GenericEvent $event,
|
||||
|
|
@ -97,13 +99,19 @@ final class UserRegistrationListenerSpec extends ObjectBehavior
|
|||
$channelContext->getChannel()->willReturn($channel);
|
||||
$channel->isDisabledRegistrationVerification()->willReturn(true);
|
||||
|
||||
$user->setVerifiedAt(Argument::type('\DateTime'))->shouldBeCalled();
|
||||
$user->setEnabled(true)->shouldBeCalled();
|
||||
$userLogin->login($user, 'shop')->shouldBeCalled();
|
||||
|
||||
$tokenGenerator->generate()->willReturn('1d7dbc5c3dbebe5c');
|
||||
$user->setEmailVerificationToken('1d7dbc5c3dbebe5c')->shouldBeCalled();
|
||||
|
||||
$userManager->persist($user)->shouldBeCalled();
|
||||
$userManager->flush()->shouldBeCalled();
|
||||
|
||||
$userLogin->login($user, 'shop')->shouldBeCalled();
|
||||
$eventDispatcher
|
||||
->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, Argument::type(GenericEvent::class))
|
||||
->shouldBeCalled()
|
||||
;
|
||||
|
||||
$this->handleUserVerification($event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue