@@ -39,11 +39,6 @@ class GraphQlStateTest extends \PHPUnit\Framework\TestCase
39
39
/** @var RequestFactory */
40
40
private RequestFactory $ requestFactory ;
41
41
42
- /**
43
- * @var CustomerTokenServiceInterface
44
- */
45
- private CustomerTokenServiceInterface $ customerTokenService ;
46
-
47
42
/**
48
43
* @return void
49
44
*/
@@ -52,17 +47,26 @@ protected function setUp(): void
52
47
$ this ->objectManager = Bootstrap::getObjectManager ();
53
48
$ this ->comparator = $ this ->objectManager ->create (Comparator::class);
54
49
$ this ->requestFactory = $ this ->objectManager ->get (RequestFactory::class);
55
- $ this ->customerTokenService = $ this ->objectManager ->get (CustomerTokenServiceInterface::class);
56
50
parent ::setUp ();
57
51
}
58
52
53
+ /**
54
+ * @magentoDataFixture Magento/Customer/_files/customer.php
55
+ * @magentoDataFixture Magento/Customer/_files/customer_address.php
56
+ * @dataProvider customerDataProvider
57
+ * @return void
58
+ * @throws \Exception
59
+ */
60
+ public function testCustomerState (string $ query , array $ variables , array $ variables2 , array $ authInfo , string $ operationName , string $ expected )
61
+ {
62
+ $ this ->testState ($ query , $ variables , $ variables2 , $ authInfo , $ operationName , $ expected );
63
+ }
64
+
59
65
/**
60
66
* Runs various GraphQL queries and checks if state of shared objects in Object Manager have changed
61
67
* @magentoConfigFixture base_website btob/website_configuration/company_active 1
62
68
* @magentoConfigFixture default_store btob/website_configuration/company_active 1
63
69
* @magentoConfigFixture default_store company/general/allow_company_registration 1
64
- * @magentoDataFixture Magento/Customer/_files/customer.php
65
- * @magentoDataFixture Magento/Customer/_files/customer_address.php
66
70
* @dataProvider queryDataProvider
67
71
* @param string $query
68
72
* @param array $variables
@@ -134,7 +138,8 @@ private function doRequest(string $query, array $authInfo)
134
138
if ($ authInfo ) {
135
139
$ email = $ authInfo ['email ' ];
136
140
$ password = $ authInfo ['password ' ];
137
- $ customerToken = $ this ->customerTokenService ->createCustomerAccessToken ($ email , $ password );
141
+ $ customerToken = $ this ->objectManager ->get (CustomerTokenServiceInterface::class)
142
+ ->createCustomerAccessToken ($ email , $ password );
138
143
$ request ->getHeaders ()->addHeaders (['Authorization ' => 'Bearer ' . $ customerToken ]);
139
144
}
140
145
$ unusedResponse = $ this ->objectManager ->create (HttpResponse::class);
@@ -372,7 +377,17 @@ public function queryDataProvider(): array
372
377
'resolveUrl ' ,
373
378
'"type":"CMS_PAGE","id":1 '
374
379
],
375
- # Customer Scenarios
380
+ ];
381
+ }
382
+ /**
383
+ * Queries, variables, operation names, and expected responses for test
384
+ *
385
+ * @return array[]
386
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
387
+ */
388
+ public function customerDataProvider (): array
389
+ {
390
+ return [
376
391
'Create Customer ' => [
377
392
<<<'QUERY'
378
393
mutation($firstname: String!, $lastname: String!, $email: String!, $password: String!) {
@@ -433,11 +448,11 @@ public function queryDataProvider(): array
433
448
}
434
449
}
435
450
QUERY,
436
- ['allow ' => true ],
437
- ['allow ' => false ],
438
- [
'email ' =>
'[email protected] ' ,
'password ' =>
'password ' ],
439
- 'updateCustomer ' ,
440
- 'allow_remote_shopping_assistance '
451
+ ['allow ' => true ],
452
+ ['allow ' => false ],
453
+ [
'email ' =>
'[email protected] ' ,
'password ' =>
'password ' ],
454
+ 'updateCustomer ' ,
455
+ 'allow_remote_shopping_assistance '
441
456
],
442
457
'Update Customer Address ' => [
443
458
<<<'QUERY'
@@ -492,8 +507,8 @@ public function queryDataProvider(): array
492
507
['addressId ' => 1 , 'city ' => 'New York ' ],
493
508
['addressId ' => 1 , 'city ' => 'Austin ' ],
494
509
[
'email ' =>
'[email protected] ' ,
'password ' =>
'password ' ],
495
- 'updateCustomerAddress ' ,
496
- 'city '
510
+ 'updateCustomerAddress ' ,
511
+ 'city '
497
512
],
498
513
'Update Customer Email ' => [
499
514
<<<'QUERY'
@@ -528,7 +543,6 @@ public function queryDataProvider(): array
528
543
'generateCustomerToken ' ,
529
544
'token '
530
545
]
531
-
532
546
];
533
547
}
534
548
}
0 commit comments