Skip to content

Commit dad9e57

Browse files
convenientaa-kashk
authored andcommitted
Fix code style
1 parent fff342e commit dad9e57

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

app/code/Magento/Sales/Model/Order/Invoice/Plugin/AddressUpdate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AddressUpdate
2323
*
2424
* @var \Magento\Framework\App\Config\ScopeConfigInterface
2525
*/
26-
protected $globalConfig;
26+
private $globalConfig;
2727

2828
/**
2929
* AddressUpdate constructor.
@@ -49,6 +49,7 @@ public function __construct(
4949
* @param \Magento\Sales\Model\Order $order
5050
* @return void
5151
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
52+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5253
*/
5354
public function afterProcess(
5455
\Magento\Sales\Model\ResourceModel\Order\Handler\Address $subject,

app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Plugin/AddressUpdateTest.php

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Sales\Test\Unit\Model\Order\Invoice\Plugin;
99

10+
use Magento\Framework\App\Config\ScopeConfigInterface;
1011
use Magento\Sales\Model\Order;
1112
use Magento\Sales\Model\Order\Address;
1213
use Magento\Sales\Model\Order\Invoice;
@@ -34,17 +35,27 @@ class AddressUpdateTest extends TestCase
3435
*/
3536
private $attributeMock;
3637

38+
/**
39+
* @var MockObject
40+
*/
41+
private $globalConfigMock;
42+
3743
protected function setUp(): void
3844
{
3945
$this->gripPoolMock = $this->createMock(GridPool::class);
4046
$this->attributeMock = $this->createMock(Attribute::class);
47+
$this->globalConfigMock = $this->createMock(ScopeConfigInterface::class);
4148
$this->model = new AddressUpdate(
4249
$this->gripPoolMock,
43-
$this->attributeMock
50+
$this->attributeMock,
51+
$this->globalConfigMock
4452
);
4553
}
4654

47-
public function testAfterProcess()
55+
/**
56+
* @dataProvider dataProvider
57+
*/
58+
public function testAfterProcess($asyncReindexEnabled, $expectedReindexCalledCount)
4859
{
4960
$billingId = 100;
5061
$shippingId = 200;
@@ -69,7 +80,9 @@ public function testAfterProcess()
6980
$orderMock->expects($this->once())->method('getBillingAddress')->willReturn($billingMock);
7081
$orderMock->expects($this->once())->method('getShippingAddress')->willReturn($shippingMock);
7182
$orderMock->expects($this->once())->method('getInvoiceCollection')->willReturn($invoiceCollectionMock);
72-
$orderMock->expects($this->once())->method('getId')->willReturn($orderId);
83+
$orderMock->expects($this->exactly($expectedReindexCalledCount))
84+
->method('getId')
85+
->willReturn($orderId);
7386

7487
$invoiceMock->expects($this->once())->method('getBillingAddressId')->willReturn(null);
7588
$invoiceMock->expects($this->once())->method('getShippingAddressId')->willReturn(null);
@@ -81,12 +94,34 @@ public function testAfterProcess()
8194
->with($invoiceMock, ['billing_address_id', 'shipping_address_id'])
8295
->willReturnSelf();
8396

84-
$this->gripPoolMock->expects($this->once())->method('refreshByOrderId')->with($orderId)->willReturnSelf();
97+
$this->gripPoolMock->expects($this->exactly($expectedReindexCalledCount))
98+
->method('refreshByOrderId')
99+
->with($orderId)
100+
->willReturnSelf();
101+
102+
$this->globalConfigMock->expects($this->once())
103+
->method('getValue')
104+
->with('dev/grid/async_indexing')
105+
->willReturn($asyncReindexEnabled);
85106

86107
$this->model->afterProcess(
87108
$this->createMock(\Magento\Sales\Model\ResourceModel\Order\Handler\Address::class),
88109
$this->createMock(\Magento\Sales\Model\ResourceModel\Order\Handler\Address::class),
89110
$orderMock
90111
);
91112
}
113+
114+
public function dataProvider()
115+
{
116+
return [
117+
'Do not reindex when async is enabled' => [
118+
true,
119+
0
120+
],
121+
'Reindex when async is disabled' => [
122+
false,
123+
1
124+
],
125+
];
126+
}
92127
}

0 commit comments

Comments
 (0)