9
9
10
10
use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
11
11
use Magento \Customer \Test \Fixture \Customer ;
12
- use Magento \Framework \Exception \AuthenticationException ;
13
- use Magento \Framework \Exception \EmailNotConfirmedException ;
14
12
use Magento \Framework \ObjectManagerInterface ;
15
- use Magento \Integration \ Api \ CustomerTokenServiceInterface ;
13
+ use Magento \GraphQl \ GetCustomerAuthenticationHeader ;
16
14
use Magento \Quote \Test \Fixture \AddProductToCart ;
17
15
use Magento \Quote \Test \Fixture \CustomerCart ;
18
16
use Magento \Quote \Test \Fixture \QuoteIdMask as QuoteMaskFixture ;
@@ -30,9 +28,9 @@ class GetCartPaginatedItemsTest extends GraphQlAbstract
30
28
private $ objectManager ;
31
29
32
30
/**
33
- * @var CustomerTokenServiceInterface
31
+ * @var GetCustomerAuthenticationHeader
34
32
*/
35
- private $ customerTokenService ;
33
+ private $ getCustomerAuthenticationHeader ;
36
34
37
35
/**
38
36
* @var DataFixtureStorage
@@ -46,7 +44,7 @@ protected function setUp(): void
46
44
{
47
45
parent ::setUp ();
48
46
$ this ->objectManager = Bootstrap::getObjectManager ();
49
- $ this ->customerTokenService = $ this ->objectManager ->get (CustomerTokenServiceInterface ::class);
47
+ $ this ->getCustomerAuthenticationHeader = $ this ->objectManager ->get (GetCustomerAuthenticationHeader ::class);
50
48
$ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
51
49
}
52
50
@@ -74,7 +72,12 @@ public function testGetCartPaginatedItems(array $expectedSkus, int $pageSize, in
74
72
$ customer = $ this ->fixtures ->get ('customer ' );
75
73
$ maskedQuoteId = $ this ->fixtures ->get ('quoteIdMask ' )->getMaskedId ();
76
74
$ 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
+ );
78
81
79
82
$ this ->assertArrayNotHasKey ('errors ' , $ response );
80
83
$ this ->assertEquals ($ totalCount , $ response ['cart ' ]['itemsV2 ' ]['total_count ' ]);
@@ -120,19 +123,6 @@ private function getQuery(string $maskedQuoteId, int $pageSize, int $currentPage
120
123
QUERY ;
121
124
}
122
125
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
-
136
126
/**
137
127
* @return array
138
128
*/
0 commit comments