Skip to content

Commit 3171173

Browse files
committed
MC-21862: [Integration] Automate MC-11658
1 parent 99f206f commit 3171173

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
use Magento\Framework\Message\MessageInterface;
2121
use Magento\Framework\Serialize\Serializer\Json;
2222
use Magento\Framework\Stdlib\CookieManagerInterface;
23+
use Magento\Store\Model\StoreManager;
24+
use Magento\Store\Model\StoreManagerInterface;
2325
use Magento\TestFramework\Helper\Bootstrap;
2426
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
2527
use Magento\TestFramework\Request;
2628
use Magento\TestFramework\Response;
2729
use Magento\Theme\Controller\Result\MessagePlugin;
30+
use PHPUnit\Framework\Constraint\StringContains;
2831
use Zend\Stdlib\Parameters;
2932

3033
/**
@@ -744,6 +747,63 @@ public function testLoginPostRedirect($redirectDashboard, string $redirectUrl)
744747
$this->assertTrue($this->_objectManager->get(Session::class)->isLoggedIn());
745748
}
746749

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

0 commit comments

Comments
 (0)