2626use Magento \Customer \Test \Fixture \Customer ;
2727use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
2828use Magento \Quote \Test \Fixture \CustomerCart ;
29+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
30+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
2931
3032/**
3133 * Class RetrieveOrdersTest
@@ -44,6 +46,11 @@ class RetrieveOrdersByOrderNumberTest extends GraphQlAbstract
4446 /** @var ProductRepositoryInterface */
4547 private $ productRepository ;
4648
49+ /**
50+ * @var DataFixtureStorage
51+ */
52+ private $ fixtures ;
53+
4754 protected function setUp ():void
4855 {
4956 parent ::setUp ();
@@ -52,6 +59,7 @@ protected function setUp():void
5259 $ this ->orderRepository = $ objectManager ->get (OrderRepositoryInterface::class);
5360 $ this ->searchCriteriaBuilder = $ objectManager ->get (SearchCriteriaBuilder::class);
5461 $ this ->productRepository = $ objectManager ->get (ProductRepositoryInterface::class);
62+ $ this ->fixtures = $ objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
5563 }
5664
5765 /**
@@ -427,7 +435,7 @@ public function testGetMatchingOrdersForLowerQueryLength()
427435 DataFixture(SetShippingAddress::class, ['cart_id ' => '$cart2.id$ ' ]),
428436 DataFixture(SetDeliveryMethod::class, ['cart_id ' => '$cart2.id$ ' ]),
429437 DataFixture(SetPaymentMethod::class, ['cart_id ' => '$cart2.id$ ' ]),
430- DataFixture(PlaceOrder::class, ['cart_id ' => '$cart2.id$ ' ]),
438+ DataFixture(PlaceOrder::class, ['cart_id ' => '$cart2.id$ ' ], ' 100000002 ' ),
431439
432440 DataFixture(CustomerCart::class, ['customer_id ' => '$customer.id$ ' ], 'cart3 ' ),
433441 DataFixture(ProductFixture::class, ['sku ' => '100000003 ' , 'price ' => 10 ], 'p3 ' ),
@@ -436,7 +444,7 @@ public function testGetMatchingOrdersForLowerQueryLength()
436444 DataFixture(SetShippingAddress::class, ['cart_id ' => '$cart3.id$ ' ]),
437445 DataFixture(SetDeliveryMethod::class, ['cart_id ' => '$cart3.id$ ' ]),
438446 DataFixture(SetPaymentMethod::class, ['cart_id ' => '$cart3.id$ ' ]),
439- DataFixture(PlaceOrder::class, ['cart_id ' => '$cart3.id$ ' ]),
447+ DataFixture(PlaceOrder::class, ['cart_id ' => '$cart3.id$ ' ], ' 100000003 ' ),
440448
441449 DataFixture(CustomerCart::class, ['customer_id ' => '$customer.id$ ' ], 'cart4 ' ),
442450 DataFixture(ProductFixture::class, ['sku ' => '100000004 ' , 'price ' => 10 ], 'p4 ' ),
@@ -445,7 +453,7 @@ public function testGetMatchingOrdersForLowerQueryLength()
445453 DataFixture(SetShippingAddress::class, ['cart_id ' => '$cart4.id$ ' ]),
446454 DataFixture(SetDeliveryMethod::class, ['cart_id ' => '$cart4.id$ ' ]),
447455 DataFixture(SetPaymentMethod::class, ['cart_id ' => '$cart4.id$ ' ]),
448- DataFixture(PlaceOrder::class, ['cart_id ' => '$cart4.id$ ' ]),
456+ DataFixture(PlaceOrder::class, ['cart_id ' => '$cart4.id$ ' ], ' 100000004 ' ),
449457
450458 DataFixture(CustomerCart::class, ['customer_id ' => '$customer.id$ ' ], 'cart5 ' ),
451459 DataFixture(ProductFixture::class, ['sku ' => '100000005 ' , 'price ' => 10 ], 'p5 ' ),
@@ -454,7 +462,7 @@ public function testGetMatchingOrdersForLowerQueryLength()
454462 DataFixture(SetShippingAddress::class, ['cart_id ' => '$cart5.id$ ' ]),
455463 DataFixture(SetDeliveryMethod::class, ['cart_id ' => '$cart5.id$ ' ]),
456464 DataFixture(SetPaymentMethod::class, ['cart_id ' => '$cart5.id$ ' ]),
457- DataFixture(PlaceOrder::class, ['cart_id ' => '$cart5.id$ ' ]),
465+ DataFixture(PlaceOrder::class, ['cart_id ' => '$cart5.id$ ' ], ' 100000005 ' ),
458466
459467 DataFixture(CustomerCart::class, ['customer_id ' => '$customer.id$ ' ], 'cart6 ' ),
460468 DataFixture(ProductFixture::class, ['sku ' => '100000006 ' , 'price ' => 10 ], 'p6 ' ),
@@ -463,7 +471,7 @@ public function testGetMatchingOrdersForLowerQueryLength()
463471 DataFixture(SetShippingAddress::class, ['cart_id ' => '$cart6.id$ ' ]),
464472 DataFixture(SetDeliveryMethod::class, ['cart_id ' => '$cart6.id$ ' ]),
465473 DataFixture(SetPaymentMethod::class, ['cart_id ' => '$cart6.id$ ' ]),
466- DataFixture(PlaceOrder::class, ['cart_id ' => '$cart6.id$ ' ]),
474+ DataFixture(PlaceOrder::class, ['cart_id ' => '$cart6.id$ ' ], ' 100000006 ' ),
467475
468476 DataFixture(CustomerCart::class, ['customer_id ' => '$customer.id$ ' ], 'cart7 ' ),
469477 DataFixture(ProductFixture::class, ['sku ' => '100000007 ' , 'price ' => 10 ], 'p7 ' ),
@@ -472,7 +480,7 @@ public function testGetMatchingOrdersForLowerQueryLength()
472480 DataFixture(SetShippingAddress::class, ['cart_id ' => '$cart7.id$ ' ]),
473481 DataFixture(SetDeliveryMethod::class, ['cart_id ' => '$cart7.id$ ' ]),
474482 DataFixture(SetPaymentMethod::class, ['cart_id ' => '$cart7.id$ ' ]),
475- DataFixture(PlaceOrder::class, ['cart_id ' => '$cart7.id$ ' ]),
483+ DataFixture(PlaceOrder::class, ['cart_id ' => '$cart7.id$ ' ], ' 100000007 ' ),
476484
477485 DataFixture(CustomerCart::class, ['customer_id ' => '$customer.id$ ' ], 'cart8 ' ),
478486 DataFixture(ProductFixture::class, ['sku ' => '100000008 ' , 'price ' => 10 ], 'p8 ' ),
@@ -481,7 +489,7 @@ public function testGetMatchingOrdersForLowerQueryLength()
481489 DataFixture(SetShippingAddress::class, ['cart_id ' => '$cart8.id$ ' ]),
482490 DataFixture(SetDeliveryMethod::class, ['cart_id ' => '$cart8.id$ ' ]),
483491 DataFixture(SetPaymentMethod::class, ['cart_id ' => '$cart8.id$ ' ]),
484- DataFixture(PlaceOrder::class, ['cart_id ' => '$cart8.id$ ' ]),
492+ DataFixture(PlaceOrder::class, ['cart_id ' => '$cart8.id$ ' ], ' 100000008 ' ),
485493
486494 ]
487495 public function testGetCustomerDescendingSortedOrders ()
@@ -517,14 +525,31 @@ public function testGetCustomerDescendingSortedOrders()
517525 $ this ->assertArrayHasKey ('orders ' , $ response ['customer ' ]);
518526 $ this ->assertArrayHasKey ('items ' , $ response ['customer ' ]['orders ' ]);
519527 $ customerOrderItemsInResponse = $ response ['customer ' ]['orders ' ]['items ' ];
520- $ expectedOrderNumbers = ['100000008 ' , '100000007 ' ,'100000006 ' , '100000005 ' , '100000004 ' ,'100000002 ' ];
528+
529+ $ o2 = '100000002 ' ;
530+ $ o3 = '100000003 ' ;
531+ $ o4 = '100000004 ' ;
532+ $ o5 = '100000005 ' ;
533+ $ o6 = '100000006 ' ;
534+ $ o7 = '100000007 ' ;
535+ $ o8 = '100000008 ' ;
536+
537+ $ order2 = $ this ->fixtures ->get ($ o2 )->getIncrementId ();
538+ $ order3 = $ this ->fixtures ->get ($ o3 )->getIncrementId ();
539+ $ order4 = $ this ->fixtures ->get ($ o4 )->getIncrementId ();
540+ $ order5 = $ this ->fixtures ->get ($ o5 )->getIncrementId ();
541+ $ order6 = $ this ->fixtures ->get ($ o6 )->getIncrementId ();
542+ $ order7 = $ this ->fixtures ->get ($ o7 )->getIncrementId ();
543+ $ order8 = $ this ->fixtures ->get ($ o8 )->getIncrementId ();
544+
545+ $ expectedOrderNumbers = [$ order8 , $ order7 , $ order6 , $ order5 , $ order4 , $ order3 , $ order2 ];
521546
522547 foreach ($ expectedOrderNumbers as $ key => $ data ) {
523548 $ orderItemInResponse = $ customerOrderItemsInResponse [$ key ];
524549 $ this ->assertEquals (
525- $ orderItemInResponse ['number ' ],
526550 $ data ,
527- "The order number is different than the expected for order - {$ orderItemInResponse ['number ' ]}"
551+ $ orderItemInResponse ['number ' ],
552+ "The order number is different than the expected for order - {$ data }"
528553 );
529554 }
530555 }
0 commit comments