1616use Magento \Customer \Test \Fixture \Customer as CustomerFixture ;
1717use Magento \Framework \Exception \AuthenticationException ;
1818use Magento \Framework \Exception \LocalizedException ;
19- use Magento \Framework \ObjectManagerInterface ;
2019use Magento \Integration \Api \CustomerTokenServiceInterface ;
2120use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
2221use Magento \Quote \Test \Fixture \CustomerCart as CustomerCartFixture ;
4241 DataFixture(SetShippingAddressFixture::class, ['cart_id ' => '$quote.id$ ' ]),
4342 DataFixture(SetDeliveryMethodFixture::class, ['cart_id ' => '$quote.id$ ' ]),
4443 DataFixture(SetPaymentMethodFixture::class, ['cart_id ' => '$quote.id$ ' ]),
45- DataFixture(PlaceOrderFixture::class, ['cart_id ' => '$quote.id$ ' ], 'order ' ),
44+ DataFixture(PlaceOrderFixture::class, ['cart_id ' => '$quote.id$ ' ], 'order ' )
4645]
4746class OrderAvailableActionTest extends GraphQlAbstract
4847{
@@ -56,11 +55,6 @@ class OrderAvailableActionTest extends GraphQlAbstract
5655 */
5756 private $ fixtures ;
5857
59- /**
60- * @var ObjectManagerInterface
61- */
62- private $ objectManager ;
63-
6458 /**
6559 * @var OrderRepositoryInterface
6660 */
@@ -72,23 +66,20 @@ class OrderAvailableActionTest extends GraphQlAbstract
7266 */
7367 protected function setUp (): void
7468 {
75- parent ::setUp ();
76- $ this ->objectManager = Bootstrap::getObjectManager ();
77-
78- $ this ->customerTokenService = $ this ->objectManager ->get (CustomerTokenServiceInterface::class);
79- $ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
80- $ this ->orderRepository = $ this ->objectManager ->get (OrderRepository::class);
69+ $ this ->customerTokenService = Bootstrap::getObjectManager ()->get (CustomerTokenServiceInterface::class);
70+ $ this ->fixtures = Bootstrap::getObjectManager ()->get (DataFixtureStorageManager::class)->getStorage ();
71+ $ this ->orderRepository = Bootstrap::getObjectManager ()->get (OrderRepository::class);
8172 }
8273
8374 #[
84- Config('sales/cancellation/enabled ' , 1 )
75+ Config('sales/cancellation/enabled ' , 1 ),
76+ Config('sales/reorder/allow ' , 1 )
8577 ]
8678 /**
8779 * @dataProvider orderStatusProvider
8880 */
8981 public function testCustomerOrderAvailableActions ($ status , $ expectedResult ): void
9082 {
91- $ customerEmail = $ this ->fixtures ->get ('customer ' )->getEmail ();
9283 /**
9384 * @var $order OrderInterface
9485 */
@@ -104,8 +95,9 @@ public function testCustomerOrderAvailableActions($status, $expectedResult): voi
10495 $ this ->getCustomerOrdersQuery (),
10596 [],
10697 '' ,
107- $ this ->getCustomerAuthHeaders ($ customerEmail )
98+ $ this ->getCustomerAuthHeaders ($ this -> fixtures -> get ( ' customer ' )-> getEmail () )
10899 );
100+
109101 $ result = $ response ['customerOrders ' ]['items ' ][0 ]['available_actions ' ];
110102
111103 foreach ($ expectedResult as $ action ) {
@@ -114,28 +106,59 @@ public function testCustomerOrderAvailableActions($status, $expectedResult): voi
114106 }
115107
116108 #[
117- Config('sales/cancellation/enabled ' , 0 )
109+ Config('sales/cancellation/enabled ' , 0 ),
110+ Config('sales/reorder/allow ' , 1 )
118111 ]
119112 public function testCustomerOrderActionWithDisabledOrderCancellation (): void
120113 {
121- $ customerEmail = $ this ->fixtures ->get ('customer ' )->getEmail ();
114+ $ response = $ this ->graphQlQuery (
115+ $ this ->getCustomerOrdersQuery (),
116+ [],
117+ '' ,
118+ $ this ->getCustomerAuthHeaders ($ this ->fixtures ->get ('customer ' )->getEmail ())
119+ );
120+
121+ $ this ->assertEquals (['REORDER ' ], $ response ['customerOrders ' ]['items ' ][0 ]['available_actions ' ]);
122+ }
123+
124+ #[
125+ Config('sales/cancellation/enabled ' , 1 ),
126+ Config('sales/reorder/allow ' , 0 )
127+ ]
128+ public function testCustomerOrderActionWithDisabledReOrder (): void
129+ {
130+ $ response = $ this ->graphQlQuery (
131+ $ this ->getCustomerOrdersQuery (),
132+ [],
133+ '' ,
134+ $ this ->getCustomerAuthHeaders ($ this ->fixtures ->get ('customer ' )->getEmail ())
135+ );
136+
137+ $ this ->assertEquals (['CANCEL ' ], $ response ['customerOrders ' ]['items ' ][0 ]['available_actions ' ]);
138+ }
122139
140+ #[
141+ Config('sales/cancellation/enabled ' , 0 ),
142+ Config('sales/reorder/allow ' , 0 )
143+ ]
144+ public function testCustomerOrderActionWithoutAnyActions (): void
145+ {
123146 $ response = $ this ->graphQlQuery (
124147 $ this ->getCustomerOrdersQuery (),
125148 [],
126149 '' ,
127- $ this ->getCustomerAuthHeaders ($ customerEmail )
150+ $ this ->getCustomerAuthHeaders ($ this -> fixtures -> get ( ' customer ' )-> getEmail () )
128151 );
129- $ result = $ response ['customerOrders ' ]['items ' ][0 ]['available_actions ' ];
130152
131- $ this ->assertEquals ([' REORDER ' ], $ result );
153+ $ this ->assertEquals ([], $ response [ ' customerOrders ' ][ ' items ' ][ 0 ][ ' available_actions ' ] );
132154 }
133155
134156 /**
135157 * @throws AuthenticationException
136158 */
137159 #[
138160 Config('sales/cancellation/enabled ' , 1 ),
161+ Config('sales/reorder/allow ' , 1 ),
139162 DataFixture(ProductFixture::class, as: 'product1 ' ),
140163 DataFixture(ProductFixture::class, as: 'product2 ' ),
141164 DataFixture(CustomerFixture::class, as: 'customer ' ),
0 commit comments