Skip to content

Commit be24253

Browse files
committed
MC-20636: MyAccount :: Order Details :: Order Details by Order Number
- moved the fixture to Graphql specific folder
1 parent 0ef8a7a commit be24253

File tree

4 files changed

+174
-41
lines changed

4 files changed

+174
-41
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function setUp():void
4747

4848
/**
4949
* @magentoApiDataFixture Magento/Customer/_files/customer.php
50-
* @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php
50+
* @magentoApiDataFixture Magento/GraphQl/Sales/_files/orders_with_customer.php
5151
*/
5252
public function testGetCustomerOrdersSimpleProductQuery()
5353
{
@@ -359,7 +359,7 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts(array $custome
359359

360360
/**
361361
* @magentoApiDataFixture Magento/Customer/_files/customer.php
362-
* @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php
362+
* @magentoApiDataFixture Magento/GraphQl/Sales/_files/orders_with_customer.php
363363
*/
364364
public function testGetMatchingCustomerOrders()
365365
{
@@ -411,7 +411,7 @@ public function testGetMatchingCustomerOrders()
411411

412412
/**
413413
* @magentoApiDataFixture Magento/Customer/_files/customer.php
414-
* @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php
414+
* @magentoApiDataFixture Magento/GraphQl/Sales/_files/orders_with_customer.php
415415
*/
416416
public function testGetMatchingOrdersForLowerQueryLength()
417417
{
@@ -456,12 +456,12 @@ public function testGetMatchingOrdersForLowerQueryLength()
456456
$this->assertArrayHasKey('orders', $response['customer']);
457457
$this->assertArrayHasKey('items', $response['customer']['orders']);
458458
$this->assertArrayHasKey('total_count', $response['customer']['orders']);
459-
$this->assertEquals(2, $response['customer']['orders']['total_count']);
459+
$this->assertEquals(6, $response['customer']['orders']['total_count']);
460460
}
461461

462462
/**
463463
* @magentoApiDataFixture Magento/Customer/_files/customer.php
464-
* @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php
464+
* @magentoApiDataFixture Magento/GraphQl/Sales/_files/orders_with_customer.php
465465
*/
466466
public function testGetMultipleCustomerOrdersQueryWithDefaultPagination()
467467
{
@@ -648,7 +648,7 @@ public function testGetCustomerOrdersWithWrongCustomer()
648648
* @throws AuthenticationException
649649
* @dataProvider dataProviderIncorrectOrder
650650
* @magentoApiDataFixture Magento/Customer/_files/customer.php
651-
* @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php
651+
* @magentoApiDataFixture Magento/GraphQl/Sales/_files/orders_with_customer.php
652652
*/
653653
public function testGetCustomerNonExistingOrderQuery(string $orderNumber)
654654
{
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Sales\Api\Data\OrderInterfaceFactory;
10+
use Magento\Sales\Model\Order;
11+
use Magento\Sales\Api\OrderRepositoryInterface;
12+
use Magento\Sales\Model\Order\Address as OrderAddress;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
15+
16+
Resolver::getInstance()->requireDataFixture('Magento/Sales/_files/order.php');
17+
$objectManager = Bootstrap::getObjectManager();
18+
/** @var ProductRepositoryInterface $productRepository */
19+
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
20+
$product = $productRepository->get('simple');
21+
/** @var Order $order */
22+
$order = $objectManager->get(OrderInterfaceFactory::class)->create()->loadByIncrementId('100000001');
23+
$payment = $order->getPayment();
24+
$orderItems = $order->getItems();
25+
$orderItem = reset($orderItems);
26+
$addressData = include __DIR__ . '/address_data.php';
27+
$orders = [
28+
[
29+
'increment_id' => '100000002',
30+
'state' => \Magento\Sales\Model\Order::STATE_NEW,
31+
'status' => 'processing',
32+
'order_currency_code' =>'USD',
33+
'grand_total' => 120.00,
34+
'subtotal' => 120.00,
35+
'base_grand_total' => 120.00,
36+
'store_id' => 1,
37+
'website_id' => 1,
38+
],
39+
[
40+
'increment_id' => '100000003',
41+
'state' => \Magento\Sales\Model\Order::STATE_PROCESSING,
42+
'status' => 'processing',
43+
'grand_total' => 130.00,
44+
'base_grand_total' => 130.00,
45+
'subtotal' => 130.00,
46+
'total_paid' => 130.00,
47+
'store_id' => 0,
48+
'website_id' => 0,
49+
],
50+
[
51+
'increment_id' => '100000004',
52+
'state' => \Magento\Sales\Model\Order::STATE_PROCESSING,
53+
'status' => 'closed',
54+
'grand_total' => 140.00,
55+
'base_grand_total' => 140.00,
56+
'subtotal' => 140.00,
57+
'store_id' => 1,
58+
'website_id' => 1,
59+
],
60+
[
61+
'increment_id' => '100000005',
62+
'state' => \Magento\Sales\Model\Order::STATE_COMPLETE,
63+
'status' => 'complete',
64+
'grand_total' => 150.00,
65+
'base_grand_total' => 150.00,
66+
'subtotal' => 150.00,
67+
'total_paid' => 150.00,
68+
'store_id' => 1,
69+
'website_id' => 1,
70+
],
71+
[
72+
'increment_id' => '100000006',
73+
'state' => \Magento\Sales\Model\Order::STATE_PROCESSING,
74+
'status' => 'Processing',
75+
'grand_total' => 160.00,
76+
'base_grand_total' => 160.00,
77+
'subtotal' => 160.00,
78+
'total_paid' => 160.00,
79+
'store_id' => 1,
80+
'website_id' => 1,
81+
],
82+
[
83+
'increment_id' => '100000007',
84+
'state' => \Magento\Sales\Model\Order::STATE_PROCESSING,
85+
'status' => 'Processing',
86+
'order_currency_code' =>'USD',
87+
'grand_total' => 180.00,
88+
'base_grand_total' => 180.00,
89+
'subtotal' => 170.00,
90+
'tax_amount' => 5.00,
91+
'shipping_amount'=> 5.00,
92+
'base_shipping_amount'=> 4.00,
93+
'store_id' => 1,
94+
'website_id' => 1,
95+
],
96+
[
97+
'increment_id' => '100000008',
98+
'state' => \Magento\Sales\Model\Order::STATE_PROCESSING,
99+
'status' => 'Processing',
100+
'order_currency_code' =>'USD',
101+
'grand_total' => 190.00,
102+
'base_grand_total' => 190.00,
103+
'subtotal' => 180.00,
104+
'tax_amount' => 5.00,
105+
'shipping_amount'=> 5.00,
106+
'base_shipping_amount'=> 4.00,
107+
'store_id' => 1,
108+
'website_id' => 1,
109+
]
110+
];
111+
112+
/** @var OrderRepositoryInterface $orderRepository */
113+
$orderRepository = $objectManager->create(OrderRepositoryInterface::class);
114+
/** @var array $orderData */
115+
foreach ($orders as $orderData) {
116+
$newPayment = clone $payment;
117+
$newPayment->setId(null);
118+
/** @var $order \Magento\Sales\Model\Order */
119+
$order = Bootstrap::getObjectManager()->create(
120+
\Magento\Sales\Model\Order::class
121+
);
122+
123+
// Reset addresses
124+
/** @var Order\Address $billingAddress */
125+
$billingAddress = $objectManager->create(OrderAddress::class, ['data' => $addressData]);
126+
$billingAddress->setAddressType('billing');
127+
128+
$shippingAddress = clone $billingAddress;
129+
$shippingAddress->setId(null)->setAddressType('shipping');
130+
131+
/** @var Order\Item $orderItem */
132+
$orderItem = $objectManager->create(Order\Item::class);
133+
$orderItem->setProductId($product->getId())
134+
->setQtyOrdered(2)
135+
->setBasePrice($product->getPrice())
136+
->setPrice($product->getPrice())
137+
->setRowTotal($product->getPrice())
138+
->setProductType('simple')
139+
->setName($product->getName())
140+
->setSku($product->getSku());
141+
142+
143+
$order
144+
->setData($orderData)
145+
->addItem($orderItem)
146+
->setCustomerIsGuest(false)
147+
->setCustomerId(1)
148+
->setCustomerEmail('[email protected]')
149+
->setBillingAddress($billingAddress)
150+
->setShippingAddress($shippingAddress)
151+
->setPayment($newPayment);
152+
153+
$orderRepository->save($order);
154+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
9+
10+
Resolver::getInstance()->requireDataFixture('Magento/Sales/_files/default_rollback.php');

dev/tests/integration/testsuite/Magento/Sales/_files/orders_with_customer.php

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
'increment_id' => '100000002',
3030
'state' => \Magento\Sales\Model\Order::STATE_NEW,
3131
'status' => 'processing',
32-
'order_currency_code' =>'USD',
3332
'grand_total' => 120.00,
3433
'subtotal' => 120.00,
3534
'base_grand_total' => 120.00,
@@ -70,43 +69,15 @@
7069
],
7170
[
7271
'increment_id' => '100000006',
73-
'state' => \Magento\Sales\Model\Order::STATE_PROCESSING,
74-
'status' => 'Processing',
72+
'state' => \Magento\Sales\Model\Order::STATE_COMPLETE,
73+
'status' => 'complete',
7574
'grand_total' => 160.00,
7675
'base_grand_total' => 160.00,
7776
'subtotal' => 160.00,
7877
'total_paid' => 160.00,
7978
'store_id' => 1,
8079
'website_id' => 1,
8180
],
82-
[
83-
'increment_id' => '100000007',
84-
'state' => \Magento\Sales\Model\Order::STATE_PROCESSING,
85-
'status' => 'Processing',
86-
'order_currency_code' =>'USD',
87-
'grand_total' => 180.00,
88-
'base_grand_total' => 180.00,
89-
'subtotal' => 170.00,
90-
'tax_amount' => 5.00,
91-
'shipping_amount'=> 5.00,
92-
'base_shipping_amount'=> 4.00,
93-
'store_id' => 1,
94-
'website_id' => 1,
95-
],
96-
[
97-
'increment_id' => '100000008',
98-
'state' => \Magento\Sales\Model\Order::STATE_PROCESSING,
99-
'status' => 'Processing',
100-
'order_currency_code' =>'USD',
101-
'grand_total' => 190.00,
102-
'base_grand_total' => 190.00,
103-
'subtotal' => 180.00,
104-
'tax_amount' => 5.00,
105-
'shipping_amount'=> 5.00,
106-
'base_shipping_amount'=> 4.00,
107-
'store_id' => 1,
108-
'website_id' => 1,
109-
]
11081
];
11182

11283
/** @var OrderRepositoryInterface $orderRepository */
@@ -135,10 +106,7 @@
135106
->setBasePrice($product->getPrice())
136107
->setPrice($product->getPrice())
137108
->setRowTotal($product->getPrice())
138-
->setProductType('simple')
139-
->setName($product->getName())
140-
->setSku($product->getSku());
141-
109+
->setProductType('simple');
142110

143111
$order
144112
->setData($orderData)
@@ -152,3 +120,4 @@
152120

153121
$orderRepository->save($order);
154122
}
123+

0 commit comments

Comments
 (0)