@@ -39,11 +39,6 @@ class GraphQlStateTest extends \PHPUnit\Framework\TestCase
3939 /** @var RequestFactory */
4040 private RequestFactory $ requestFactory ;
4141
42- /**
43- * @var CustomerTokenServiceInterface
44- */
45- private CustomerTokenServiceInterface $ customerTokenService ;
46-
4742 /**
4843 * @return void
4944 */
@@ -52,17 +47,26 @@ protected function setUp(): void
5247 $ this ->objectManager = Bootstrap::getObjectManager ();
5348 $ this ->comparator = $ this ->objectManager ->create (Comparator::class);
5449 $ this ->requestFactory = $ this ->objectManager ->get (RequestFactory::class);
55- $ this ->customerTokenService = $ this ->objectManager ->get (CustomerTokenServiceInterface::class);
5650 parent ::setUp ();
5751 }
5852
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+
5965 /**
6066 * Runs various GraphQL queries and checks if state of shared objects in Object Manager have changed
6167 * @magentoConfigFixture base_website btob/website_configuration/company_active 1
6268 * @magentoConfigFixture default_store btob/website_configuration/company_active 1
6369 * @magentoConfigFixture default_store company/general/allow_company_registration 1
64- * @magentoDataFixture Magento/Customer/_files/customer.php
65- * @magentoDataFixture Magento/Customer/_files/customer_address.php
6670 * @dataProvider queryDataProvider
6771 * @param string $query
6872 * @param array $variables
@@ -134,7 +138,8 @@ private function doRequest(string $query, array $authInfo)
134138 if ($ authInfo ) {
135139 $ email = $ authInfo ['email ' ];
136140 $ password = $ authInfo ['password ' ];
137- $ customerToken = $ this ->customerTokenService ->createCustomerAccessToken ($ email , $ password );
141+ $ customerToken = $ this ->objectManager ->get (CustomerTokenServiceInterface::class)
142+ ->createCustomerAccessToken ($ email , $ password );
138143 $ request ->getHeaders ()->addHeaders (['Authorization ' => 'Bearer ' . $ customerToken ]);
139144 }
140145 $ unusedResponse = $ this ->objectManager ->create (HttpResponse::class);
@@ -372,7 +377,17 @@ public function queryDataProvider(): array
372377 'resolveUrl ' ,
373378 '"type":"CMS_PAGE","id":1 '
374379 ],
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 [
376391 'Create Customer ' => [
377392 <<<'QUERY'
378393 mutation($firstname: String!, $lastname: String!, $email: String!, $password: String!) {
@@ -433,11 +448,11 @@ public function queryDataProvider(): array
433448 }
434449 }
435450 QUERY,
436- ['allow ' => true ],
437- ['allow ' => false ],
438- ['email ' => 'customer@example.com ' , 'password ' => 'password ' ],
439- 'updateCustomer ' ,
440- 'allow_remote_shopping_assistance '
451+ ['allow ' => true ],
452+ ['allow ' => false ],
453+ ['email ' => 'customer@example.com ' , 'password ' => 'password ' ],
454+ 'updateCustomer ' ,
455+ 'allow_remote_shopping_assistance '
441456 ],
442457 'Update Customer Address ' => [
443458 <<<'QUERY'
@@ -492,8 +507,8 @@ public function queryDataProvider(): array
492507 ['addressId ' => 1 , 'city ' => 'New York ' ],
493508 ['addressId ' => 1 , 'city ' => 'Austin ' ],
494509 ['email ' => 'customer@example.com ' , 'password ' => 'password ' ],
495- 'updateCustomerAddress ' ,
496- 'city '
510+ 'updateCustomerAddress ' ,
511+ 'city '
497512 ],
498513 'Update Customer Email ' => [
499514 <<<'QUERY'
@@ -528,7 +543,6 @@ public function queryDataProvider(): array
528543 'generateCustomerToken ' ,
529544 'token '
530545 ]
531-
532546 ];
533547 }
534548}
0 commit comments