Skip to content

Commit bf2a210

Browse files
committed
Merge remote-tracking branch 'origin/MC-21862' into 2.3-develop-pr82
2 parents c4b35b2 + c248a18 commit bf2a210

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Magento\Framework\Message\MessageInterface;
2222
use Magento\Framework\Serialize\Serializer\Json;
2323
use Magento\Framework\Stdlib\CookieManagerInterface;
24+
use Magento\Store\Model\StoreManager;
25+
use Magento\Store\Model\StoreManagerInterface;
2426
use Magento\TestFramework\Helper\Bootstrap;
2527
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
2628
use Magento\TestFramework\Request;
@@ -746,6 +748,65 @@ public function testLoginPostRedirect($redirectDashboard, string $redirectUrl)
746748
$this->assertTrue($this->_objectManager->get(Session::class)->isLoggedIn());
747749
}
748750

751+
/**
752+
* Register Customer with email confirmation.
753+
*
754+
* @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php
755+
* @return void
756+
*/
757+
public function testRegisterCustomerWithEmailConfirmation(): void
758+
{
759+
$email = 'test_example@email.com';
760+
$this->fillRequestWithAccountDataAndFormKey($email);
761+
$this->dispatch('customer/account/createPost');
762+
$this->assertRedirect($this->stringContains('customer/account/index/'));
763+
$this->assertSessionMessages(
764+
$this->equalTo(
765+
[
766+
'You must confirm your account. Please check your email for the confirmation link or '
767+
. '<a href="http://localhost/index.php/customer/account/confirmation/'
768+
. '?email=test_example%40email.com">click here</a> for a new link.'
769+
]
770+
),
771+
MessageInterface::TYPE_SUCCESS
772+
);
773+
/** @var CustomerRepositoryInterface $customerRepository */
774+
$customerRepository = $this->_objectManager->create(CustomerRepositoryInterface::class);
775+
/** @var CustomerInterface $customer */
776+
$customer = $customerRepository->get($email);
777+
$confirmation = $customer->getConfirmation();
778+
$message = $this->transportBuilderMock->getSentMessage();
779+
$rawMessage = $message->getBody()->getParts()[0]->getRawContent();
780+
$messageConstraint = $this->logicalAnd(
781+
new StringContains("You must confirm your {$email} email before you can sign in (link is only valid once"),
782+
new StringContains("customer/account/confirm/?id={$customer->getId()}&amp;key={$confirmation}")
783+
);
784+
$this->assertThat($rawMessage, $messageConstraint);
785+
786+
/** @var CookieManagerInterface $cookieManager */
787+
$cookieManager = $this->_objectManager->get(CookieManagerInterface::class);
788+
$cookieManager->deleteCookie(MessagePlugin::MESSAGES_COOKIES_NAME);
789+
$this->_objectManager->removeSharedInstance(Http::class);
790+
$this->_objectManager->removeSharedInstance(Request::class);
791+
$this->_request = null;
792+
793+
$this->getRequest()
794+
->setParam('id', $customer->getId())
795+
->setParam('key', $confirmation);
796+
$this->dispatch('customer/account/confirm');
797+
798+
/** @var StoreManager $store */
799+
$store = $this->_objectManager->get(StoreManagerInterface::class);
800+
$name = $store->getStore()->getFrontendName();
801+
802+
$this->assertRedirect($this->stringContains('customer/account/index/'));
803+
$this->assertSessionMessages(
804+
$this->equalTo(["Thank you for registering with {$name}."]),
805+
MessageInterface::TYPE_SUCCESS
806+
);
807+
$this->assertEmpty($customerRepository->get($email)->getConfirmation());
808+
}
809+
749810
/**
750811
* Test that confirmation email address displays special characters correctly.
751812
*

0 commit comments

Comments
 (0)