Skip to content

Commit 592f5de

Browse files
#28570: createCustomer does not match validation requirements
1 parent 0f7d805 commit 592f5de

File tree

4 files changed

+402
-10
lines changed

4 files changed

+402
-10
lines changed

app/code/Magento/CustomerGraphQl/Model/Resolver/UpdateCustomerEmail.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ class UpdateCustomerEmail implements ResolverInterface
2525
* @var GetCustomer
2626
*/
2727
private $getCustomer;
28+
2829
/**
2930
* @var UpdateCustomerAccount
3031
*/
3132
private $updateCustomerAccount;
33+
3234
/**
3335
* @var ExtractCustomerData
3436
*/
@@ -50,7 +52,7 @@ public function __construct(
5052
}
5153

5254
/**
53-
* @inheritdoc
55+
* Resolves customer email update mutation
5456
*/
5557
public function resolve(
5658
Field $field,
@@ -67,7 +69,10 @@ public function resolve(
6769
$customer = $this->getCustomer->execute($context);
6870
$this->updateCustomerAccount->execute(
6971
$customer,
70-
['email' => $args['email'], 'password' => $args['password']],
72+
[
73+
'email' => $args['email'] ?? null,
74+
'password' => $args['password'] ?? null
75+
],
7176
$context->getExtensionAttributes()->getStore()
7277
);
7378

app/code/Magento/CustomerGraphQl/etc/schema.graphqls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ type Query {
1717
type Mutation {
1818
generateCustomerToken(email: String!, password: String!): CustomerToken @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\GenerateCustomerToken") @doc(description:"Retrieve the customer token")
1919
changeCustomerPassword(currentPassword: String!, newPassword: String!): Customer @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\ChangePassword") @doc(description:"Changes the password for the logged-in customer")
20-
createCustomer (input: CustomerCreateInput!): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CreateCustomer") @doc(description:"Create customer account")
20+
createCustomer (input: CustomerInput!): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CreateCustomer") @doc(description:"Create customer account")
21+
createCustomerV2 (input: CustomerCreateInput!): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CreateCustomer") @doc(description:"Create customer account")
2122
updateCustomer (input: CustomerInput!): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\UpdateCustomer") @doc(description:"Deprecated. Use UpdateCustomerV2 instead.")
2223
updateCustomerV2 (input: CustomerUpdateInput!): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\UpdateCustomer") @doc(description:"Update the customer's personal information")
2324
revokeCustomerToken: RevokeCustomerTokenOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\RevokeCustomerToken") @doc(description:"Revoke the customer token")

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,8 @@ public function testCreateCustomerAccountWithoutPassword()
116116
*/
117117
public function testCreateCustomerIfInputDataIsEmpty()
118118
{
119-
$exceptionMessage = 'Field CustomerCreateInput.email of required type String! was not provided.
120-
Field CustomerCreateInput.firstname of required type String! was not provided.
121-
Field CustomerCreateInput.lastname of required type String! was not provided.';
122-
123119
$this->expectException(\Exception::class);
124-
$this->expectExceptionMessage($exceptionMessage);
120+
$this->expectExceptionMessage('"input" value should be specified');
125121

126122
$query = <<<QUERY
127123
mutation {
@@ -148,7 +144,7 @@ public function testCreateCustomerIfInputDataIsEmpty()
148144
public function testCreateCustomerIfEmailMissed()
149145
{
150146
$this->expectException(\Exception::class);
151-
$this->expectExceptionMessage('Field CustomerCreateInput.email of required type String! was not provided');
147+
$this->expectExceptionMessage('Required parameters are missing: Email');
152148

153149
$newFirstname = 'Richard';
154150
$newLastname = 'Rowe';
@@ -238,7 +234,7 @@ public function invalidEmailAddressDataProvider(): array
238234
public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
239235
{
240236
$this->expectException(\Exception::class);
241-
$this->expectExceptionMessage('Field "test123" is not defined by type CustomerCreateInput.');
237+
$this->expectExceptionMessage('Field "test123" is not defined by type CustomerInput.');
242238

243239
$newFirstname = 'Richard';
244240
$newLastname = 'Rowe';

0 commit comments

Comments
 (0)