|
8 | 8 | namespace Magento\QuoteGraphQl\Test\Unit\Model\Resolver;
|
9 | 9 |
|
10 | 10 | use Magento\Framework\Exception\LocalizedException;
|
| 11 | +use Magento\Framework\Exception\NoSuchEntityException; |
11 | 12 | use Magento\Framework\GraphQl\Config\Element\Field;
|
12 | 13 | use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
|
13 | 14 | use Magento\GraphQl\Model\Query\Context;
|
|
16 | 17 | use Magento\Quote\Model\QuoteIdMaskFactory;
|
17 | 18 | use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
|
18 | 19 | use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask as QuoteIdMaskResourceModel;
|
19 |
| -use Magento\QuoteGraphQl\Model\Resolver\Cart; |
20 | 20 | use Magento\QuoteGraphQl\Model\Resolver\MaskedCartId;
|
21 | 21 | use PHPUnit\Framework\MockObject\MockObject;
|
22 | 22 | use PHPUnit\Framework\TestCase;
|
@@ -134,4 +134,32 @@ public function testResolve(): void
|
134 | 134 | ->with($this->quoteIdMask);
|
135 | 135 | $this->maskedCartId->resolve($this->fieldMock, $this->contextMock, $this->resolveInfoMock, $this->valueMock);
|
136 | 136 | }
|
| 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 | + } |
137 | 165 | }
|
0 commit comments