77
88namespace Magento \Reports \Controller \Adminhtml \Report \Sales ;
99
10+ use Magento \Catalog \Helper \Data ;
1011use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
12+ use Magento \Checkout \Test \Fixture \PlaceOrder as PlaceOrderFixture ;
1113use Magento \Checkout \Test \Fixture \SetBillingAddress as SetBillingAddressFixture ;
1214use Magento \Checkout \Test \Fixture \SetDeliveryMethod as SetDeliveryMethodFixture ;
1315use Magento \Checkout \Test \Fixture \SetPaymentMethod as SetPaymentMethodFixture ;
1416use Magento \Checkout \Test \Fixture \SetShippingAddress as SetShippingAddressFixture ;
1517use Magento \Customer \Test \Fixture \Customer ;
1618use Magento \Directory \Test \Fixture \CurrencyRate ;
19+ use Magento \Framework \App \Config \ScopeConfigInterface ;
20+ use Magento \Framework \App \ObjectManager ;
1721use Magento \Framework \Exception \CouldNotSaveException ;
1822use Magento \Framework \Exception \LocalizedException ;
1923use Magento \Framework \Exception \NoSuchEntityException ;
2024use Magento \Framework \Exception \StateException ;
2125use Magento \Framework \View \LayoutInterface ;
22- use Magento \Quote \Api \CartManagementInterface ;
23- use Magento \Quote \Api \CartRepositoryInterface ;
2426use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
2527use Magento \Quote \Test \Fixture \CustomerCart ;
26- use Magento \Sales \Api \InvoiceOrderInterface ;
27- use Magento \Store \Model \ScopeInterface ;
28- use Magento \Store \Model \Store ;
28+ use Magento \Sales \Test \Fixture \Invoice as InvoiceFixture ;
2929use Magento \Store \Test \Fixture \Group as StoreGroupFixture ;
3030use Magento \Store \Test \Fixture \Store as StoreFixture ;
3131use Magento \Store \Test \Fixture \Website as WebsiteFixture ;
3636use Magento \TestFramework \Fixture \DataFixtureStorage ;
3737use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
3838use Magento \TestFramework \Fixture \DbIsolation ;
39- use Magento \TestFramework \Request ;
4039use Magento \TestFramework \TestCase \AbstractBackendController ;
4140
4241class AdminOrderReports extends AbstractBackendController
@@ -46,27 +45,9 @@ class AdminOrderReports extends AbstractBackendController
4645 */
4746 private $ fixtures ;
4847
49- /**
50- * @var CartManagementInterface
51- */
52- private $ cartManagement ;
53-
54- /**
55- * @var InvoiceOrderInterface
56- */
57- private $ invoiceOrder ;
58-
59- /**
60- * @var CartRepositoryInterface
61- */
62- private $ quoteRepository ;
63-
6448 protected function setUp (): void
6549 {
6650 parent ::setUp ();
67- $ this ->cartManagement = $ this ->_objectManager ->get (CartManagementInterface::class);
68- $ this ->invoiceOrder = $ this ->_objectManager ->get (InvoiceOrderInterface::class);
69- $ this ->quoteRepository = $ this ->_objectManager ->get (CartRepositoryInterface::class);
7051 $ this ->fixtures = $ this ->_objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
7152 }
7253
@@ -78,18 +59,16 @@ protected function setUp(): void
7859 */
7960 #[
8061 DbIsolation(false ),
81- AppIsolation(true ),
82- AppArea('adminhtml ' ),
83- Config('catalog/price/scope ' , Store::PRICE_SCOPE_WEBSITE ),
84- DataFixture(WebsiteFixture::class, as: 'website2 ' ),
62+ Config(Data::XML_PATH_PRICE_SCOPE , Data::PRICE_SCOPE_WEBSITE ),
63+ DataFixture(WebsiteFixture::class, ['code ' => 'website2 ' ], as: 'website2 ' ),
8564 DataFixture(StoreGroupFixture::class, ['website_id ' => '$website2.id$ ' ], 'group2 ' ),
86- DataFixture(StoreFixture::class, ['website_id ' => '$website2 .id$ ' ], 'store2 ' ),
87- Config('currency/options/default ' , 'EUR ' , 'website ' , '$ website2.code$ ' ),
88- Config('currency/options/allow ' , 'EUR ' , 'website ' , '$ website2.code$ ' ),
65+ DataFixture(StoreFixture::class, ['store_group_id ' => '$group2 .id$ ' ], 'store2 ' ),
66+ Config('currency/options/default ' , 'EUR ' , 'website ' , 'website2 ' ),
67+ Config('currency/options/allow ' , 'EUR ' , 'website ' , 'website2 ' ),
8968 DataFixture(CurrencyRate::class, ['USD ' => ['EUR ' => '0.8 ' ]]),
9069 DataFixture(ProductFixture::class, ['website_ids ' => [1 , '$website2.id$ ' ]], as: 'p1 ' ),
91- DataFixture(Customer::class, ['website_id ' => '$website2.id$ ' ], as: 'customer ' ),
92- DataFixture(CustomerCart::class, ['customer_id ' => '$customer.id$ ' ], as: 'cart ' ),
70+ DataFixture(Customer::class, ['store_id ' => ' $store2.id$ ' , ' website_id ' => '$website2.id$ ' ], as: 'customer ' ),
71+ DataFixture(CustomerCart::class, ['customer_id ' => '$customer.id$ ' , ' currency ' => ' EUR ' ], as: 'cart ' , scope: ' store2 ' ),
9372 DataFixture(
9473 AddProductToCartFixture::class,
9574 ['cart_id ' => '$cart.id$ ' , 'product_id ' => '$p1.id$ ' , 'qty ' => 1 ]
@@ -98,20 +77,14 @@ protected function setUp(): void
9877 DataFixture(SetShippingAddressFixture::class, ['cart_id ' => '$cart.id$ ' ], as: 'shippingAddress ' ),
9978 DataFixture(SetDeliveryMethodFixture::class, ['cart_id ' => '$cart.id$ ' ]),
10079 DataFixture(SetPaymentMethodFixture::class, ['cart_id ' => '$cart.id$ ' ]),
80+ DataFixture(PlaceOrderFixture::class, ['cart_id ' => '$cart.id$ ' ], 'order ' ),
81+ DataFixture(InvoiceFixture::class, ['order_id ' => '$order.id$ ' ], 'invoice ' ),
10182 ]
10283 public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency ()
10384 {
104- $ cart = $ this ->fixtures ->get ('cart ' );
105- $ storeId = $ this ->fixtures ->get ('store2 ' )->getId ();
106- $ websiteId = (int ) $ this ->fixtures ->get ('website2 ' )->getId ();
107-
108- $ cart ->setStoreId ($ storeId );
109- $ this ->quoteRepository ->save ($ cart );
85+ $ scopeConfig = ObjectManager::getInstance ()->get (ScopeConfigInterface::class);
11086
111- $ orderId = $ this ->cartManagement ->placeOrder ($ cart ->getId ());
112- $ this ->assertNotEmpty ($ orderId );
113- $ invoiceId = $ this ->invoiceOrder ->execute ($ orderId );
114- $ this ->assertNotEmpty ($ invoiceId );
87+ $ websiteId = (int ) $ this ->fixtures ->get ('website2 ' )->getId ();
11588
11689 $ this ->_objectManager ->create ('Magento\Sales\Model\ResourceModel\Report\Order ' )->aggregate ();
11790
@@ -130,6 +103,7 @@ public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency
130103 $ filterData = base64_encode (http_build_query ($ requestArray ));
131104 $ this ->dispatch ("backend/reports/report_sales/sales/website/ {$ websiteId }/filter/ {$ filterData }/ " );
132105 $ this ->assertEquals (200 , $ this ->getResponse ()->getHttpResponseCode ());
106+ $ body = $ this ->getResponse ()->getBody ();
133107 $ layout = $ this ->_objectManager ->get (LayoutInterface::class);
134108 $ salesReportGrid = $ layout ->getBlock ('adminhtml_sales_sales.grid ' );
135109 $ blockHtml = $ salesReportGrid ->toHtml ();
0 commit comments