Skip to content

Commit f2e7b44

Browse files
committed
ACP2E-877: Customers not filtered by 'Signed up point' when creating an order in Admin
- Added the test coverage and fixed the static build test failure.
1 parent e5b0816 commit f2e7b44

File tree

2 files changed

+36
-0
lines changed
  • app/code/Magento/Sales/Model/ResourceModel/Order/Customer
  • dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/Customer

2 files changed

+36
-0
lines changed

app/code/Magento/Sales/Model/ResourceModel/Order/Customer/Collection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ protected function beforeAddLoadedItem(DataObject $item): DataObject
158158

159159
/**
160160
* @inheritDoc
161+
*
161162
* @throws LocalizedException
162163
*/
163164
public function addFieldToFilter($field, $condition = null)

dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/Customer/CollectionTest.php

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

88
namespace Magento\Sales\Model\ResourceModel\Order\Customer;
99

10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Framework\ObjectManagerInterface;
1112
use Magento\Store\Api\StoreRepositoryInterface;
1213
use Magento\Store\Api\WebsiteRepositoryInterface;
@@ -50,4 +51,38 @@ public function testCollection(): void
5051
$this->assertEquals($website->getName(), $customer->getWebsiteName());
5152
$this->assertEquals($store->getName(), $customer->getStoreName());
5253
}
54+
55+
/**
56+
* Test customer collection with the website and the store name filter.
57+
*
58+
* @throws LocalizedException
59+
* @see \Magento\Customer\Model\ResourceModel\Customer\Collection::addFieldToFilter()
60+
*
61+
* @magentoDataFixture Magento/Customer/_files/customer_for_second_website.php
62+
*/
63+
public function testCollectionWithWebsiteStoreFilter(): void
64+
{
65+
/** @var Collection $customerCollection */
66+
$customerCollection = $this->objectManager->create(Collection::class);
67+
68+
$customer = $customerCollection->getItems();
69+
$customer = array_shift($customer);
70+
71+
/** @var WebsiteRepositoryInterface $websiteRepository */
72+
$websiteRepository = $this->objectManager->get(WebsiteRepositoryInterface::class);
73+
$website = $websiteRepository->getById($customer->getWebsiteId());
74+
75+
/** @var StoreRepositoryInterface $storeRepository */
76+
$storeRepository = $this->objectManager->get(StoreRepositoryInterface::class);
77+
$store = $storeRepository->getById($customer->getStoreId());
78+
79+
$customerCollectionWithStoreWebsiteFilter = $customerCollection
80+
->addFieldToFilter('store_name', $store->getName())
81+
->addFieldToFilter('website_name', $website->getName());
82+
$customerWithStoreWebsiteFilter = $customerCollectionWithStoreWebsiteFilter->getItems();
83+
$customerWithStoreWebsiteFilter = array_shift($customerWithStoreWebsiteFilter);
84+
85+
$this->assertEquals($website->getName(), $customerWithStoreWebsiteFilter->getWebsiteName());
86+
$this->assertEquals($store->getName(), $customerWithStoreWebsiteFilter->getStoreName());
87+
}
5388
}

0 commit comments

Comments
 (0)