Skip to content

Commit a08db5e

Browse files
committed
Merge remote-tracking branch 'adobe-commerce-tier-4/ACP2E-3128' into Tier4-Kings-PR-07-24-2024
2 parents 2456e7d + 9a0ba5f commit a08db5e

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,7 @@ private function getQuoteMaskId(int $quoteId): string
9595
*/
9696
private function ensureQuoteMaskExist(int $quoteId): string
9797
{
98-
try {
99-
$maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
100-
} catch (NoSuchEntityException $e) {
101-
$maskedId = '';
102-
}
98+
$maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
10399
if ($maskedId === '') {
104100
$quoteIdMask = $this->quoteIdMaskFactory->create();
105101
$quoteIdMask->setQuoteId($quoteId);

app/code/Magento/QuoteGraphQl/Test/Unit/Model/Resolver/MaskedCartIdTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\QuoteGraphQl\Test\Unit\Model\Resolver;
99

1010
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\Exception\NoSuchEntityException;
1112
use Magento\Framework\GraphQl\Config\Element\Field;
1213
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1314
use Magento\GraphQl\Model\Query\Context;
@@ -16,7 +17,6 @@
1617
use Magento\Quote\Model\QuoteIdMaskFactory;
1718
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
1819
use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask as QuoteIdMaskResourceModel;
19-
use Magento\QuoteGraphQl\Model\Resolver\Cart;
2020
use Magento\QuoteGraphQl\Model\Resolver\MaskedCartId;
2121
use PHPUnit\Framework\MockObject\MockObject;
2222
use PHPUnit\Framework\TestCase;
@@ -134,4 +134,32 @@ public function testResolve(): void
134134
->with($this->quoteIdMask);
135135
$this->maskedCartId->resolve($this->fieldMock, $this->contextMock, $this->resolveInfoMock, $this->valueMock);
136136
}
137+
138+
/**
139+
* @return void
140+
* @throws \Exception
141+
*/
142+
public function testResolveForExceptionWhenQuoteNotExists(): void
143+
{
144+
$this->expectExceptionMessage('Current user does not have an active cart.');
145+
$this->valueMock = ['model' => $this->quoteMock];
146+
$cartId = 0;
147+
$this->quoteIdToMaskedQuoteId->method('execute')->with($cartId)->willThrowException(
148+
new NoSuchEntityException(
149+
__(
150+
'No such entity with %fieldName = %fieldValue',
151+
[
152+
'fieldName' => 'quoteId',
153+
'fieldValue' => $cartId
154+
]
155+
)
156+
)
157+
);
158+
$this->maskedCartId->resolve(
159+
$this->fieldMock,
160+
$this->contextMock,
161+
$this->resolveInfoMock,
162+
$this->valueMock
163+
);
164+
}
137165
}

0 commit comments

Comments
 (0)