|
10 | 10 | use Magento\Customer\Test\Fixture\Customer;
|
11 | 11 | use Magento\Framework\App\Area;
|
12 | 12 | use Magento\Framework\Exception\LocalizedException;
|
13 |
| -use Magento\Framework\Mail\Template\TransportBuilder; |
14 | 13 | use Magento\Framework\ObjectManagerInterface;
|
15 | 14 | use Magento\Newsletter\Model\Subscriber;
|
16 | 15 | use Magento\Store\Test\Fixture\Group as StoreGroupFixture;
|
|
20 | 19 | use Magento\TestFramework\Fixture\DataFixture;
|
21 | 20 | use Magento\TestFramework\Fixture\DataFixtureStorage;
|
22 | 21 | use Magento\TestFramework\Fixture\DataFixtureStorageManager;
|
| 22 | +use Magento\TestFramework\Fixture\DbIsolation; |
23 | 23 | use Magento\TestFramework\Helper\Bootstrap;
|
| 24 | +use Magento\TestFramework\Mail\Template\TransportBuilderMock; |
24 | 25 |
|
25 | 26 | /**
|
26 | 27 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
@@ -56,6 +57,7 @@ protected function setUp(): void
|
56 | 57 | * @throws \Magento\Framework\Exception\MailException
|
57 | 58 | */
|
58 | 59 | #[
|
| 60 | + DbIsolation(false), |
59 | 61 | ConfigFixture('system/smtp/transport', 'smtp', 'store'),
|
60 | 62 | DataFixture(WebsiteFixture::class, as: 'website2'),
|
61 | 63 | DataFixture(StoreGroupFixture::class, ['website_id' => '$website2.id$'], 'store_group2'),
|
@@ -117,37 +119,32 @@ private function subscribeNewsLetterAndAssertFromHeader(
|
117 | 119 | /** @var Subscriber $subscriber */
|
118 | 120 | $subscriber = $this->objectManager->create(Subscriber::class);
|
119 | 121 | $subscriber->subscribe($customerData['email']);
|
120 |
| - $subscriber->confirm($subscriber->getSubscriberConfirmCode()); |
121 | 122 |
|
122 |
| - /** @var TransportBuilder $transportBuilder */ |
123 |
| - $transportBuilder = $this->objectManager->get(TransportBuilder::class); |
124 |
| - $transport = $transportBuilder->setTemplateIdentifier('newsletter_subscription_confirm_email_template') |
125 |
| - ->setTemplateOptions( |
126 |
| - [ |
127 |
| - 'area' => Area::AREA_FRONTEND, |
128 |
| - 'store' => (int) $customerData['storeId'] |
129 |
| - ] |
130 |
| - ) |
131 |
| - ->setFromByScope( |
132 |
| - [ |
133 |
| - 'email' => $customerData['storeEmail'], |
134 |
| - 'name' => 'Store Email Name' |
135 |
| - ], |
136 |
| - (int) $customerData['storeId'] |
137 |
| - ) |
138 |
| - ->setTemplateVars( |
139 |
| - [ |
140 |
| - 'subscriber_data' => [ |
141 |
| - 'confirmation_link' => $subscriber->getConfirmationLink(), |
142 |
| - ], |
143 |
| - ] |
144 |
| - ) |
145 |
| - ->addTo($customerData['email']) |
146 |
| - ->getTransport(); |
147 |
| - $transport->sendMessage(); |
| 123 | + /** @var TransportBuilderMock $transportBuilderMock */ |
| 124 | + $transportBuilderMock = $this->objectManager->get(TransportBuilderMock::class); |
| 125 | + $transport = $transportBuilderMock->setTemplateIdentifier( |
| 126 | + 'customer_password_reset_password_template' |
| 127 | + )->setTemplateVars([ |
| 128 | + 'subscriber_data' => [ |
| 129 | + 'confirmation_link' => $subscriber->getConfirmationLink(), |
| 130 | + ], |
| 131 | + ])->setTemplateOptions([ |
| 132 | + 'area' => Area::AREA_FRONTEND, |
| 133 | + 'store' => (int) $customerData['storeId'] |
| 134 | + ]) |
| 135 | + ->setFromByScope( |
| 136 | + [ |
| 137 | + 'email' => $customerData['storeEmail'], |
| 138 | + 'name' => 'Store Email Name' |
| 139 | + ], |
| 140 | + (int) $customerData['storeId'] |
| 141 | + ) |
| 142 | + ->addTo($customerData['email']) |
| 143 | + ->getTransport(); |
| 144 | + |
148 | 145 | $headers = $transport->getMessage()->getHeaders();
|
149 |
| - $sendMessage = $transport->getMessage(); |
150 |
| - $this->assertNotNull($sendMessage); |
| 146 | + |
| 147 | + $this->assertNotNull($transport->getMessage()); |
151 | 148 | $this->assertStringContainsString($customerData['storeEmail'], $headers['From']);
|
152 | 149 | }
|
153 | 150 | }
|
0 commit comments