Skip to content

Commit 5e2674b

Browse files
committed
ACP2E-3253: GraphQL cart itemsV2 pagination is not working correctly
1 parent 54ad1ab commit 5e2674b

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

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

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99

1010
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
1111
use Magento\Customer\Test\Fixture\Customer;
12-
use Magento\Framework\Exception\AuthenticationException;
13-
use Magento\Framework\Exception\EmailNotConfirmedException;
1412
use Magento\Framework\ObjectManagerInterface;
15-
use Magento\Integration\Api\CustomerTokenServiceInterface;
13+
use Magento\GraphQl\GetCustomerAuthenticationHeader;
1614
use Magento\Quote\Test\Fixture\AddProductToCart;
1715
use Magento\Quote\Test\Fixture\CustomerCart;
1816
use 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
120123
QUERY;
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

Comments
 (0)