7
7
8
8
namespace Magento \Reports \Controller \Adminhtml \Report \Sales ;
9
9
10
+ use Magento \Catalog \Helper \Data ;
10
11
use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
12
+ use Magento \Checkout \Test \Fixture \PlaceOrder as PlaceOrderFixture ;
11
13
use Magento \Checkout \Test \Fixture \SetBillingAddress as SetBillingAddressFixture ;
12
14
use Magento \Checkout \Test \Fixture \SetDeliveryMethod as SetDeliveryMethodFixture ;
13
15
use Magento \Checkout \Test \Fixture \SetPaymentMethod as SetPaymentMethodFixture ;
14
16
use Magento \Checkout \Test \Fixture \SetShippingAddress as SetShippingAddressFixture ;
15
17
use Magento \Customer \Test \Fixture \Customer ;
16
18
use Magento \Directory \Test \Fixture \CurrencyRate ;
19
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
20
+ use Magento \Framework \App \ObjectManager ;
17
21
use Magento \Framework \Exception \CouldNotSaveException ;
18
22
use Magento \Framework \Exception \LocalizedException ;
19
23
use Magento \Framework \Exception \NoSuchEntityException ;
20
24
use Magento \Framework \Exception \StateException ;
21
25
use Magento \Framework \View \LayoutInterface ;
22
- use Magento \Quote \Api \CartManagementInterface ;
23
- use Magento \Quote \Api \CartRepositoryInterface ;
24
26
use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
25
27
use 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 ;
29
29
use Magento \Store \Test \Fixture \Group as StoreGroupFixture ;
30
30
use Magento \Store \Test \Fixture \Store as StoreFixture ;
31
31
use Magento \Store \Test \Fixture \Website as WebsiteFixture ;
36
36
use Magento \TestFramework \Fixture \DataFixtureStorage ;
37
37
use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
38
38
use Magento \TestFramework \Fixture \DbIsolation ;
39
- use Magento \TestFramework \Request ;
40
39
use Magento \TestFramework \TestCase \AbstractBackendController ;
41
40
42
41
class AdminOrderReports extends AbstractBackendController
@@ -46,27 +45,9 @@ class AdminOrderReports extends AbstractBackendController
46
45
*/
47
46
private $ fixtures ;
48
47
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
-
64
48
protected function setUp (): void
65
49
{
66
50
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);
70
51
$ this ->fixtures = $ this ->_objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
71
52
}
72
53
@@ -78,18 +59,16 @@ protected function setUp(): void
78
59
*/
79
60
#[
80
61
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 ' ),
85
64
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 ' ),
89
68
DataFixture(CurrencyRate::class, ['USD ' => ['EUR ' => '0.8 ' ]]),
90
69
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 ' ),
93
72
DataFixture(
94
73
AddProductToCartFixture::class,
95
74
['cart_id ' => '$cart.id$ ' , 'product_id ' => '$p1.id$ ' , 'qty ' => 1 ]
@@ -98,20 +77,14 @@ protected function setUp(): void
98
77
DataFixture(SetShippingAddressFixture::class, ['cart_id ' => '$cart.id$ ' ], as: 'shippingAddress ' ),
99
78
DataFixture(SetDeliveryMethodFixture::class, ['cart_id ' => '$cart.id$ ' ]),
100
79
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 ' ),
101
82
]
102
83
public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency ()
103
84
{
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);
110
86
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 ();
115
88
116
89
$ this ->_objectManager ->create ('Magento\Sales\Model\ResourceModel\Report\Order ' )->aggregate ();
117
90
@@ -130,6 +103,7 @@ public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency
130
103
$ filterData = base64_encode (http_build_query ($ requestArray ));
131
104
$ this ->dispatch ("backend/reports/report_sales/sales/website/ {$ websiteId }/filter/ {$ filterData }/ " );
132
105
$ this ->assertEquals (200 , $ this ->getResponse ()->getHttpResponseCode ());
106
+ $ body = $ this ->getResponse ()->getBody ();
133
107
$ layout = $ this ->_objectManager ->get (LayoutInterface::class);
134
108
$ salesReportGrid = $ layout ->getBlock ('adminhtml_sales_sales.grid ' );
135
109
$ blockHtml = $ salesReportGrid ->toHtml ();
0 commit comments