Skip to content

Commit 3ad41f3

Browse files
committed
MC-20636: MyAccount :: Order Details :: Order Details by Order Number
- CR fixes
1 parent d91ac89 commit 3ad41f3

File tree

2 files changed

+53
-68
lines changed

2 files changed

+53
-68
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/RetrieveOrdersByOrderNumberTest.php

Lines changed: 51 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Magento\Framework\Api\SearchCriteriaBuilder;
1515
use Magento\Framework\Exception\AuthenticationException;
1616
use Magento\GraphQl\GetCustomerAuthenticationHeader;
17-
use Magento\Integration\Api\CustomerTokenServiceInterface;
1817
use Magento\Sales\Api\OrderRepositoryInterface;
1918
use Magento\Sales\Model\Order;
2019
use Magento\Sales\Model\ResourceModel\Order\Collection;
@@ -26,20 +25,12 @@
2625
*/
2726
class RetrieveOrdersByOrderNumberTest extends GraphQlAbstract
2827
{
29-
/**
30-
* @var CustomerTokenServiceInterface
31-
*/
32-
private $customerTokenService;
33-
3428
/** @var OrderRepositoryInterface */
3529
private $orderRepository;
3630

3731
/** @var SearchCriteriaBuilder */
3832
private $searchCriteriaBuilder;
3933

40-
/** @var Order\Item */
41-
private $orderItem;
42-
4334
/** @var GetCustomerAuthenticationHeader */
4435
private $customerAuthenticationHeader;
4536

@@ -50,12 +41,10 @@ protected function setUp():void
5041
{
5142
parent::setUp();
5243
$objectManager = Bootstrap::getObjectManager();
53-
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
5444
$this->customerAuthenticationHeader = $objectManager->get(GetCustomerAuthenticationHeader::class);
5545
$this->orderRepository = $objectManager->get(OrderRepositoryInterface::class);
5646
$this->searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
5747
$this->productRepository = $objectManager->get(ProductRepositoryInterface::class);
58-
$this->orderItem = $objectManager->get(Order\Item::class);
5948
}
6049

6150
/**
@@ -112,17 +101,16 @@ public function testGetCustomerOrdersSimpleProductQuery()
112101
$this->assertArrayHasKey('items', $response['customer']['orders']);
113102
$this->assertNotEmpty($response['customer']['orders']['items']);
114103
$customerOrderItemsInResponse = $response['customer']['orders']['items'][0];
115-
$expectedCount = count($response['customer']['orders']['items']);
116104
$this->assertArrayHasKey('items', $customerOrderItemsInResponse);
117105
$this->assertNotEmpty($customerOrderItemsInResponse['items']);
118106

119107
$searchCriteria = $this->searchCriteriaBuilder->addFilter('increment_id', '100000002')
120108
->create();
121109
/** @var \Magento\Sales\Api\Data\OrderInterface[] $items */
122-
$items = $this->orderRepository->getList($searchCriteria)->getItems();
123-
foreach ($items as $item) {
124-
$orderId = $item->getEntityId();
125-
$orderNumber = $item->getIncrementId();
110+
$orders = $this->orderRepository->getList($searchCriteria)->getItems();
111+
foreach ($orders as $order) {
112+
$orderId = $order->getEntityId();
113+
$orderNumber = $order->getIncrementId();
126114
$this->assertEquals($orderId, $customerOrderItemsInResponse['id']);
127115
$this->assertEquals($orderNumber, $customerOrderItemsInResponse['number']);
128116
$this->assertEquals('Processing', $customerOrderItemsInResponse['status']);
@@ -155,16 +143,6 @@ public function testGetCustomerOrderWithBundleProduct()
155143
{
156144
$qty = 1;
157145
$bundleSku = 'bundle-product-two-dropdown-options';
158-
$simpleProductSku = 'simple2';
159-
/** @var Product $simple */
160-
$simple = $this->productRepository->get($simpleProductSku);
161-
$stockData =[
162-
StockItemInterface::QTY => 200,
163-
StockItemInterface::MANAGE_STOCK =>true,
164-
StockItemInterface::IS_IN_STOCK =>true
165-
];
166-
$simple->setQuantityAndStockStatus($stockData);
167-
$this->productRepository->save($simple);
168146
/** @var Product $bundleProduct */
169147
$bundleProduct = $this->productRepository->get($bundleSku);
170148
/** @var $typeInstance \Magento\Bundle\Model\Product\Type */
@@ -192,13 +170,40 @@ public function testGetCustomerOrderWithBundleProduct()
192170

193171
$customerOrderItems = $customerOrderResponse[0];
194172
$this->assertEquals("Pending", $customerOrderItems['status']);
195-
196173
$bundledItemInTheOrder = $customerOrderItems['items'][0];
197174
$this->assertEquals('bundle-product-two-dropdown-options-simple1-simple2', $bundledItemInTheOrder['product_sku']);
198-
$this->assertArrayHasKey('child_items', $bundledItemInTheOrder);
199-
$childItemInTheOrder = $bundledItemInTheOrder['child_items'][0];
200-
$this->assertNotEmpty($childItemInTheOrder);
201-
$this->assertEquals('simple1', $childItemInTheOrder['product_sku']);
175+
$priceOfBundledItemInOrder = $bundledItemInTheOrder['product_sale_price']['value'];
176+
$this->assertEquals(15, $priceOfBundledItemInOrder);
177+
$this->assertArrayHasKey('bundle_options', $bundledItemInTheOrder);
178+
$bundleOptionsFromResponse = $bundledItemInTheOrder['bundle_options'];
179+
$this->assertNotEmpty($bundleOptionsFromResponse);
180+
$this->assertEquals(2, count($bundleOptionsFromResponse));
181+
$expectedBundleOptions =
182+
[
183+
[ '__typename' => 'SelectedBundleOptionItems',
184+
'label' => 'Drop Down Option 1',
185+
'items' => [
186+
[
187+
'product_sku' => 'simple1',
188+
'product_name' => 'Simple Product1',
189+
'product_type'=> 'simple',
190+
'quantity_ordered'=> 1
191+
]
192+
]
193+
],
194+
[ '__typename' => 'SelectedBundleOptionItems',
195+
'label' => 'Drop Down Option 2',
196+
'items' => [
197+
[
198+
'product_sku' => 'simple2',
199+
'product_name' => 'Simple Product2',
200+
'product_type'=> 'simple',
201+
'quantity_ordered'=> 2
202+
]
203+
]
204+
],
205+
];
206+
$this->assertEquals($expectedBundleOptions, $bundleOptionsFromResponse);
202207
$this->deleteOrder();
203208
}
204209

@@ -481,12 +486,13 @@ public function testGetMatchingOrdersForLowerQueryLength()
481486
*/
482487
public function testGetMultipleCustomerOrdersQueryWithDefaultPagination()
483488
{
489+
$orderNumbers = ['100000007', '100000008'];
484490
$query =
485491
<<<QUERY
486492
{
487493
customer
488494
{
489-
orders(filter:{number:{in:["100000007","100000008"]}}){
495+
orders(filter:{number:{in:["{$orderNumbers[0]}","{$orderNumbers[1]}"]}}){
490496
total_count
491497
page_info{
492498
total_pages
@@ -545,15 +551,14 @@ public function testGetMultipleCustomerOrdersQueryWithDefaultPagination()
545551
$customerOrderItemsInResponse = $response['customer']['orders']['items'];
546552
$this->assertCount(2, $response['customer']['orders']['items']);
547553

548-
$orderNumbers = ['100000007', '100000008'];
549554
$searchCriteria = $this->searchCriteriaBuilder->addFilter('increment_id', $orderNumbers, 'in')
550555
->create();
551556
/** @var \Magento\Sales\Api\Data\OrderInterface[] $items */
552-
$items = $this->orderRepository->getList($searchCriteria)->getItems();
557+
$orders = $this->orderRepository->getList($searchCriteria)->getItems();
553558
$key = 0;
554-
foreach ($items as $item) {
555-
$orderId = $item->getEntityId();
556-
$orderNumber = $item->getIncrementId();
559+
foreach ($orders as $order) {
560+
$orderId = $order->getEntityId();
561+
$orderNumber = $order->getIncrementId();
557562
$this->assertEquals($orderId, $customerOrderItemsInResponse[$key]['id']);
558563
$this->assertEquals($orderNumber, $customerOrderItemsInResponse[$key]['number']);
559564
$this->assertEquals('Processing', $customerOrderItemsInResponse[$key]['status']);
@@ -1461,30 +1466,23 @@ private function getCustomerOrderQueryBundleProduct($orderNumber)
14611466
orders(filter:{number:{eq:"{$orderNumber}"}}) {
14621467
total_count
14631468
items {
1469+
id
14641470
number
14651471
order_date
14661472
status
14671473
items{
1474+
__typename
14681475
product_sku
1476+
product_name
1477+
product_url_key
1478+
product_sale_price{value}
14691479
quantity_ordered
14701480
__typename
14711481
... on BundleOrderItem{
1472-
child_items{
1473-
discounts{
1474-
amount{
1475-
value
1476-
currency
1477-
}
1478-
label
1479-
}
1482+
bundle_options{
14801483
__typename
1481-
product_sku
1482-
product_name
1483-
product_sku
1484-
product_url_key
1485-
product_sale_price{value}
1486-
product_sale_price{value currency}
1487-
quantity_ordered
1484+
label
1485+
items{ product_sku product_name product_type quantity_ordered}
14881486
}
14891487
}
14901488
}
@@ -1494,28 +1492,15 @@ private function getCustomerOrderQueryBundleProduct($orderNumber)
14941492
total_tax{value}
14951493
subtotal { value currency }
14961494
taxes {amount{value currency} title rate}
1497-
discounts{
1498-
amount{
1499-
value
1500-
currency
1501-
}
1502-
label
1503-
}
15041495
total_shipping{value}
15051496
shipping_handling
15061497
{
15071498
amount_including_tax{value}
15081499
amount_excluding_tax{value}
15091500
total_amount{value}
15101501
taxes {amount{value} title rate}
1511-
discounts{
1512-
amount{
1513-
value
1514-
currency
1515-
}
1516-
label
1517-
}
15181502
}
1503+
discounts {amount{value currency} label}
15191504
}
15201505
}
15211506
}

dev/tests/integration/testsuite/Magento/Bundle/_files/multiple_products.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
->setAttributeSetId($product->getDefaultAttributeSetId())
2929
->setName('Simple Product')
3030
->setSku('simple1')
31-
->setTaxClassId(0)
31+
->setTaxClassId(2)
3232
->setDescription('description')
3333
->setShortDescription('short description')
3434
->setOptionsContainer('container1')
@@ -57,7 +57,7 @@
5757
->setAttributeSetId($product2->getDefaultAttributeSetId())
5858
->setName('Simple Product2')
5959
->setSku('simple2')
60-
->setTaxClassId(0)
60+
->setTaxClassId(2)
6161
->setDescription('description')
6262
->setShortDescription('short description')
6363
->setOptionsContainer('container1')

0 commit comments

Comments
 (0)