1
1
<?php
2
2
3
- use Magento \Sales \Model \Order ;
3
+ namespace Magento \SalesRule \Model \Observer ;
4
4
5
+ use Magento \Sales \Model \Order ;
5
6
use Magento \Customer \Model \GroupManagement ;
6
7
use Magento \SalesRule \Api \CouponRepositoryInterface ;
7
8
use Magento \SalesRule \Model \Coupon ;
13
14
/**
14
15
* Class AssignCouponDataAfterOrderCustomerAssignTest
15
16
*
17
+ * @magentoAppIsolation enabled
18
+ *
16
19
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17
20
*/
18
21
class AssignCouponDataAfterOrderCustomerAssignTest extends \PHPUnit \Framework \TestCase
@@ -80,12 +83,12 @@ public function __construct($name = null, array $data = [], $dataName = '')
80
83
parent ::__construct ($ name , $ data , $ dataName );
81
84
$ this ->objectManager = Bootstrap::getObjectManager ();
82
85
$ this ->eventManager = $ this ->createMock (\Magento \Framework \Event \ManagerInterface::class);
83
- $ this ->orderRepository = $ this ->objectManager ->get (Magento \Sales \Model \OrderRepository::class);
86
+ $ this ->orderRepository = $ this ->objectManager ->get (\ Magento \Sales \Model \OrderRepository::class);
84
87
$ this ->delegateCustomerService = $ this ->objectManager ->get (Order \OrderCustomerDelegate::class);
85
88
$ this ->customerRepository = $ this ->objectManager ->get (\Magento \Customer \Api \CustomerRepositoryInterface::class);
86
- $ this ->ruleCustomerFactory = $ this ->objectManager ->get (Magento \SalesRule \Model \Rule \CustomerFactory::class); ;
89
+ $ this ->ruleCustomerFactory = $ this ->objectManager ->get (\ Magento \SalesRule \Model \Rule \CustomerFactory::class);
87
90
$ this ->assignCouponToCustomerObserver = $ this ->objectManager ->get (
88
- Magento \SalesRule \Observer \AssignCouponDataAfterOrderCustomerAssignObserver::class
91
+ \ Magento \SalesRule \Observer \AssignCouponDataAfterOrderCustomerAssignObserver::class
89
92
);
90
93
}
91
94
@@ -116,7 +119,6 @@ protected function tearDown()
116
119
}
117
120
118
121
/**
119
- * @magentoAppIsolation enabled
120
122
* @magentoDataFixture Magento/Sales/_files/order.php
121
123
*/
122
124
public function testCouponDataHasBeenAssignedTest ()
@@ -137,15 +139,14 @@ public function testCouponDataHasBeenAssignedTest()
137
139
}
138
140
139
141
/**
140
- * @magentoAppIsolation enabled
141
142
* @magentoDataFixture Magento/Sales/_files/order.php
142
143
*/
143
144
public function testOrderCancelingDecreasesCouponUsages ()
144
145
{
145
146
$ this ->processOrder ($ this ->order );
146
147
147
148
// Should not throw exception as bux is fixed now
148
- $ this ->cancelOrder ( $ this -> order );
149
+ $ this ->order -> cancel ( );
149
150
$ ruleCustomer = $ this ->getSalesruleCustomerUsage ($ this ->customer , $ this ->salesRule );
150
151
151
152
// Assert, that rule customer model has been created for specific customer
@@ -172,20 +173,12 @@ private function processOrder(Order $order)
172
173
return $ this ->orderRepository ->save ($ order );
173
174
}
174
175
175
- /**
176
- * @param Order $order
177
- */
178
- private function cancelOrder (Order $ order )
179
- {
180
- $ order ->cancel ();
181
- }
182
-
183
176
/**
184
177
* @param Customer $customer
185
178
* @param Rule $rule
186
179
* @return Rule\Customer
187
180
*/
188
- private function getSalesruleCustomerUsage (Customer $ customer , Rule $ rule ) : Magento \SalesRule \Model \Rule \Customer
181
+ private function getSalesruleCustomerUsage (Customer $ customer , Rule $ rule ) : \ Magento \SalesRule \Model \Rule \Customer
189
182
{
190
183
$ ruleCustomer = $ this ->ruleCustomerFactory ->create ();
191
184
return $ ruleCustomer ->loadByCustomerRule ($ customer ->getId (), $ rule ->getRuleId ());
@@ -301,4 +294,3 @@ private function registerNewCustomer() : Customer
301
294
return $ customer ;
302
295
}
303
296
}
304
-
0 commit comments