Skip to content

Commit 8458120

Browse files
akaashakaash
authored andcommitted
ACQE-5180 | Place an order with other than the default currency and validate the email confirmation has the same currency
1 parent 2abc466 commit 8458120

File tree

1 file changed

+65
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Bundle/Block/Sales/Order/Items

1 file changed

+65
-0
lines changed

dev/tests/integration/testsuite/Magento/Bundle/Block/Sales/Order/Items/RendererTest.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Bundle\Test\Fixture\OrderItem as OrderItemFixture;
1212
use Magento\Bundle\Test\Fixture\Product as BundleProductFixture;
1313
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
14+
use Magento\Customer\Api\AccountManagementInterface;
1415
use Magento\Customer\Model\Session;
1516
use Magento\Framework\ObjectManagerInterface;
1617
use Magento\Framework\View\LayoutInterface;
@@ -43,6 +44,11 @@ class RendererTest extends TestCase
4344
/** @var Renderer */
4445
private $block;
4546

47+
/**
48+
* @var AccountManagementInterface
49+
*/
50+
private $accountManagement;
51+
4652
/**
4753
* @defaultDoc
4854
*/
@@ -52,6 +58,7 @@ protected function setUp(): void
5258
$layout = $this->objectManager->get(LayoutInterface::class);
5359
$this->block = $layout->createBlock(Renderer::class);
5460
$this->fixtures = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage();
61+
$this->accountManagement = $this->objectManager->get(AccountManagementInterface::class);
5562
}
5663

5764
#[
@@ -99,4 +106,62 @@ public function testOrderEmailContent(): void
99106

100107
$this->assertStringContainsString("€99", $priceBlockHtml[0]);
101108
}
109+
110+
/**
111+
* @return void
112+
* @throws \Magento\Framework\Exception\LocalizedException
113+
*/
114+
#[
115+
DbIsolation(false),
116+
Config('default/currency/options/base', 'USD', 'store', 'default'),
117+
Config('currency/options/default', 'EUR', 'store', 'default'),
118+
Config('currency/options/allow', 'USD, EUR', 'store', 'default'),
119+
DataFixture(ProductFixture::class, ['price' => 10], 'p1'),
120+
DataFixture(ProductFixture::class, ['price' => 20], 'p2'),
121+
DataFixture(ProductFixture::class, ['price' => 30], 'p3'),
122+
DataFixture(BundleOptionFixture::class, ['product_links' => ['$p1$', '$p2$', '$p3$']], 'opt1'),
123+
DataFixture(BundleProductFixture::class, ['_options' => ['$opt1$']], 'bundle1'),
124+
DataFixture(OrderItemFixture::class, ['items' => [['sku' => '$bundle1.sku$']]], 'order'),
125+
DataFixture(Customer::class, ['email' => 'customer@example.com'], as: 'customer'),
126+
]
127+
public function testPlaceOrderWithOtherThanDefaultCurrencyValidateEmailHasSameCurrency(): void
128+
{
129+
// Load customer data
130+
$customer = $this->fixtures->get('customer');
131+
$customerEmail = $customer->getEmail();
132+
133+
// Login to customer
134+
$this->accountManagement->authenticate($customerEmail, 'password');
135+
136+
// Place the order
137+
$order = $this->objectManager->create(Order::class);
138+
$incrementId = $this->fixtures->get('order')->getIncrementId();
139+
$order->loadByIncrementId($incrementId);
140+
$storeManager = $this->objectManager->get(StoreManagerInterface::class);
141+
$currencyCode = $storeManager->getWebsite()->getDefaultStore()->getDefaultCurrency()->getCode();
142+
$storeId = $this->objectManager->get(StoreManagerInterface::class)->getStore()->getId();
143+
$order->setStoreId($storeId);
144+
$order->setOrderCurrencyCode($currencyCode);
145+
$order->save();
146+
147+
$priceBlockHtml = [];
148+
149+
$items = $order->getAllItems();
150+
foreach ($items as $item) {
151+
$item->setProductOptions([
152+
'bundle_options' => [
153+
[
154+
'value' => [
155+
['title' => '']
156+
],
157+
],
158+
],
159+
'bundle_selection_attributes' => '{"qty":5 ,"price":99}'
160+
]);
161+
$this->block->setItem($item);
162+
$priceBlockHtml[] = $this->block->getValueHtml($item);
163+
}
164+
165+
$this->assertStringContainsString("€99", $priceBlockHtml[0]);
166+
}
102167
}

0 commit comments

Comments
 (0)