Skip to content

Commit c258f98

Browse files
committed
MAGETWO-97195: Automate with Integration test Confirmation email should be delivered to the customer when address contains '+' symbol
1 parent 42553db commit c258f98

7 files changed

+47
-45
lines changed

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController
3838
*/
3939
private $transportBuilderMock;
4040

41+
/**
42+
* @inheritdoc
43+
*/
4144
protected function setUp()
4245
{
4346
parent::setUp();
@@ -682,10 +685,7 @@ public function testConfirmationEmailWithSpecialCharacters()
682685
$this->assertContains('To: ' . $email, $rawMessage);
683686

684687
$content = $message->getBody()->getPartContent(0);
685-
preg_match('<a\s*href="(?<url>.*?)".*>', $content, $matches);
686-
$confirmationUrl = $matches['url'];
687-
$confirmationUrl = str_replace('http://localhost/index.php/','',$confirmationUrl);
688-
$confirmationUrl = html_entity_decode($confirmationUrl);
688+
$confirmationUrl = $this->getConfirmationUrlFromMessageContent($content);
689689
$this->setRequestInfo($confirmationUrl, 'confirm');
690690
$this->clearCookieMessagesList();
691691
$this->dispatch($confirmationUrl);
@@ -844,4 +844,23 @@ private function clearCookieMessagesList()
844844
$jsonSerializer->serialize([])
845845
);
846846
}
847+
848+
/**
849+
* Get confirmation URL from message content.
850+
*
851+
* @param string $content
852+
* @return string
853+
*/
854+
private function getConfirmationUrlFromMessageContent(string $content)
855+
{
856+
$confirmationUrl = '';
857+
858+
if (preg_match('<a\s*href="(?<url>.*?)".*>', $content, $matches)) {
859+
$confirmationUrl = $matches['url'];
860+
$confirmationUrl = str_replace('http://localhost/index.php/', '', $confirmationUrl);
861+
$confirmationUrl = html_entity_decode($confirmationUrl);
862+
}
863+
864+
return $confirmationUrl;
865+
}
847866
}

dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
$objectManager = Bootstrap::getObjectManager();
1414
$mutableScopeConfig = $objectManager->create(MutableScopeConfigInterface::class);
1515

16-
$this->confirmationConfigScopeValue = $mutableScopeConfig->getValue(
17-
'customer/create_account/confirm',
18-
ScopeInterface::SCOPE_WEBSITES,
19-
null
20-
);
21-
2216
$mutableScopeConfig->setValue(
2317
'customer/create_account/confirm',
2418
0,

dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable_rollback.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,18 @@
66

77
declare(strict_types=1);
88

9-
use Magento\Framework\App\Config\MutableScopeConfigInterface;
9+
use Magento\Config\Model\ResourceModel\Config;
1010
use Magento\Framework\Registry;
11-
use Magento\Store\Model\ScopeInterface;
1211
use Magento\TestFramework\Helper\Bootstrap;
1312

1413
/** @var Registry $registry */
1514
$registry = Bootstrap::getObjectManager()->get(Registry::class);
1615
$registry->unregister('isSecureArea');
1716
$registry->register('isSecureArea', true);
1817

19-
$mutableScopeConfig = Bootstrap::getObjectManager()->create(MutableScopeConfigInterface::class);
20-
$mutableScopeConfig->setValue(
21-
'customer/create_account/confirm',
22-
$this->confirmationConfigScopeValue,
23-
ScopeInterface::SCOPE_WEBSITES,
24-
null
25-
);
18+
/** @var Config $config */
19+
$config = Bootstrap::getObjectManager()->create(Config::class);
20+
$config->deleteConfig('customer/create_account/confirm');
2621

2722
$registry->unregister('isSecureArea');
2823
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
$objectManager = Bootstrap::getObjectManager();
1414
$mutableScopeConfig = $objectManager->create(MutableScopeConfigInterface::class);
1515

16-
$this->confirmationConfigScopeValue = $mutableScopeConfig->getValue(
17-
'customer/create_account/confirm',
18-
ScopeInterface::SCOPE_WEBSITES,
19-
null
20-
);
21-
2216
$mutableScopeConfig->setValue(
2317
'customer/create_account/confirm',
2418
1,

dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable_rollback.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,18 @@
66

77
declare(strict_types=1);
88

9-
use Magento\Framework\App\Config\MutableScopeConfigInterface;
9+
use Magento\Config\Model\ResourceModel\Config;
1010
use Magento\Framework\Registry;
11-
use Magento\Store\Model\ScopeInterface;
1211
use Magento\TestFramework\Helper\Bootstrap;
1312

1413
/** @var Registry $registry */
1514
$registry = Bootstrap::getObjectManager()->get(Registry::class);
1615
$registry->unregister('isSecureArea');
1716
$registry->register('isSecureArea', true);
1817

19-
$mutableScopeConfig = Bootstrap::getObjectManager()->create(MutableScopeConfigInterface::class);
20-
$mutableScopeConfig->setValue(
21-
'customer/create_account/confirm',
22-
$this->confirmationConfigScopeValue,
23-
ScopeInterface::SCOPE_WEBSITES,
24-
null
25-
);
18+
/** @var Config $config */
19+
$config = Bootstrap::getObjectManager()->create(Config::class);
20+
$config->deleteConfig('customer/create_account/confirm');
2621

2722
$registry->unregister('isSecureArea');
2823
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,32 @@
66

77
declare(strict_types=1);
88

9+
use Magento\Customer\Api\CustomerRepositoryInterface;
10+
use Magento\Customer\Api\Data\CustomerInterface;
911
use Magento\Customer\Model\Customer;
1012
use Magento\TestFramework\Helper\Bootstrap;
1113

1214
include __DIR__ . '/customer_confirmation_config_enable.php';
1315

1416
$objectManager = Bootstrap::getObjectManager();
17+
1518
/** @var Customer $customer */
1619
$customer = $objectManager->create(Customer::class);
17-
$customer->setWebsiteId(1)
18-
->setId(1)
20+
/** @var CustomerRepositoryInterface $customerRepository */
21+
$customerRepository = $objectManager->create(CustomerRepositoryInterface::class);
22+
/** @var CustomerInterface $customerInterface */
23+
$customerInterface = $objectManager->create(CustomerInterface::class);
24+
25+
$customerInterface->setWebsiteId(1)
1926
->setEmail('customer+confirmation@example.com')
20-
->setPassword('password')
2127
->setConfirmation($customer->getRandomConfirmationKey())
2228
->setGroupId(1)
2329
->setStoreId(1)
24-
->setIsActive(1)
2530
->setFirstname('John')
2631
->setLastname('Smith')
2732
->setDefaultBilling(1)
2833
->setDefaultShipping(1)
2934
->setTaxvat('12')
3035
->setGender(0);
3136

32-
$customer->isObjectNew(true);
33-
$customer->save();
37+
$customerRepository->save($customerInterface, 'password');

dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars_rollback.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88

99
include __DIR__ . '/customer_confirmation_config_enable_rollback.php';
1010

11+
use Magento\Customer\Api\CustomerRepositoryInterface;
1112
use Magento\Framework\Registry;
1213
use Magento\TestFramework\Helper\Bootstrap;
13-
use Magento\Customer\Model\Customer;
1414

1515
/** @var Registry $registry */
1616
$registry = Bootstrap::getObjectManager()->get(Registry::class);
1717
$registry->unregister('isSecureArea');
1818
$registry->register('isSecureArea', true);
1919

20-
/** @var Customer $customer */
21-
$customer = Bootstrap::getObjectManager()->create(Customer::class);
22-
$customer->load(1);
20+
/** @var CustomerRepositoryInterface $customerRepository */
21+
$customerRepository = Bootstrap::getObjectManager()->create(CustomerRepositoryInterface::class);
22+
$customer = $customerRepository->get('customer+confirmation@example.com');
23+
2324
if ($customer->getId()) {
24-
$customer->delete();
25+
$customerRepository->delete($customer);
2526
}
2627

2728
$registry->unregister('isSecureArea');

0 commit comments

Comments
 (0)