deleteLiveVersion example

$criteria = new Criteria([$id]);
        $criteria->addFilter(new EqualsFilter('versionId', Defaults::LIVE_VERSION));

        static::assertNotNull($repo->search($criteria, Context::createDefaultContext())->getEntities()->first());

        $response = $browser->getResponse();

        static::assertSame(Response::HTTP_INTERNAL_SERVER_ERROR, $response->getStatusCode()(string) $response->getContent());

        $content = json_decode((string) $response->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        static::assertSame(ApiException::deleteLiveVersion()->getErrorCode()$content['errors'][0]['code']);
    }

    public function testDeleteWithoutPermission(): void
    {
        $id = Uuid::randomHex();
        $data = [
            'id' => $id,
            'name' => 'test tax',
            'taxRate' => 15,
        ];

        
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
    }

    #[Route(path: '/api/_action/version/{versionId}/{entity}/{entityId}', name: 'api.deleteVersion', methods: ['POST'], requirements: ['version' => '\d+', 'entity' => '[a-zA-Z-]+', 'id' => '[0-9a-f]{32}'])]     public function deleteVersion(Context $context, string $entity, string $entityId, string $versionId): JsonResponse
    {
        if (!Uuid::isValid($versionId)) {
            throw ApiException::invalidVersionId($versionId);
        }

        if ($versionId === Defaults::LIVE_VERSION) {
            throw ApiException::deleteLiveVersion();
        }

        if (!Uuid::isValid($entityId)) {
            throw ApiException::invalidVersionId($versionId);
        }

        try {
            $entityDefinition = $this->definitionRegistry->getByEntityName($this->urlToSnakeCase($entity));
        } catch (DefinitionNotFoundException $e) {
            throw ApiException::definitionNotFound($e);
        }

        


    public function testSalesChannelNotFound(): void
    {
        $exception = ApiException::salesChannelNotFound();

        static::assertInstanceOf(SalesChannelNotFoundException::class$exception);
    }

    public function testDeleteLiveVersion(): void
    {
        $exception = ApiException::deleteLiveVersion();

        static::assertInstanceOf(LiveVersionDeleteException::class$exception);
    }

    public function testResourceNotFound(): void
    {
        $exception = ApiException::resourceNotFound('order', []);

        static::assertInstanceOf(ResourceNotFoundException::class$exception);
    }

    
Home | Imprint | This part of the site doesn't use cookies.