Skip to content

Commit 0375649

Browse files
committed
GraphQL-469: Tests data rollback for \Magento\GraphQl\Customer\CreateCustomerTest::testCreateCustomerAccountWithPassword
1 parent 41b226c commit 0375649

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

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

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
namespace Magento\GraphQl\Customer;
99

1010
use Magento\Customer\Api\CustomerRepositoryInterface;
11-
use Magento\Customer\Model\CustomerRegistry;
11+
use Magento\Framework\Registry;
1212
use Magento\TestFramework\Helper\Bootstrap;
1313
use Magento\TestFramework\TestCase\GraphQlAbstract;
1414

1515
class CreateCustomerTest extends GraphQlAbstract
1616
{
1717
/**
18-
* @var CustomerRegistry
18+
* @var Registry
1919
*/
20-
private $customerRegistry;
20+
private $registry;
2121

2222
/**
2323
* @var CustomerRepositoryInterface
@@ -28,7 +28,7 @@ protected function setUp()
2828
{
2929
parent::setUp();
3030

31-
$this->customerRegistry = Bootstrap::getObjectManager()->get(CustomerRegistry::class);
31+
$this->registry = Bootstrap::getObjectManager()->get(Registry::class);
3232
$this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class);
3333
}
3434

@@ -40,7 +40,7 @@ public function testCreateCustomerAccountWithPassword()
4040
$newFirstname = 'Richard';
4141
$newLastname = 'Rowe';
4242
$currentPassword = 'test123#';
43-
$newEmail = 'customer_created_random123@example.com';
43+
$newEmail = 'new_customer@example.com';
4444

4545
$query = <<<QUERY
4646
mutation {
@@ -50,7 +50,7 @@ public function testCreateCustomerAccountWithPassword()
5050
lastname: "{$newLastname}"
5151
email: "{$newEmail}"
5252
password: "{$currentPassword}"
53-
is_subscribed: true
53+
is_subscribed: true
5454
}
5555
) {
5656
customer {
@@ -78,7 +78,7 @@ public function testCreateCustomerAccountWithoutPassword()
7878
{
7979
$newFirstname = 'Richard';
8080
$newLastname = 'Rowe';
81-
$newEmail = 'customer_created_random123@example.com';
81+
$newEmail = 'new_customer@example.com';
8282

8383
$query = <<<QUERY
8484
mutation {
@@ -87,7 +87,7 @@ public function testCreateCustomerAccountWithoutPassword()
8787
firstname: "{$newFirstname}"
8888
lastname: "{$newLastname}"
8989
email: "{$newEmail}"
90-
is_subscribed: true
90+
is_subscribed: true
9191
}
9292
) {
9393
customer {
@@ -151,7 +151,7 @@ public function testCreateCustomerIfEmailMissed()
151151
firstname: "{$newFirstname}"
152152
lastname: "{$newLastname}"
153153
password: "{$currentPassword}"
154-
is_subscribed: true
154+
is_subscribed: true
155155
}
156156
) {
157157
customer {
@@ -186,7 +186,7 @@ public function testCreateCustomerIfEmailIsNotValid()
186186
lastname: "{$newLastname}"
187187
email: "{$newEmail}"
188188
password: "{$currentPassword}"
189-
is_subscribed: true
189+
is_subscribed: true
190190
}
191191
) {
192192
customer {
@@ -211,7 +211,7 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
211211
$newFirstname = 'Richard';
212212
$newLastname = 'Rowe';
213213
$currentPassword = 'test123#';
214-
$newEmail = 'customer_created_random123@example.com';
214+
$newEmail = 'new_customer@example.com';
215215

216216
$query = <<<QUERY
217217
mutation {
@@ -222,7 +222,7 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
222222
test123: "123test123"
223223
email: "{$newEmail}"
224224
password: "{$currentPassword}"
225-
is_subscribed: true
225+
is_subscribed: true
226226
}
227227
) {
228228
customer {
@@ -240,21 +240,18 @@ public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput()
240240

241241
public function tearDown()
242242
{
243-
$newEmail = 'customer_created_random123@example.com';
243+
$newEmail = 'new_customer@example.com';
244244
try {
245245
$customer = $this->customerRepository->get($newEmail);
246-
247246
} 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;
255248
}
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);
258255
parent::tearDown();
259256
}
260257
}

0 commit comments

Comments
 (0)