99
1010use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
1111use Magento \Customer \Test \Fixture \Customer ;
12- use Magento \Framework \Exception \AuthenticationException ;
13- use Magento \Framework \Exception \EmailNotConfirmedException ;
1412use Magento \Framework \ObjectManagerInterface ;
15- use Magento \Integration \ Api \ CustomerTokenServiceInterface ;
13+ use Magento \GraphQl \ GetCustomerAuthenticationHeader ;
1614use Magento \Quote \Test \Fixture \AddProductToCart ;
1715use Magento \Quote \Test \Fixture \CustomerCart ;
1816use Magento \Quote \Test \Fixture \QuoteIdMask as QuoteMaskFixture ;
@@ -30,9 +28,9 @@ class GetCartPaginatedItemsTest extends GraphQlAbstract
3028 private $ objectManager ;
3129
3230 /**
33- * @var CustomerTokenServiceInterface
31+ * @var GetCustomerAuthenticationHeader
3432 */
35- private $ customerTokenService ;
33+ private $ getCustomerAuthenticationHeader ;
3634
3735 /**
3836 * @var DataFixtureStorage
@@ -46,7 +44,7 @@ protected function setUp(): void
4644 {
4745 parent ::setUp ();
4846 $ this ->objectManager = Bootstrap::getObjectManager ();
49- $ this ->customerTokenService = $ this ->objectManager ->get (CustomerTokenServiceInterface ::class);
47+ $ this ->getCustomerAuthenticationHeader = $ this ->objectManager ->get (GetCustomerAuthenticationHeader ::class);
5048 $ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
5149 }
5250
@@ -74,7 +72,12 @@ public function testGetCartPaginatedItems(array $expectedSkus, int $pageSize, in
7472 $ customer = $ this ->fixtures ->get ('customer ' );
7573 $ maskedQuoteId = $ this ->fixtures ->get ('quoteIdMask ' )->getMaskedId ();
7674 $ query = $ this ->getQuery ($ maskedQuoteId , $ pageSize , $ currentPage );
77- $ response = $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ($ customer ->getEmail ()));
75+ $ response = $ this ->graphQlQuery (
76+ $ query ,
77+ [],
78+ '' ,
79+ $ this ->getCustomerAuthenticationHeader ->execute ($ customer ->getEmail (), 'password ' )
80+ );
7881
7982 $ this ->assertArrayNotHasKey ('errors ' , $ response );
8083 $ this ->assertEquals ($ totalCount , $ response ['cart ' ]['itemsV2 ' ]['total_count ' ]);
@@ -120,19 +123,6 @@ private function getQuery(string $maskedQuoteId, int $pageSize, int $currentPage
120123QUERY ;
121124 }
122125
123- /**
124- * @param string $username
125- * @param string $password
126- * @return string[]
127- * @throws AuthenticationException
128- * @throws EmailNotConfirmedException
129- */
130- private function getHeaderMap (string $ username = 'customer@example.com ' , string $ password = 'password ' ): array
131- {
132- $ customerToken = $ this ->customerTokenService ->createCustomerAccessToken ($ username , $ password );
133- return ['Authorization ' => 'Bearer ' . $ customerToken ];
134- }
135-
136126 /**
137127 * @return array
138128 */
0 commit comments