@@ -24,17 +24,7 @@ public function testGenerateCustomerValidToken()
24
24
$ email = 'customer@example.com ' ;
25
25
$ password = 'password ' ;
26
26
27
- $ mutation
28
- = <<<MUTATION
29
- mutation {
30
- generateCustomerToken(
31
- email: " {$ email }"
32
- password: " {$ password }"
33
- ) {
34
- token
35
- }
36
- }
37
- MUTATION ;
27
+ $ mutation = $ this ->getQuery ($ email , $ password );
38
28
39
29
$ response = $ this ->graphQlMutation ($ mutation );
40
30
$ this ->assertArrayHasKey ('generateCustomerToken ' , $ response );
@@ -52,19 +42,9 @@ public function testGenerateCustomerValidToken()
52
42
* @param string $password
53
43
* @param string $message
54
44
*/
55
- public function testGenerateCustomerTokenNegativeCases (string $ email , string $ password , string $ message )
45
+ public function testGenerateCustomerTokenInvalidData (string $ email , string $ password , string $ message )
56
46
{
57
- $ mutation
58
- = <<<MUTATION
59
- mutation {
60
- generateCustomerToken(
61
- email: " {$ email }"
62
- password: " {$ password }"
63
- ) {
64
- token
65
- }
66
- }
67
- MUTATION ;
47
+ $ mutation = $ this ->getQuery ($ email , $ password );
68
48
$ this ->expectExceptionMessage ($ message );
69
49
$ this ->graphQlMutation ($ mutation );
70
50
}
@@ -79,17 +59,7 @@ public function testRegenerateCustomerToken()
79
59
$ email = 'customer@example.com ' ;
80
60
$ password = 'password ' ;
81
61
82
- $ mutation
83
- = <<<MUTATION
84
- mutation {
85
- generateCustomerToken(
86
- email: " {$ email }"
87
- password: " {$ password }"
88
- ) {
89
- token
90
- }
91
- }
92
- MUTATION ;
62
+ $ mutation = $ this ->getQuery ($ email , $ password );
93
63
94
64
$ response1 = $ this ->graphQlMutation ($ mutation );
95
65
$ token1 = $ response1 ['generateCustomerToken ' ]['token ' ];
@@ -131,4 +101,22 @@ public function dataProviderInvalidCustomerInfo(): array
131
101
]
132
102
];
133
103
}
104
+
105
+ /**
106
+ * @param string $email
107
+ * @param string $password
108
+ * @return string
109
+ */
110
+ private function getQuery (string $ email , string $ password ) : string {
111
+ return <<<MUTATION
112
+ mutation {
113
+ generateCustomerToken(
114
+ email: " {$ email }"
115
+ password: " {$ password }"
116
+ ) {
117
+ token
118
+ }
119
+ }
120
+ MUTATION ;
121
+ }
134
122
}
0 commit comments