|
7 | 7 |
|
8 | 8 | namespace Magento\ProductAlert\Model\Mailing;
|
9 | 9 |
|
| 10 | +use Magento\Catalog\Api\ProductRepositoryInterface; |
| 11 | +use Magento\Catalog\Model\ProductFactory; |
| 12 | +use Magento\Catalog\Model\ResourceModel\Product as ProductResourceModel; |
10 | 13 | use Magento\Customer\Api\AccountManagementInterface;
|
11 | 14 | use Magento\Customer\Model\Session;
|
12 | 15 | use Magento\Framework\Locale\Resolver;
|
|
18 | 21 | use Magento\Framework\Translate;
|
19 | 22 | use Magento\Framework\View\Design\ThemeInterface;
|
20 | 23 | use Magento\Framework\View\DesignInterface;
|
| 24 | +use Magento\Store\Model\Store; |
21 | 25 | use Magento\Store\Model\StoreRepository;
|
22 | 26 | use Magento\TestFramework\Helper\Bootstrap;
|
23 | 27 | use Magento\TestFramework\Mail\Template\TransportBuilderMock;
|
@@ -136,6 +140,37 @@ public function testProcessPortuguese()
|
136 | 140 | $this->assertStringContainsString(substr($expectedText, 0, 50), $messageContent);
|
137 | 141 | }
|
138 | 142 |
|
| 143 | + /** |
| 144 | + * @magentoConfigFixture current_store catalog/productalert/allow_price 1 |
| 145 | + * @magentoDataFixture Magento/ProductAlert/_files/product_alert.php |
| 146 | + */ |
| 147 | + public function testCustomerShouldGetEmailForEveryProductPriceDrop(): void |
| 148 | + { |
| 149 | + $this->processAlerts(); |
| 150 | + |
| 151 | + $this->assertStringContainsString( |
| 152 | + '$10.00', |
| 153 | + $this->transportBuilder->getSentMessage()->getBody()->getParts()[0]->getRawContent() |
| 154 | + ); |
| 155 | + |
| 156 | + // Intentional: update product without using ProductRepository |
| 157 | + // to prevent changes from being cached on application level |
| 158 | + $product = $this->objectManager->get(ProductFactory::class)->create(); |
| 159 | + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); |
| 160 | + $productResource = $this->objectManager->get(ProductResourceModel::class); |
| 161 | + $product->setStoreId(Store::DEFAULT_STORE_ID); |
| 162 | + $productResource->load($product, $productRepository->get('simple')->getId()); |
| 163 | + $product->setPrice(5); |
| 164 | + $productResource->save($product); |
| 165 | + |
| 166 | + $this->processAlerts(); |
| 167 | + |
| 168 | + $this->assertStringContainsString( |
| 169 | + '$5.00', |
| 170 | + $this->transportBuilder->getSentMessage()->getBody()->getParts()[0]->getRawContent() |
| 171 | + ); |
| 172 | + } |
| 173 | + |
139 | 174 | /**
|
140 | 175 | * Process price alerts
|
141 | 176 | */
|
|
0 commit comments