24
24
use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
25
25
use Magento \Quote \Test \Fixture \CustomerCart ;
26
26
use Magento \Sales \Api \InvoiceOrderInterface ;
27
+ use Magento \Sales \Api \InvoiceRepositoryInterface ;
28
+ use Magento \Sales \Api \OrderManagementInterface ;
29
+ use Magento \Sales \Api \OrderRepositoryInterface ;
27
30
use Magento \Store \Model \ScopeInterface ;
28
31
use Magento \Store \Model \StoreManagerInterface ;
29
32
use Magento \Store \Test \Fixture \Group as StoreGroupFixture ;
30
33
use Magento \Store \Test \Fixture \Store as StoreFixture ;
31
34
use Magento \Store \Test \Fixture \Website as WebsiteFixture ;
35
+ use Magento \TestFramework \Fixture \AppArea ;
32
36
use Magento \TestFramework \Fixture \Config ;
33
37
use Magento \TestFramework \Fixture \DataFixture ;
34
38
use Magento \TestFramework \Fixture \DataFixtureStorage ;
@@ -61,13 +65,35 @@ class AdminOrderReportsTest extends AbstractBackendController
61
65
*/
62
66
private $ storeManager ;
63
67
68
+ /**
69
+ * @var OrderRepositoryInterface
70
+ */
71
+ private $ orderRepository ;
72
+
73
+ /**
74
+ * @var OrderManagementInterface
75
+ */
76
+ private $ orderManagement ;
77
+
78
+ /**
79
+ * @var InvoiceRepositoryInterface
80
+ */
81
+ private $ invoiceRepository ;
82
+
83
+ private int $ orderId ;
84
+
85
+ private int $ invoiceId ;
86
+
64
87
protected function setUp (): void
65
88
{
66
89
parent ::setUp ();
67
90
$ this ->cartManagement = $ this ->_objectManager ->get (CartManagementInterface::class);
68
91
$ this ->invoiceOrder = $ this ->_objectManager ->get (InvoiceOrderInterface::class);
69
92
$ this ->fixtures = $ this ->_objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
70
93
$ this ->storeManager = $ this ->_objectManager ->get (StoreManagerInterface::class);
94
+ $ this ->orderRepository = $ this ->_objectManager ->get (OrderRepositoryInterface::class);
95
+ $ this ->orderManagement = $ this ->_objectManager ->get (OrderManagementInterface::class);
96
+ $ this ->invoiceRepository = $ this ->_objectManager ->get (InvoiceRepositoryInterface::class);
71
97
}
72
98
73
99
/**
@@ -80,6 +106,7 @@ protected function setUp(): void
80
106
*/
81
107
#[
82
108
DbIsolation(false ),
109
+ AppArea('adminhtml ' ),
83
110
Config(Data::XML_PATH_PRICE_SCOPE , Data::PRICE_SCOPE_WEBSITE ),
84
111
DataFixture(WebsiteFixture::class, ['code ' => 'website2 ' ], as: 'website2 ' ),
85
112
DataFixture(StoreGroupFixture::class, ['website_id ' => '$website2.id$ ' ], 'group2 ' ),
@@ -107,10 +134,10 @@ public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency
107
134
$ store = $ this ->storeManager ->getStore ();
108
135
$ store ->setCurrentCurrencyCode ('EUR ' );
109
136
110
- $ orderId = $ this ->cartManagement ->placeOrder ($ cart ->getId ());
111
- $ this ->assertNotEmpty ($ orderId );
112
- $ invoiceId = $ this ->invoiceOrder ->execute ($ orderId );
113
- $ this ->assertNotEmpty ($ invoiceId );
137
+ $ this -> orderId = $ this ->cartManagement ->placeOrder ($ cart ->getId ());
138
+ $ this ->assertNotEmpty ($ this -> orderId );
139
+ $ this -> invoiceId = $ this ->invoiceOrder ->execute ($ this -> orderId );
140
+ $ this ->assertNotEmpty ($ this -> invoiceId );
114
141
115
142
$ this ->_objectManager ->create ('Magento\Sales\Model\ResourceModel\Report\Order ' )->aggregate ();
116
143
@@ -134,4 +161,26 @@ public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency
134
161
$ blockHtml = $ salesReportGrid ->toHtml ();
135
162
$ this ->assertStringContainsString ('€ ' , $ blockHtml );
136
163
}
164
+
165
+ /**
166
+ * @inheritdoc
167
+ */
168
+ protected function tearDown (): void
169
+ {
170
+ $ store = $ this ->storeManager ->getStore ();
171
+ $ store ->setCurrentCurrencyCode ('USD ' );
172
+
173
+ $ order = $ this ->orderRepository ->get ($ this ->orderId );
174
+ if ($ order ) {
175
+ $ this ->orderManagement ->cancel ($ this ->orderId );
176
+ $ this ->orderRepository ->delete ($ order );
177
+ }
178
+
179
+ $ invoice = $ this ->invoiceRepository ->get ($ this ->invoiceId );
180
+ $ this ->invoiceRepository ->delete ($ invoice );
181
+
182
+ $ this ->_objectManager ->create ('Magento\Sales\Model\ResourceModel\Report\Order ' )->aggregate ();
183
+
184
+ parent ::tearDown ();
185
+ }
137
186
}
0 commit comments