Skip to content

Commit 41b226c

Browse files
committed
Merge remote-tracking branch 'XxXgeoXxX/2.3-develop#469' into 2.3-develop#469
2 parents b96e65c + f265584 commit 41b226c

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

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

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ class CreateCustomerTest extends GraphQlAbstract
2424
*/
2525
private $customerRepository;
2626

27-
/**
28-
* @var null|string
29-
*/
30-
private $customerRandomEmail = null;
31-
3227
protected function setUp()
3328
{
3429
parent::setUp();
@@ -45,15 +40,15 @@ public function testCreateCustomerAccountWithPassword()
4540
$newFirstname = 'Richard';
4641
$newLastname = 'Rowe';
4742
$currentPassword = 'test123#';
48-
$this->customerRandomEmail = 'customer_created' . rand(1, 2000000) . '@example.com';
43+
$newEmail = 'customer_created_random123@example.com';
4944

5045
$query = <<<QUERY
5146
mutation {
5247
createCustomer(
5348
input: {
5449
firstname: "{$newFirstname}"
5550
lastname: "{$newLastname}"
56-
email: "{$this->customerRandomEmail}"
51+
email: "{$newEmail}"
5752
password: "{$currentPassword}"
5853
is_subscribed: true
5954
}
@@ -72,7 +67,7 @@ public function testCreateCustomerAccountWithPassword()
7267

7368
$this->assertEquals($newFirstname, $response['createCustomer']['customer']['firstname']);
7469
$this->assertEquals($newLastname, $response['createCustomer']['customer']['lastname']);
75-
$this->assertEquals($this->customerRandomEmail, $response['createCustomer']['customer']['email']);
70+
$this->assertEquals($newEmail, $response['createCustomer']['customer']['email']);
7671
$this->assertEquals(true, $response['createCustomer']['customer']['is_subscribed']);
7772
}
7873

@@ -83,15 +78,15 @@ public function testCreateCustomerAccountWithoutPassword()
8378
{
8479
$newFirstname = 'Richard';
8580
$newLastname = 'Rowe';
86-
$this->customerRandomEmail = 'customer_created' . rand(1, 2000000) . '@example.com';
81+
$newEmail = 'customer_created_random123@example.com';
8782

8883
$query = <<<QUERY
8984
mutation {
9085
createCustomer(
9186
input: {
9287
firstname: "{$newFirstname}"
9388
lastname: "{$newLastname}"
94-
email: "{$this->customerRandomEmail}"
89+
email: "{$newEmail}"
9590
is_subscribed: true
9691
}
9792
) {
@@ -109,7 +104,7 @@ public function testCreateCustomerAccountWithoutPassword()
109104

110105
$this->assertEquals($newFirstname, $response['createCustomer']['customer']['firstname']);
111106
$this->assertEquals($newLastname, $response['createCustomer']['customer']['lastname']);
112-
$this->assertEquals($this->customerRandomEmail, $response['createCustomer']['customer']['email']);
107+
$this->assertEquals($newEmail, $response['createCustomer']['customer']['email']);
113108
$this->assertEquals(true, $response['createCustomer']['customer']['is_subscribed']);
114109
}
115110

@@ -216,7 +211,7 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
216211
$newFirstname = 'Richard';
217212
$newLastname = 'Rowe';
218213
$currentPassword = 'test123#';
219-
$newEmail = 'customer_created' . rand(1, 2000000) . '@example.com';
214+
$newEmail = 'customer_created_random123@example.com';
220215

221216
$query = <<<QUERY
222217
mutation {
@@ -245,17 +240,21 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
245240

246241
public function tearDown()
247242
{
248-
if ($this->customerRandomEmail !== null) {
249-
$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
250-
$registry->unregister('isSecureArea');
251-
$registry->register('isSecureArea', true);
252-
$customer = $this->customerRepository->get($this->customerRandomEmail);
253-
if (isset($customer) && $customer->getId()) {
254-
$this->customerRepository->delete($customer);
255-
}
256-
$registry->unregister('isSecureArea');
257-
$registry->register('isSecureArea', false);
243+
$newEmail = 'customer_created_random123@example.com';
244+
try {
245+
$customer = $this->customerRepository->get($newEmail);
246+
247+
} 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);
258255
}
256+
$registry->unregister('isSecureArea');
257+
$registry->register('isSecureArea', false);
259258
parent::tearDown();
260259
}
261260
}

0 commit comments

Comments
 (0)