Skip to content

Commit 7b5e58c

Browse files
author
Mohan Ahuja
committed
ACP2E-356: Cannot create a new customer from Admin if Customer Sharing setting is set to Global
- Fixing unit test issues.
1 parent d3cfafa commit 7b5e58c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

app/code/Magento/Customer/Test/Unit/ViewModel/Customer/StoreTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Store\Model\Store;
1616
use Magento\Store\Model\StoreManagerInterface;
1717
use Magento\Store\Model\System\Store as SystemStore;
18+
use Magento\Store\Model\Website;
1819
use PHPUnit\Framework\TestCase;
1920

2021
/**
@@ -90,6 +91,10 @@ public function testToOptionArray(array $options, bool $isWebsiteScope, bool $is
9091
$this->store->method('getWebsiteId')
9192
->willReturn(1);
9293

94+
$websiteMock = $this->createPartialMock(Website::class, ['getId']);
95+
$websiteMock->method('getId')->willReturn(1);
96+
$this->systemStore->method('getWebsiteCollection')->willReturn([$websiteMock]);
97+
9398
if ($isCustomerDataInSession) {
9499
$this->dataPersistor->method('get')
95100
->with('customer')

app/code/Magento/Customer/Test/Unit/ViewModel/Customer/WebsiteTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1414
use Magento\Store\Model\System\Store as SystemStore;
1515
use PHPUnit\Framework\TestCase;
16+
use Magento\Store\Model\Website;
17+
use Magento\Store\Model\Store;
1618

1719
/**
1820
* Test for customer's website view model
@@ -49,6 +51,20 @@ protected function setUp(): void
4951
'scopeConfig' => $this->scopeConfig
5052
]
5153
);
54+
$websiteMock1 = $this->createPartialMock(Website::class, ['getId', 'getDefaultStore']);
55+
$websiteMock2 = $this->createPartialMock(Website::class, ['getId', 'getDefaultStore']);
56+
$storeMock1 = $this->createPartialMock(Store::class, ['getId']);
57+
$storeMock2 = $this->createPartialMock(Store::class, ['getId']);
58+
59+
$websiteMock1->method('getId')->willReturn(1);
60+
$websiteMock1->method('getDefaultStore')->willReturn($storeMock1);
61+
$storeMock1->method('getId')->willReturn(1);
62+
63+
$websiteMock2->method('getId')->willReturn(2);
64+
$websiteMock2->method('getDefaultStore')->willReturn($storeMock2);
65+
$storeMock2->method('getId')->willReturn(2);
66+
67+
$this->systemStore->method('getWebsiteCollection')->willReturn([$websiteMock1, $websiteMock2]);
5268
}
5369

5470
/**

0 commit comments

Comments
 (0)