|
12 | 12 | use Shopware\Core\Checkout\Cart\LineItem\LineItemCollection; |
13 | 13 | use Shopware\Core\Checkout\Cart\SalesChannel\CartService; |
14 | 14 | use Shopware\Core\Checkout\Customer\CustomerEntity; |
15 | | -use Shopware\Core\Checkout\Payment\Cart\PaymentHandler\PrePayment; |
16 | 15 | use Shopware\Core\Content\Product\Aggregate\ProductVisibility\ProductVisibilityDefinition; |
17 | 16 | use Shopware\Core\Defaults; |
18 | 17 | use Shopware\Core\Framework\Context; |
19 | | -use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface; |
20 | 18 | use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; |
21 | | -use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; |
22 | 19 | use Shopware\Core\Framework\Feature; |
23 | 20 | use Shopware\Core\Framework\Test\TestCaseBase\IntegrationTestBehaviour; |
24 | 21 | use Shopware\Core\Framework\Util\Random; |
|
33 | 30 | use Shopware\Core\Test\TestDefaults; |
34 | 31 | use Symfony\Component\EventDispatcher\EventDispatcher; |
35 | 32 | use Symfony\Contracts\EventDispatcher\Event; |
| 33 | +use function json_encode; |
36 | 34 |
|
37 | 35 | class CartRestorerTest extends TestCase |
38 | 36 | { |
@@ -325,33 +323,25 @@ public function testCartMergedEventIsFiredWithCustomerCart(): void |
325 | 323 | static::assertEquals(5, $p2->getQuantity()); |
326 | 324 | } |
327 | 325 |
|
328 | | - private function getStateId(string $state, string $machine) |
| 326 | + public function testPermissionsAreIgnoredOnRestoer(): void |
329 | 327 | { |
330 | | - return $this->getContainer()->get(Connection::class) |
331 | | - ->fetchColumn(' |
332 | | - SELECT LOWER(HEX(state_machine_state.id)) |
333 | | - FROM state_machine_state |
334 | | - INNER JOIN state_machine |
335 | | - ON state_machine.id = state_machine_state.state_machine_id |
336 | | - AND state_machine.technical_name = :machine |
337 | | - WHERE state_machine_state.technical_name = :state |
338 | | - ', [ |
339 | | - 'state' => $state, |
340 | | - 'machine' => $machine, |
341 | | - ]); |
342 | | - } |
| 328 | + $currentContextToken = Random::getAlphanumericString(32); |
343 | 329 |
|
344 | | - private function getPrePaymentMethodId(): string |
345 | | - { |
346 | | - /** @var EntityRepositoryInterface $repository */ |
347 | | - $repository = $this->getContainer()->get('payment_method.repository'); |
| 330 | + $currentContext = $this->createSalesChannelContext($currentContextToken, []); |
348 | 331 |
|
349 | | - $criteria = (new Criteria()) |
350 | | - ->setLimit(1) |
351 | | - ->addFilter(new EqualsFilter('active', true)) |
352 | | - ->addFilter(new EqualsFilter('handlerIdentifier', PrePayment::class)); |
| 332 | + $con = $this->getContainer()->get(Connection::class); |
| 333 | + |
| 334 | + $con->insert('sales_channel_api_context', [ |
| 335 | + 'token' => Random::getAlphanumericString(32), |
| 336 | + 'payload' => json_encode(['expired' => false, 'customerId' => $this->customerId, 'permissions' => ['foo']], \JSON_THROW_ON_ERROR), |
| 337 | + 'sales_channel_id' => Uuid::fromHexToBytes($currentContext->getSalesChannelId()), |
| 338 | + 'customer_id' => Uuid::fromHexToBytes($this->customerId), |
| 339 | + 'updated_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT), |
| 340 | + ]); |
| 341 | + |
| 342 | + $restoreContext = $this->cartRestorer->restore($this->customerId, $currentContext); |
353 | 343 |
|
354 | | - return $repository->searchIds($criteria, Context::createDefaultContext())->getIds()[0]; |
| 344 | + static::assertSame([], $restoreContext->getPermissions()); |
355 | 345 | } |
356 | 346 |
|
357 | 347 | private function createProduct(Context $context): string |
|
0 commit comments