Skip to content

Commit 29756f8

Browse files
committed
ACP2E-1120: extend new statuses that can apply for new placed order with free payment
1 parent b2bbe9d commit 29756f8

File tree

2 files changed

+15
-32
lines changed

2 files changed

+15
-32
lines changed

app/code/Magento/Payment/Model/Method/Free.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ public function __construct(
101101
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
102102
{
103103
return parent::isAvailable(
104-
$quote
105-
) && null !== $quote && $this->priceCurrency->round(
106-
$quote->getGrandTotal()
107-
) == 0;
104+
$quote
105+
) && null !== $quote && $this->priceCurrency->round(
106+
$quote->getGrandTotal()
107+
) == 0;
108108
}
109109

110110
/**

app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Magento\Payment\Model\Method\Free;
1919
use Magento\Payment\Model\Method\Logger;
2020
use Magento\Quote\Model\Quote;
21-
use Magento\Sales\Model\Order\Config;
2221
use PHPUnit\Framework\MockObject\MockObject;
2322
use PHPUnit\Framework\TestCase;
2423
use Psr\Log\LoggerInterface;
@@ -43,11 +42,6 @@ class FreeTest extends TestCase
4342
*/
4443
protected $currencyPrice;
4544

46-
/**
47-
* @var MockObject
48-
*/
49-
protected $configMock;
50-
5145
/**
5246
* @inheritdoc
5347
*/
@@ -70,8 +64,6 @@ protected function setUp(): void
7064
->setConstructorArgs([$this->getMockForAbstractClass(LoggerInterface::class)])
7165
->getMock();
7266

73-
$this->configMock = $this->createMock(Config::class);
74-
7567
$this->methodFree = new Free(
7668
$context,
7769
$registry,
@@ -80,33 +72,26 @@ protected function setUp(): void
8072
$paymentData,
8173
$this->scopeConfig,
8274
$loggerMock,
83-
$this->currencyPrice,
84-
null,
85-
null,
86-
[],
87-
$this->configMock
75+
$this->currencyPrice
8876
);
8977
}
9078

9179
/**
9280
* @param string $orderStatus
9381
* @param string $paymentAction
9482
* @param mixed $result
95-
* @param array $stateStatuses
9683
*
9784
* @return void
9885
* @dataProvider getConfigPaymentActionProvider
9986
*/
10087
public function testGetConfigPaymentAction($orderStatus, $paymentAction, $result, $stateStatuses): void
10188
{
102-
$this->configMock
103-
->method('getStateStatuses')
104-
->with('new')
105-
->willReturn($stateStatuses);
106-
$this->scopeConfig
107-
->method('getValue')
108-
->withConsecutive(['payment/free/order_status'], ['payment/free/'.$paymentAction])
109-
->willReturnOnConsecutiveCalls($orderStatus, $result);
89+
90+
if ($orderStatus != 'pending') {
91+
$this->scopeConfig
92+
->method('getValue')
93+
->willReturnOnConsecutiveCalls($orderStatus, $result);
94+
}
11095
$this->assertEquals($result, $this->methodFree->getConfigPaymentAction());
11196
}
11297

@@ -165,12 +150,10 @@ public function getIsAvailableProvider(): array
165150
public function getConfigPaymentActionProvider(): array
166151
{
167152
return [
168-
['pending', 'payment_action', null, ['pending' => 'Pending']],
169-
['new', 'payment_action', null, ['pending' => 'Pending', 'new' => 'New']],
170-
['new', 'payment_action', 'payment_action', ['pending' => 'Pending']],
171-
['processing', 'payment_action', 'payment_action', ['pending' => 'Pending']],
172-
['processing', 'payment_action', null, ['pending' => 'Pending', 'processing' => 'Processing']],
173-
['processing', 'payment_action', 'payment_action', ['pending' => 'Pending', 'processing' => 'Processing']]
153+
['pending', 'payment_action', null],
154+
['new', 'payment_action', null],
155+
['processing', 'payment_action', null],
156+
['processing', 'payment_action', 'payment_action']
174157
];
175158
}
176159
}

0 commit comments

Comments
 (0)