Skip to content

Commit 0f2e345

Browse files
author
Viktor Sevch
committed
MC-39886: Improve customer api
1 parent ed77424 commit 0f2e345

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,4 +1060,80 @@ public function customerWithMultiByteDataProvider(): array
10601060
],
10611061
];
10621062
}
1063+
1064+
/**
1065+
* Test customer create with valid name's.
1066+
*
1067+
* @param string $fieldName
1068+
* @param string $fieldValue
1069+
* @return void
1070+
*
1071+
* @dataProvider customerValidNameDataProvider
1072+
*/
1073+
public function testCreateCustomerWithValidName(string $fieldName, string $fieldValue): void
1074+
{
1075+
$customerData = $this->dataObjectProcessor->buildOutputDataArray(
1076+
$this->customerHelper->createSampleCustomerDataObject(),
1077+
Customer::class
1078+
);
1079+
$customerData[$fieldName] = $fieldValue;
1080+
1081+
$serviceInfo = [
1082+
'rest' => [
1083+
'resourcePath' => self::RESOURCE_PATH,
1084+
'httpMethod' => Request::HTTP_METHOD_POST,
1085+
],
1086+
'soap' => [
1087+
'service' => self::SERVICE_NAME,
1088+
'serviceVersion' => self::SERVICE_VERSION,
1089+
'operation' => self::SERVICE_NAME . 'Save',
1090+
],
1091+
];
1092+
1093+
$requestData = ['customer' => $customerData];
1094+
1095+
$response = $this->_webApiCall($serviceInfo, $requestData);
1096+
1097+
$this->assertNotNull($response);
1098+
$this->assertEquals($fieldValue, $response[$fieldName]);
1099+
}
1100+
1101+
/**
1102+
* Customer valid name data provider.
1103+
*
1104+
* @return array
1105+
*/
1106+
public function customerValidNameDataProvider(): array
1107+
{
1108+
return [
1109+
[
1110+
'firstname',
1111+
'Anne-Marie',
1112+
],
1113+
[
1114+
'lastname',
1115+
'D\'Artagnan',
1116+
],
1117+
[
1118+
'lastname',
1119+
'Guðmundsdóttir',
1120+
],
1121+
[
1122+
'lastname',
1123+
'María José Carreño Quiñones',
1124+
],
1125+
[
1126+
'lastname',
1127+
'Q. Public',
1128+
],
1129+
[
1130+
'firstname',
1131+
'Elizabeth II',
1132+
],
1133+
[
1134+
'firstname',
1135+
'X Æ A-12 Musk',
1136+
],
1137+
];
1138+
}
10631139
}

0 commit comments

Comments
 (0)