Skip to content

Commit a5f2a64

Browse files
committed
ACP2E-3276: Order reports showing the wrong currency symbol
1 parent dab892b commit a5f2a64

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

dev/tests/integration/testsuite/Magento/Reports/Controller/Adminhtml/Report/Sales/AdminOrderReportsTest.php

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424
use Magento\Quote\Test\Fixture\AddProductToCart as AddProductToCartFixture;
2525
use Magento\Quote\Test\Fixture\CustomerCart;
2626
use Magento\Sales\Api\InvoiceOrderInterface;
27+
use Magento\Sales\Api\InvoiceRepositoryInterface;
28+
use Magento\Sales\Api\OrderManagementInterface;
29+
use Magento\Sales\Api\OrderRepositoryInterface;
2730
use Magento\Store\Model\ScopeInterface;
2831
use Magento\Store\Model\StoreManagerInterface;
2932
use Magento\Store\Test\Fixture\Group as StoreGroupFixture;
3033
use Magento\Store\Test\Fixture\Store as StoreFixture;
3134
use Magento\Store\Test\Fixture\Website as WebsiteFixture;
35+
use Magento\TestFramework\Fixture\AppArea;
3236
use Magento\TestFramework\Fixture\Config;
3337
use Magento\TestFramework\Fixture\DataFixture;
3438
use Magento\TestFramework\Fixture\DataFixtureStorage;
@@ -61,13 +65,35 @@ class AdminOrderReportsTest extends AbstractBackendController
6165
*/
6266
private $storeManager;
6367

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+
6487
protected function setUp(): void
6588
{
6689
parent::setUp();
6790
$this->cartManagement = $this->_objectManager->get(CartManagementInterface::class);
6891
$this->invoiceOrder = $this->_objectManager->get(InvoiceOrderInterface::class);
6992
$this->fixtures = $this->_objectManager->get(DataFixtureStorageManager::class)->getStorage();
7093
$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);
7197
}
7298

7399
/**
@@ -80,6 +106,7 @@ protected function setUp(): void
80106
*/
81107
#[
82108
DbIsolation(false),
109+
AppArea('adminhtml'),
83110
Config(Data::XML_PATH_PRICE_SCOPE, Data::PRICE_SCOPE_WEBSITE),
84111
DataFixture(WebsiteFixture::class, ['code' => 'website2'], as: 'website2'),
85112
DataFixture(StoreGroupFixture::class, ['website_id' => '$website2.id$'], 'group2'),
@@ -107,10 +134,10 @@ public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency
107134
$store = $this->storeManager->getStore();
108135
$store->setCurrentCurrencyCode('EUR');
109136

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);
114141

115142
$this->_objectManager->create('Magento\Sales\Model\ResourceModel\Report\Order')->aggregate();
116143

@@ -134,4 +161,26 @@ public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency
134161
$blockHtml = $salesReportGrid->toHtml();
135162
$this->assertStringContainsString('', $blockHtml);
136163
}
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+
}
137186
}

0 commit comments

Comments
 (0)