6 declare(strict_types=1);
29 private $objectManager;
34 private $guestCartRepository;
39 $this->quoteIdMask = $this->objectManager->create(QuoteIdMask::class);
40 $this->guestCartRepository = $this->objectManager->create(GuestCartRepositoryInterface::class);
43 public function testCreateEmptyCartForGuest()
52 self::assertArrayHasKey(
'createEmptyCart',
$response);
54 $maskedCartId =
$response[
'createEmptyCart'];
56 $guestCart = $this->guestCartRepository->get($maskedCartId);
58 self::assertNotNull($guestCart->getId());
59 self::assertNull($guestCart->getCustomer()->getId());
65 public function testCreateEmptyCartForRegisteredCustomer()
74 $customerTokenService = $this->objectManager->create(
75 \
Magento\Integration\Api\CustomerTokenServiceInterface::class
77 $customerToken = $customerTokenService->createCustomerAccessToken(
'[email protected]',
'password');
78 $headerMap = [
'Authorization' =>
'Bearer ' . $customerToken];
82 self::assertArrayHasKey(
'createEmptyCart',
$response);
84 $maskedCartId =
$response[
'createEmptyCart'];
86 $guestCart = $this->guestCartRepository->get($maskedCartId);
88 self::assertNotNull($guestCart->getId());
89 self::assertEquals(1, $guestCart->getCustomer()->getId());
graphQlQuery(string $query, array $variables=[], string $operationName='', array $headers=[])
static getObjectManager()