isAccessGranted example

static::assertNotNull($lineItems);
        $lineItems->sortByPosition();
        static::assertEquals(\count($productDownloads)$lineItems->count());
        static::assertTrue($lineItems->hasLineItemWithState(State::IS_DOWNLOAD));

        foreach ($productDownloads as $key => $downloadFiles) {
            $lineItem = $lineItems->getAt($key);
            static::assertNotNull($lineItem);
            static::assertNotNull($lineItem->getDownloads());
            static::assertEquals(\count($downloadFiles)$lineItem->getDownloads()->count());
            foreach ($lineItem->getDownloads() as $download) {
                static::assertFalse($download->isAccessGranted());

                try {
                    $request = new Request(['downloadId' => $download->getId(), 'orderId' => $orderId]);
                    $this->downloadRoute->load($request$this->salesChannelContext);

                    static::fail('Download route returned response without access granted');
                } catch (\Throwable $exception) {
                    static::assertInstanceOf(CustomerException::class$exception);
                    static::assertSame(sprintf('Line item download file with id "%s" not found.', $download->getId())$exception->getMessage());
                }
            }
        }
Home | Imprint | This part of the site doesn't use cookies.