Skip to content

Commit b451abc

Browse files
authored
ENGCOM-4523: Fixed : Additional addresses DataTable Pagination count displaying wrong #21399
2 parents cbbca83 + d67c819 commit b451abc

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

app/code/Magento/Customer/Block/Address/Grid.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
2-
declare(strict_types=1);
32
/**
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\Customer\Block\Address;
89

910
use Magento\Customer\Model\ResourceModel\Address\CollectionFactory as AddressCollectionFactory;
@@ -236,8 +237,12 @@ private function getAddressCollection(): \Magento\Customer\Model\ResourceModel\A
236237
}
237238
/** @var \Magento\Customer\Model\ResourceModel\Address\Collection $collection */
238239
$collection = $this->addressCollectionFactory->create();
239-
$collection->setOrder('entity_id', 'desc')
240-
->setCustomerFilter([$this->getCustomer()->getId()]);
240+
$collection->setOrder('entity_id', 'desc');
241+
$collection->addFieldToFilter(
242+
'entity_id',
243+
['nin' => [$this->getDefaultBilling(), $this->getDefaultShipping()]]
244+
);
245+
$collection->setCustomerFilter([$this->getCustomer()->getId()]);
241246
$this->addressCollection = $collection;
242247
}
243248
return $this->addressCollection;

app/code/Magento/Customer/Test/Unit/Block/Address/GridTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function setUp()
8181
public function testGetChildHtml()
8282
{
8383
$customerId = 1;
84-
84+
$outputString = 'OutputString';
8585
/** @var \Magento\Framework\View\Element\BlockInterface|\PHPUnit_Framework_MockObject_MockObject $block */
8686
$block = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class)
8787
->setMethods(['setCollection'])
@@ -93,7 +93,7 @@ public function testGetChildHtml()
9393
/** @var \PHPUnit_Framework_MockObject_MockObject */
9494
$addressCollection = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Address\Collection::class)
9595
->disableOriginalConstructor()
96-
->setMethods(['setOrder', 'setCustomerFilter', 'load'])
96+
->setMethods(['setOrder', 'setCustomerFilter', 'load','addFieldToFilter'])
9797
->getMock();
9898

9999
$layout->expects($this->atLeastOnce())->method('getChildName')->with('NameInLayout', 'pager')
@@ -108,12 +108,13 @@ public function testGetChildHtml()
108108
->willReturnSelf();
109109
$addressCollection->expects($this->atLeastOnce())->method('setCustomerFilter')->with([$customerId])
110110
->willReturnSelf();
111+
$addressCollection->expects(static::any())->method('addFieldToFilter')->willReturnSelf();
111112
$this->addressCollectionFactory->expects($this->atLeastOnce())->method('create')
112113
->willReturn($addressCollection);
113114
$block->expects($this->atLeastOnce())->method('setCollection')->with($addressCollection)->willReturnSelf();
114115
$this->gridBlock->setNameInLayout('NameInLayout');
115116
$this->gridBlock->setLayout($layout);
116-
$this->assertEquals('OutputString', $this->gridBlock->getChildHtml('pager'));
117+
$this->assertEquals($outputString, $this->gridBlock->getChildHtml('pager'));
117118
}
118119

119120
/**
@@ -137,7 +138,7 @@ public function testGetAdditionalAddresses()
137138
/** @var \PHPUnit_Framework_MockObject_MockObject */
138139
$addressCollection = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Address\Collection::class)
139140
->disableOriginalConstructor()
140-
->setMethods(['setOrder', 'setCustomerFilter', 'load', 'getIterator'])
141+
->setMethods(['setOrder', 'setCustomerFilter', 'load', 'getIterator','addFieldToFilter'])
141142
->getMock();
142143
$addressDataModel = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\AddressInterface::class);
143144
$address = $this->getMockBuilder(\Magento\Customer\Model\Address::class)
@@ -157,6 +158,7 @@ public function testGetAdditionalAddresses()
157158
->willReturnSelf();
158159
$addressCollection->expects($this->atLeastOnce())->method('setCustomerFilter')->with([$customerId])
159160
->willReturnSelf();
161+
$addressCollection->expects(static::any())->method('addFieldToFilter')->willReturnSelf();
160162
$addressCollection->expects($this->atLeastOnce())->method('getIterator')
161163
->willReturn(new \ArrayIterator($collection));
162164
$this->addressCollectionFactory->expects($this->atLeastOnce())->method('create')

0 commit comments

Comments
 (0)