Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 41f2669

Browse files
author
Joan He
committed
Merge remote-tracking branch 'trigger/MAGETWO-90280' into BugFixPR
2 parents cfba0ed + 467ee16 commit 41f2669

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
837837
if ($customer->getWebsiteId()) {
838838
$storeId = $this->storeManager->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId();
839839
} else {
840+
$this->storeManager->setCurrentStore(null);
840841
$storeId = $this->storeManager->getStore()->getId();
841842
}
842843
$customer->setStoreId($storeId);
@@ -1011,7 +1012,7 @@ protected function createPasswordHash($password)
10111012
}
10121013

10131014
/**
1014-
* Returns eval validator
1015+
* Get EAV validator
10151016
*
10161017
* @return Backend
10171018
*/
@@ -1216,7 +1217,7 @@ protected function getWebsiteStoreId($customer, $defaultStoreId = null)
12161217
}
12171218

12181219
/**
1219-
* Return array with template types
1220+
* Get template types
12201221
*
12211222
* @return array
12221223
* @deprecated 100.1.0

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,34 @@ public function testCreateCustomerWithErrors()
213213
}
214214
}
215215

216+
public function testCreateCustomerWithoutOptionalFields()
217+
{
218+
$serviceInfo = [
219+
'rest' => [
220+
'resourcePath' => self::RESOURCE_PATH,
221+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ],
222+
'soap' => [
223+
'service' => self::SERVICE_NAME,
224+
'serviceVersion' => self::SERVICE_VERSION,
225+
'operation' => self::SERVICE_NAME . 'CreateAccount',
226+
],
227+
];
228+
229+
$customerDataArray = $this->dataObjectProcessor->buildOutputDataArray(
230+
$this->customerHelper->createSampleCustomerDataObject(),
231+
\Magento\Customer\Api\Data\CustomerInterface::class
232+
);
233+
unset($customerDataArray['store_id']);
234+
unset($customerDataArray['website_id']);
235+
$requestData = ['customer' => $customerDataArray, 'password' => CustomerHelper::PASSWORD];
236+
try {
237+
$customerData = $this->_webApiCall($serviceInfo, $requestData, null, 'all');
238+
$this->assertNotNull($customerData['id']);
239+
} catch (\Exception $e) {
240+
$this->fail('Customer should be created without optional fields.');
241+
}
242+
}
243+
216244
/**
217245
* Test customer activation when it is required
218246
*

0 commit comments

Comments
 (0)