8
8
namespace Magento \GraphQl \Customer ;
9
9
10
10
use Magento \Customer \Api \CustomerRepositoryInterface ;
11
- use Magento \Customer \ Model \ CustomerRegistry ;
11
+ use Magento \Framework \ Registry ;
12
12
use Magento \TestFramework \Helper \Bootstrap ;
13
13
use Magento \TestFramework \TestCase \GraphQlAbstract ;
14
14
15
15
class CreateCustomerTest extends GraphQlAbstract
16
16
{
17
17
/**
18
- * @var CustomerRegistry
18
+ * @var Registry
19
19
*/
20
- private $ customerRegistry ;
20
+ private $ registry ;
21
21
22
22
/**
23
23
* @var CustomerRepositoryInterface
@@ -28,7 +28,7 @@ protected function setUp()
28
28
{
29
29
parent ::setUp ();
30
30
31
- $ this ->customerRegistry = Bootstrap::getObjectManager ()->get (CustomerRegistry ::class);
31
+ $ this ->registry = Bootstrap::getObjectManager ()->get (Registry ::class);
32
32
$ this ->customerRepository = Bootstrap::getObjectManager ()->get (CustomerRepositoryInterface::class);
33
33
}
34
34
@@ -40,7 +40,7 @@ public function testCreateCustomerAccountWithPassword()
40
40
$ newFirstname = 'Richard ' ;
41
41
$ newLastname = 'Rowe ' ;
42
42
$ currentPassword = 'test123# ' ;
43
- $ newEmail = 'customer_created_random123 @example.com ' ;
43
+ $ newEmail = 'new_customer @example.com ' ;
44
44
45
45
$ query = <<<QUERY
46
46
mutation {
@@ -50,7 +50,7 @@ public function testCreateCustomerAccountWithPassword()
50
50
lastname: " {$ newLastname }"
51
51
email: " {$ newEmail }"
52
52
password: " {$ currentPassword }"
53
- is_subscribed: true
53
+ is_subscribed: true
54
54
}
55
55
) {
56
56
customer {
@@ -78,7 +78,7 @@ public function testCreateCustomerAccountWithoutPassword()
78
78
{
79
79
$ newFirstname = 'Richard ' ;
80
80
$ newLastname = 'Rowe ' ;
81
- $ newEmail = 'customer_created_random123 @example.com ' ;
81
+ $ newEmail = 'new_customer @example.com ' ;
82
82
83
83
$ query = <<<QUERY
84
84
mutation {
@@ -87,7 +87,7 @@ public function testCreateCustomerAccountWithoutPassword()
87
87
firstname: " {$ newFirstname }"
88
88
lastname: " {$ newLastname }"
89
89
email: " {$ newEmail }"
90
- is_subscribed: true
90
+ is_subscribed: true
91
91
}
92
92
) {
93
93
customer {
@@ -151,7 +151,7 @@ public function testCreateCustomerIfEmailMissed()
151
151
firstname: " {$ newFirstname }"
152
152
lastname: " {$ newLastname }"
153
153
password: " {$ currentPassword }"
154
- is_subscribed: true
154
+ is_subscribed: true
155
155
}
156
156
) {
157
157
customer {
@@ -186,7 +186,7 @@ public function testCreateCustomerIfEmailIsNotValid()
186
186
lastname: " {$ newLastname }"
187
187
email: " {$ newEmail }"
188
188
password: " {$ currentPassword }"
189
- is_subscribed: true
189
+ is_subscribed: true
190
190
}
191
191
) {
192
192
customer {
@@ -211,7 +211,7 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
211
211
$ newFirstname = 'Richard ' ;
212
212
$ newLastname = 'Rowe ' ;
213
213
$ currentPassword = 'test123# ' ;
214
- $ newEmail = 'customer_created_random123 @example.com ' ;
214
+ $ newEmail = 'new_customer @example.com ' ;
215
215
216
216
$ query = <<<QUERY
217
217
mutation {
@@ -222,7 +222,7 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
222
222
test123: "123test123"
223
223
email: " {$ newEmail }"
224
224
password: " {$ currentPassword }"
225
- is_subscribed: true
225
+ is_subscribed: true
226
226
}
227
227
) {
228
228
customer {
@@ -240,21 +240,18 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
240
240
241
241
public function tearDown ()
242
242
{
243
- $ newEmail = 'customer_created_random123 @example.com ' ;
243
+ $ newEmail = 'new_customer @example.com ' ;
244
244
try {
245
245
$ customer = $ this ->customerRepository ->get ($ newEmail );
246
-
247
246
} catch (\Exception $ exception ) {
248
- return false ;
249
- }
250
- $ registry = Bootstrap::getObjectManager ()->get (\Magento \Framework \Registry::class);
251
- $ registry ->unregister ('isSecureArea ' );
252
- $ registry ->register ('isSecureArea ' , true );
253
- if (isset ($ customer ) && $ customer ->getId ()) {
254
- $ this ->customerRepository ->delete ($ customer );
247
+ return ;
255
248
}
256
- $ registry ->unregister ('isSecureArea ' );
257
- $ registry ->register ('isSecureArea ' , false );
249
+
250
+ $ this ->registry ->unregister ('isSecureArea ' );
251
+ $ this ->registry ->register ('isSecureArea ' , true );
252
+ $ this ->customerRepository ->delete ($ customer );
253
+ $ this ->registry ->unregister ('isSecureArea ' );
254
+ $ this ->registry ->register ('isSecureArea ' , false );
258
255
parent ::tearDown ();
259
256
}
260
257
}
0 commit comments