16
16
use Magento \Customer \Test \Fixture \Customer as CustomerFixture ;
17
17
use Magento \Framework \Exception \AuthenticationException ;
18
18
use Magento \Framework \Exception \LocalizedException ;
19
- use Magento \Framework \ObjectManagerInterface ;
20
19
use Magento \Integration \Api \CustomerTokenServiceInterface ;
21
20
use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
22
21
use Magento \Quote \Test \Fixture \CustomerCart as CustomerCartFixture ;
42
41
DataFixture(SetShippingAddressFixture::class, ['cart_id ' => '$quote.id$ ' ]),
43
42
DataFixture(SetDeliveryMethodFixture::class, ['cart_id ' => '$quote.id$ ' ]),
44
43
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 ' )
46
45
]
47
46
class OrderAvailableActionTest extends GraphQlAbstract
48
47
{
@@ -56,11 +55,6 @@ class OrderAvailableActionTest extends GraphQlAbstract
56
55
*/
57
56
private $ fixtures ;
58
57
59
- /**
60
- * @var ObjectManagerInterface
61
- */
62
- private $ objectManager ;
63
-
64
58
/**
65
59
* @var OrderRepositoryInterface
66
60
*/
@@ -72,23 +66,20 @@ class OrderAvailableActionTest extends GraphQlAbstract
72
66
*/
73
67
protected function setUp (): void
74
68
{
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);
81
72
}
82
73
83
74
#[
84
- Config('sales/cancellation/enabled ' , 1 )
75
+ Config('sales/cancellation/enabled ' , 1 ),
76
+ Config('sales/reorder/allow ' , 1 )
85
77
]
86
78
/**
87
79
* @dataProvider orderStatusProvider
88
80
*/
89
81
public function testCustomerOrderAvailableActions ($ status , $ expectedResult ): void
90
82
{
91
- $ customerEmail = $ this ->fixtures ->get ('customer ' )->getEmail ();
92
83
/**
93
84
* @var $order OrderInterface
94
85
*/
@@ -104,8 +95,9 @@ public function testCustomerOrderAvailableActions($status, $expectedResult): voi
104
95
$ this ->getCustomerOrdersQuery (),
105
96
[],
106
97
'' ,
107
- $ this ->getCustomerAuthHeaders ($ customerEmail )
98
+ $ this ->getCustomerAuthHeaders ($ this -> fixtures -> get ( ' customer ' )-> getEmail () )
108
99
);
100
+
109
101
$ result = $ response ['customerOrders ' ]['items ' ][0 ]['available_actions ' ];
110
102
111
103
foreach ($ expectedResult as $ action ) {
@@ -114,28 +106,59 @@ public function testCustomerOrderAvailableActions($status, $expectedResult): voi
114
106
}
115
107
116
108
#[
117
- Config('sales/cancellation/enabled ' , 0 )
109
+ Config('sales/cancellation/enabled ' , 0 ),
110
+ Config('sales/reorder/allow ' , 1 )
118
111
]
119
112
public function testCustomerOrderActionWithDisabledOrderCancellation (): void
120
113
{
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
+ }
122
139
140
+ #[
141
+ Config('sales/cancellation/enabled ' , 0 ),
142
+ Config('sales/reorder/allow ' , 0 )
143
+ ]
144
+ public function testCustomerOrderActionWithoutAnyActions (): void
145
+ {
123
146
$ response = $ this ->graphQlQuery (
124
147
$ this ->getCustomerOrdersQuery (),
125
148
[],
126
149
'' ,
127
- $ this ->getCustomerAuthHeaders ($ customerEmail )
150
+ $ this ->getCustomerAuthHeaders ($ this -> fixtures -> get ( ' customer ' )-> getEmail () )
128
151
);
129
- $ result = $ response ['customerOrders ' ]['items ' ][0 ]['available_actions ' ];
130
152
131
- $ this ->assertEquals ([' REORDER ' ], $ result );
153
+ $ this ->assertEquals ([], $ response [ ' customerOrders ' ][ ' items ' ][ 0 ][ ' available_actions ' ] );
132
154
}
133
155
134
156
/**
135
157
* @throws AuthenticationException
136
158
*/
137
159
#[
138
160
Config('sales/cancellation/enabled ' , 1 ),
161
+ Config('sales/reorder/allow ' , 1 ),
139
162
DataFixture(ProductFixture::class, as: 'product1 ' ),
140
163
DataFixture(ProductFixture::class, as: 'product2 ' ),
141
164
DataFixture(CustomerFixture::class, as: 'customer ' ),
0 commit comments