@@ -42,41 +42,19 @@ public function testGenerateCustomerValidToken()
4242 }
4343
4444 /**
45- * Verify customer with invalid email
45+ * Test customer with invalid data.
4646 *
4747 * @magentoApiDataFixture Magento/Customer/_files/customer.php
4848 * @expectedException \Exception
49- * @expectedExceptionMessage GraphQL response contains errors: The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.
50- */
51- public function testGenerateCustomerTokenWithInvalidEmail ()
52- {
53- $ email = 'customer@example ' ;
54- $ password = 'password ' ;
55-
56- $ mutation
57- = <<<MUTATION
58- mutation {
59- generateCustomerToken(
60- email: " {$ email }"
61- password: " {$ password }"
62- ) {
63- token
64- }
65- }
66- MUTATION ;
67- $ this ->graphQlMutation ($ mutation );
68- }
69-
70- /**
71- * Verify customer with empty email
7249 *
73- * @magentoApiDataFixture Magento/Customer/_files/customer.php
50+ * @dataProvider dataProviderCustomerInfo
51+ * @param string $email
52+ * @param string $password
53+ * @param string $message
54+ * @throws \Exception
7455 */
75- public function testGenerateCustomerTokenWithEmptyEmail ( )
56+ public function testGenerateCustomerTokenNegativeCases ( string $ email , string $ password , string $ message )
7657 {
77- $ email = '' ;
78- $ password = 'password ' ;
79-
8058 $ mutation
8159 = <<<MUTATION
8260mutation {
@@ -88,68 +66,12 @@ public function testGenerateCustomerTokenWithEmptyEmail()
8866 }
8967}
9068MUTATION ;
91-
92- $ this ->expectException (\Exception::class);
93- $ this ->expectExceptionMessage ('GraphQL response contains errors: Specify the "email" value. ' );
69+ $ this ->expectExceptionMessage ($ message );
9470 $ this ->graphQlMutation ($ mutation );
9571 }
9672
9773 /**
98- * Verify customer with invalid credentials
99- *
100- * @magentoApiDataFixture Magento/Customer/_files/customer.php
101- * @expectedException \Exception
102- * @expectedExceptionMessage GraphQL response contains errors: The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.
103- */
104- public function testGenerateCustomerTokenWithIncorrectPassword ()
105- {
106- 107- $ password = 'bad-password ' ;
108-
109- $ mutation
110- = <<<MUTATION
111- mutation {
112- generateCustomerToken(
113- email: " {$ email }"
114- password: " {$ password }"
115- ) {
116- token
117- }
118- }
119- MUTATION ;
120-
121- $ this ->graphQlMutation ($ mutation );
122- }
123-
124- /**
125- * Verify customer with empty password
126- *
127- * @magentoApiDataFixture Magento/Customer/_files/customer.php
128- */
129- public function testGenerateCustomerTokenWithInvalidPassword ()
130- {
131- 132- $ password = '' ;
133-
134- $ mutation
135- = <<<MUTATION
136- mutation {
137- generateCustomerToken(
138- email: " {$ email }"
139- password: " {$ password }"
140- ) {
141- token
142- }
143- }
144- MUTATION ;
145-
146- $ this ->expectException (\Exception::class);
147- $ this ->expectExceptionMessage ('GraphQL response contains errors: Specify the "password" value. ' );
148- $ this ->graphQlMutation ($ mutation );
149- }
150-
151- /**
152- * Verify customer with empty password
74+ * Test customer token regeneration.
15375 *
15476 * @magentoApiDataFixture Magento/Customer/_files/customer.php
15577 */
@@ -178,4 +100,36 @@ public function testRegenerateCustomerToken()
178100
179101 $ this ->assertNotEquals ($ token1 , $ token2 , 'Tokens should not be identical! ' );
180102 }
103+
104+ /**
105+ * @return array
106+ */
107+ public function dataProviderCustomerInfo ()
108+ {
109+ return [
110+ 'invalid_email ' => [
111+ 112+ 'password ' ,
113+ 'The account sign-in was incorrect or your account is disabled temporarily. ' .
114+ 'Please wait and try again later. '
115+ ],
116+ 'empty_email ' => [
117+ '' ,
118+ 'password ' ,
119+ 'Specify the "email" value. '
120+ ],
121+ 'invalid_password ' => [
122+ 123+ 'invalid_password ' ,
124+ 'The account sign-in was incorrect or your account is disabled temporarily. ' .
125+ 'Please wait and try again later. '
126+ ],
127+ 'empty_password ' => [
128+ 129+ '' ,
130+ 'Specify the "password" value. '
131+
132+ ]
133+ ];
134+ }
181135}
0 commit comments