Skip to content

Commit c1d4190

Browse files
committed
fix phpcs
1 parent afd489b commit c1d4190

File tree

1 file changed

+65
-32
lines changed

1 file changed

+65
-32
lines changed

app/code/Magento/SalesRule/Test/Unit/Model/RulesApplierTest.php

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,67 @@
66

77
namespace Magento\SalesRule\Test\Unit\Model;
88

9+
use Magento\Framework\Event\Manager;
10+
use Magento\Quote\Model\Quote;
11+
use Magento\Quote\Model\Quote\Address;
12+
use Magento\Quote\Model\Quote\Item;
13+
use Magento\Quote\Model\Quote\Item\AbstractItem;
14+
use Magento\Rule\Model\Action\Collection;
15+
use Magento\SalesRule\Model\Quote\ChildrenValidationLocator;
16+
use Magento\SalesRule\Model\Rule;
17+
use Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory;
18+
use Magento\SalesRule\Model\Rule\Action\Discount\Data;
19+
use Magento\SalesRule\Model\Rule\Action\Discount\DiscountInterface;
20+
use Magento\SalesRule\Model\RulesApplier;
21+
use Magento\SalesRule\Model\Utility;
22+
use PHPUnit\Framework\TestCase;
23+
use PHPUnit_Framework_MockObject_MockObject;
24+
925
/**
1026
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1127
*/
12-
class RulesApplierTest extends \PHPUnit\Framework\TestCase
28+
class RulesApplierTest extends TestCase
1329
{
1430
/**
15-
* @var \Magento\SalesRule\Model\RulesApplier
31+
* @var RulesApplier
1632
*/
1733
protected $rulesApplier;
1834

1935
/**
20-
* @var \Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory|\PHPUnit_Framework_MockObject_MockObject
36+
* @var CalculatorFactory|PHPUnit_Framework_MockObject_MockObject
2137
*/
2238
protected $calculatorFactory;
2339

2440
/**
25-
* @var \Magento\Framework\Event\Manager|\PHPUnit_Framework_MockObject_MockObject
41+
* @var Manager|PHPUnit_Framework_MockObject_MockObject
2642
*/
2743
protected $eventManager;
2844

2945
/**
30-
* @var \Magento\SalesRule\Model\Utility|\PHPUnit_Framework_MockObject_MockObject
46+
* @var Utility|PHPUnit_Framework_MockObject_MockObject
3147
*/
3248
protected $validatorUtility;
3349

3450
/**
35-
* @var \Magento\SalesRule\Model\Quote\ChildrenValidationLocator|\PHPUnit_Framework_MockObject_MockObject
51+
* @var ChildrenValidationLocator|PHPUnit_Framework_MockObject_MockObject
3652
*/
3753
protected $childrenValidationLocator;
3854

3955
protected function setUp()
4056
{
4157
$this->calculatorFactory = $this->createMock(
42-
\Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory::class
58+
CalculatorFactory::class
4359
);
44-
$this->eventManager = $this->createPartialMock(\Magento\Framework\Event\Manager::class, ['dispatch']);
60+
$this->eventManager = $this->createPartialMock(Manager::class, ['dispatch']);
4561
$this->validatorUtility = $this->createPartialMock(
46-
\Magento\SalesRule\Model\Utility::class,
62+
Utility::class,
4763
['canProcessRule', 'minFix', 'deltaRoundingFix', 'getItemQty']
4864
);
4965
$this->childrenValidationLocator = $this->createPartialMock(
50-
\Magento\SalesRule\Model\Quote\ChildrenValidationLocator::class,
66+
ChildrenValidationLocator::class,
5167
['isChildrenValidationRequired']
5268
);
53-
$this->rulesApplier = new \Magento\SalesRule\Model\RulesApplier(
69+
$this->rulesApplier = new RulesApplier(
5470
$this->calculatorFactory,
5571
$this->eventManager,
5672
$this->validatorUtility,
@@ -75,19 +91,21 @@ public function testApplyRulesWhenRuleWithStopRulesProcessingIsUsed($isChildren,
7591
$appliedRuleIds = [$ruleId => $ruleId];
7692

7793
/**
78-
* @var \Magento\SalesRule\Model\Rule|\PHPUnit_Framework_MockObject_MockObject $ruleWithStopFurtherProcessing
94+
* @var Rule|PHPUnit_Framework_MockObject_MockObject $ruleWithStopFurtherProcessing
7995
*/
8096
$ruleWithStopFurtherProcessing = $this->createPartialMock(
81-
\Magento\SalesRule\Model\Rule::class,
97+
Rule::class,
8298
['getStoreLabel', 'getCouponType', 'getRuleId', '__wakeup', 'getActions']
8399
);
84-
/** @var \Magento\SalesRule\Model\Rule|\PHPUnit_Framework_MockObject_MockObject $ruleThatShouldNotBeRun */
100+
/**
101+
* @var Rule|PHPUnit_Framework_MockObject_MockObject $ruleThatShouldNotBeRun
102+
*/
85103
$ruleThatShouldNotBeRun = $this->createPartialMock(
86-
\Magento\SalesRule\Model\Rule::class,
104+
Rule::class,
87105
['getStopRulesProcessing', '__wakeup']
88106
);
89107

90-
$actionMock = $this->createPartialMock(\Magento\Rule\Model\Action\Collection::class, ['validate']);
108+
$actionMock = $this->createPartialMock(Collection::class, ['validate']);
91109

92110
$ruleWithStopFurtherProcessing->setName('ruleWithStopFurtherProcessing');
93111
$ruleThatShouldNotBeRun->setName('ruleThatShouldNotBeRun');
@@ -146,22 +164,27 @@ public function testAddCouponDescriptionWithRuleDescriptionIsUsed()
146164
$ruleDescription = 'Rule description';
147165

148166
/**
149-
* @var \Magento\SalesRule\Model\Rule|\PHPUnit_Framework_MockObject_MockObject $rule
167+
* @var Rule|PHPUnit_Framework_MockObject_MockObject $rule
150168
*/
151169
$rule = $this->createPartialMock(
152-
\Magento\SalesRule\Model\Rule::class,
170+
Rule::class,
153171
['getStoreLabel', 'getCouponType', 'getRuleId', '__wakeup', 'getActions']
154-
);
172+
);
155173

156174
$rule->setDescription($ruleDescription);
157175

158-
/** @var \Magento\Quote\Model\Quote\Address|\PHPUnit_Framework_MockObject_MockObject $address */
159-
$address = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, [
176+
/**
177+
* @var Address|PHPUnit_Framework_MockObject_MockObject $address
178+
*/
179+
$address = $this->createPartialMock(
180+
Address::class,
181+
[
160182
'getQuote',
161183
'setCouponCode',
162184
'setAppliedRuleIds',
163185
'__wakeup'
164-
]);
186+
]
187+
);
165188
$description = $address->getDiscountDescriptionArray();
166189
$description[$ruleId] = $rule->getDescription();
167190
$address->setDiscountDescriptionArray($description[$ruleId]);
@@ -181,28 +204,38 @@ public function dataProviderChildren()
181204
}
182205

183206
/**
184-
* @return \Magento\Quote\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject
207+
* @return AbstractItem|PHPUnit_Framework_MockObject_MockObject
185208
*/
186209
protected function getPreparedItem()
187210
{
188-
/** @var \Magento\Quote\Model\Quote\Address|\PHPUnit_Framework_MockObject_MockObject $address */
189-
$address = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, [
211+
/**
212+
* @var Address|PHPUnit_Framework_MockObject_MockObject $address
213+
*/
214+
$address = $this->createPartialMock(
215+
Address::class,
216+
[
190217
'getQuote',
191218
'setCouponCode',
192219
'setAppliedRuleIds',
193220
'__wakeup'
194-
]);
195-
/** @var \Magento\Quote\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */
196-
$item = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, [
221+
]
222+
);
223+
/**
224+
* @var AbstractItem|PHPUnit_Framework_MockObject_MockObject $item
225+
*/
226+
$item = $this->createPartialMock(
227+
Item::class,
228+
[
197229
'setDiscountAmount',
198230
'setBaseDiscountAmount',
199231
'setDiscountPercent',
200232
'getAddress',
201233
'setAppliedRuleIds',
202234
'__wakeup',
203235
'getChildren'
204-
]);
205-
$quote = $this->createPartialMock(\Magento\Quote\Model\Quote::class, ['getStore', '__wakeUp']);
236+
]
237+
);
238+
$quote = $this->createPartialMock(Quote::class, ['getStore', '__wakeUp']);
206239
$item->expects($this->any())->method('getAddress')->will($this->returnValue($address));
207240
$address->expects($this->any())
208241
->method('getQuote')
@@ -219,10 +252,10 @@ protected function applyRule($item, $rule)
219252
{
220253
$qty = 2;
221254
$discountCalc = $this->createPartialMock(
222-
\Magento\SalesRule\Model\Rule\Action\Discount\DiscountInterface::class,
255+
DiscountInterface::class,
223256
['fixQuantity', 'calculate']
224257
);
225-
$discountData = $this->getMockBuilder(\Magento\SalesRule\Model\Rule\Action\Discount\Data::class)
258+
$discountData = $this->getMockBuilder(Data::class)
226259
->setConstructorArgs(
227260
[
228261
'amount' => 30,

0 commit comments

Comments
 (0)