Skip to content

Commit cbbc79f

Browse files
ENGCOM-4523: Fixed : Additional addresses DataTable Pagination count displaying wrong #21399
- Merge Pull Request #21399 from Dharmeshvaja91/magento2:fixed-issue-21396 - Merged commits: 1. f1e2fff 2. 8a872be 3. 69aac2c 4. 7320e1b 5. 0fcf041 6. 3ccc867 7. 5552b3e 8. dcff5d1 9. 0ab0e03 10. 6584286 11. c39751f 12. 7127e16 13. be076d5 14. 2f42295 15. fa9b420
2 parents 3666e03 + fa9b420 commit cbbc79f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ private function getAddressCollection(): \Magento\Customer\Model\ResourceModel\A
236236
}
237237
/** @var \Magento\Customer\Model\ResourceModel\Address\Collection $collection */
238238
$collection = $this->addressCollectionFactory->create();
239-
$collection->setOrder('entity_id', 'desc')
240-
->setCustomerFilter([$this->getCustomer()->getId()]);
239+
$collection->setOrder('entity_id', 'desc');
240+
$collection->addFieldToFilter('entity_id', array('nin' => array($this->getDefaultBilling(), $this->getDefaultShipping())));
241+
$collection->setCustomerFilter([$this->getCustomer()->getId()]);
241242
$this->addressCollection = $collection;
242243
}
243244
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)