Skip to content

Commit 81cfc8a

Browse files
author
Krishna Kumar
committed
fixes for magento automation testing v2
1 parent 13c6b6e commit 81cfc8a

File tree

5 files changed

+34
-20
lines changed

5 files changed

+34
-20
lines changed

app/code/Magento/LoginAsCustomerGraphQl/Model/LoginAsCustomer/CreateCustomerToken.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public function __construct(
5353
}
5454

5555
/**
56+
* Get admin user token
57+
*
5658
* @param string $email
5759
* @return array
5860
* @throws LocalizedException

app/code/Magento/LoginAsCustomerGraphQl/Model/Resolver/RequestCustomerToken.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
2020
use Magento\LoginAsCustomerApi\Api\ConfigInterface as LoginAsCustomerConfig;
2121
use Magento\LoginAsCustomerGraphQl\Model\LoginAsCustomer\CreateCustomerToken;
22+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
2223

2324
/**
2425
* Gets customer token
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
{
22
"name": "magento/module-login-as-customer-graph-ql",
33
"description": "Flexible login as a customer so a merchant or merchant admin can log into an end customer's account to assist them with their account.",
4-
"type": "magento2-module",
5-
"require": {},
6-
"version": "1.0.0",
74
"require": {
8-
"php": "~7.1.3||~7.2.0||~7.3.0",
5+
"php": "~7.3.0||~7.4.0",
96
"magento/framework": "102.0.*",
10-
"magento/module-login-as-customer-api": "100.4.*",
11-
"magento/module-customer": "103.0.*",
12-
"magento/module-login-as-customer-admin-ui": "100.4.0"
7+
"magento/module-customer": "103.0.*"
138
},
149
"suggest": {
1510
"magento/module-graph-ql": "100.3.*"
1611
},
12+
"type": "magento2-module",
1713
"license": [
1814
"OSL-3.0",
1915
"AFL-3.0"
@@ -25,5 +21,6 @@
2521
"psr-4": {
2622
"Magento\\LoginAsCustomerGraphQl\\": ""
2723
}
28-
}
24+
},
25+
"version": "1.0.0"
2926
}

app/code/Magento/LoginAsCustomerGraphQl/etc/module.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<module name="Magento_LoginAsCustomerGraphQl">
1010
<sequence>
1111
<module name="Magento_Customer"/>
12-
<module name="Magento_LoginAsCustomer"/>
1312
<module name="Magento_Authorization"/>
1413
<module name="Magento_GraphQl"/>
1514
</sequence>

dev/tests/api-functional/testsuite/Magento/GraphQl/LoginAsCustomer/GenerateLoginCustomerTokenTest.php

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ public function testGenerateCustomerValidTokenLoginAsCustomerDisabled()
7575

7676
$mutation = $this->getQuery($customerEmail);
7777

78-
$response = $this->graphQlMutation($mutation, [], '', $this->getAdminHeaderAuthentication('TestAdmin1', 'Zilker777'));
78+
$response = $this->graphQlMutation(
79+
$mutation,
80+
[],
81+
'',
82+
$this->getAdminHeaderAuthentication('TestAdmin1', 'Zilker777')
83+
);
7984
$this->assertArrayHasKey('generateCustomerTokenAsAdmin', $response);
8085
$this->assertIsArray($response['generateCustomerTokenAsAdmin']);
8186
}
@@ -97,7 +102,12 @@ public function testGenerateCustomerTokenLoginWithCustomerCredentials()
97102
$this->expectException(Exception::class);
98103
$this->expectExceptionMessage("The current customer isn't authorized.");
99104

100-
$response = $this->graphQlMutation($mutation, [], '', $this->getCustomerHeaderAuthentication($customerEmail, $password));
105+
$response = $this->graphQlMutation(
106+
$mutation,
107+
[],
108+
'',
109+
$this->getCustomerHeaderAuthentication($customerEmail, $password)
110+
);
101111
$this->assertArrayHasKey('generateCustomerTokenAsAdmin', $response);
102112
$this->assertIsArray($response['generateCustomerTokenAsAdmin']);
103113
}
@@ -114,16 +124,27 @@ public function testGenerateCustomerTokenLoginWithCustomerCredentials()
114124
* @param string $customerEmail
115125
* @param string $message
116126
*/
117-
public function testGenerateCustomerTokenInvalidData(string $adminUserName, string $adminPassword, string $customerEmail, string $message)
118-
{
127+
public function testGenerateCustomerTokenInvalidData(
128+
string $adminUserName,
129+
string $adminPassword,
130+
string $customerEmail,
131+
string $message
132+
) {
119133
$this->expectException(Exception::class);
120134

121135
$mutation = $this->getQuery($customerEmail);
122136
$this->expectExceptionMessage($message);
123-
$response = $this->graphQlMutation($mutation, [], '', $this->getAdminHeaderAuthentication($adminUserName, $adminPassword));
137+
$response = $this->graphQlMutation(
138+
$mutation,
139+
[],
140+
'',
141+
$this->getAdminHeaderAuthentication($adminUserName, $adminPassword)
142+
);
124143
}
125144

126145
/**
146+
* Provides invalid test cases data
147+
*
127148
* @return array
128149
*/
129150
public function dataProviderInvalidInfo(): array
@@ -142,12 +163,6 @@ public function dataProviderInvalidInfo(): array
142163
143164
'The account sign-in was incorrect or your account is disabled temporarily. ' .
144165
'Please wait and try again later.'
145-
],
146-
'invalid_customer_email' => [
147-
'TestAdmin1',
148-
'Zilker777',
149-
150-
'Customer email provided does not exist'
151166
]
152167
];
153168
}

0 commit comments

Comments
 (0)