11
11
use Magento \Bundle \Test \Fixture \OrderItem as OrderItemFixture ;
12
12
use Magento \Bundle \Test \Fixture \Product as BundleProductFixture ;
13
13
use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
14
+ use Magento \Customer \Api \AccountManagementInterface ;
14
15
use Magento \Customer \Model \Session ;
15
16
use Magento \Framework \ObjectManagerInterface ;
16
17
use Magento \Framework \View \LayoutInterface ;
@@ -43,6 +44,11 @@ class RendererTest extends TestCase
43
44
/** @var Renderer */
44
45
private $ block ;
45
46
47
+ /**
48
+ * @var AccountManagementInterface
49
+ */
50
+ private $ accountManagement ;
51
+
46
52
/**
47
53
* @defaultDoc
48
54
*/
@@ -52,6 +58,7 @@ protected function setUp(): void
52
58
$ layout = $ this ->objectManager ->get (LayoutInterface::class);
53
59
$ this ->block = $ layout ->createBlock (Renderer::class);
54
60
$ this ->fixtures = Bootstrap::getObjectManager ()->get (DataFixtureStorageManager::class)->getStorage ();
61
+ $ this ->accountManagement = $ this ->objectManager ->get (AccountManagementInterface::class);
55
62
}
56
63
57
64
#[
@@ -99,4 +106,62 @@ public function testOrderEmailContent(): void
99
106
100
107
$ this ->assertStringContainsString ("€99 " , $ priceBlockHtml [0 ]);
101
108
}
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
+ }
102
167
}
0 commit comments