invalidFilterQuery example


#[Package('core')] class QueryStringParser
{
    /** * @param array<string, mixed> $query */
    public static function fromArray(EntityDefinition $definition, array $query, SearchRequestException $exception, string $path = ''): Filter
    {
        if (empty($query['type'])) {
            throw DataAbstractionLayerException::invalidFilterQuery('Value for filter type is required.');
        }

        switch ($query['type']) {
            case 'equals':
                if (empty($query['field'])) {
                    throw DataAbstractionLayerException::invalidFilterQuery('Parameter "field" for equals filter is missing.', $path . '/field');
                }

                if (!\array_key_exists('value', $query) || $query['value'] === '') {
                    throw DataAbstractionLayerException::invalidFilterQuery('Parameter "value" for equals filter is missing.', $path . '/value');
                }

                

    public function testInvalidLanguageIdLegacy(): void
    {
        $e = DataAbstractionLayerException::invalidLanguageId('foo');

        static::assertInstanceOf(LanguageNotFoundException::class$e);
    }

    public function testInvalidFilterQuery(): void
    {
        $e = DataAbstractionLayerException::invalidFilterQuery('foo', 'baz');

        static::assertInstanceOf(InvalidFilterQueryException::class$e);
        static::assertEquals('foo', $e->getMessage());
        static::assertEquals('baz', $e->getPath());
    }

    public function testCannotCreateNewVersion(): void
    {
        $e = DataAbstractionLayerException::cannotCreateNewVersion('product', 'product-id');

        static::assertEquals(Response::HTTP_BAD_REQUEST, $e->getStatusCode());
        
Home | Imprint | This part of the site doesn't use cookies.