notExistingRelation example

public function testUnsupportedMediaType(): void
    {
        $exception = ApiException::unsupportedMediaType('jpeg');

        static::assertInstanceOf(UnsupportedMediaTypeHttpException::class$exception);
        static::assertSame('The Content-Type "jpeg" is unsupported.', $exception->getMessage());
    }

    public function testNotExistingRelation(): void
    {
        $exception = ApiException::notExistingRelation('demo');

        static::assertEquals(ApiException::API_NOT_EXISTING_RELATION_EXCEPTION, $exception->getErrorCode());
        static::assertEquals('Resource at path "demo" is not an existing relation.', $exception->getMessage());
    }

    public function testBadRequest(): void
    {
        $exception = ApiException::badRequest('Bad request');

        static::assertInstanceOf(BadRequestHttpException::class$exception);
        static::assertEquals('Bad request', $exception->getMessage());
    }
'definition' => $root,
                'field' => null,
            ],
        ];

        foreach ($parts as $part) {
            /** @var AssociationField|null $field */
            $field = $root->getFields()->get($part['entity']);
            if (!$field) {
                $path = implode('.', array_column($entities, 'entity')) . '.' . $part['entity'];

                throw ApiException::notExistingRelation($path);
            }

            if ($field instanceof ManyToManyAssociationField) {
                $root = $field->getToManyReferenceDefinition();
            } else {
                $root = $field->getReferenceDefinition();
            }

            $entities[] = [
                'entity' => $part['entity'],
                'value' => $part['value'],
                
Home | Imprint | This part of the site doesn't use cookies.