invalidCriteriaIds example

/** * @param array<string>|array<array<string, string>>|null $ids */
    public function __construct(?array $ids = null)
    {
        if ($ids === null) {
            return;
        }

        $ids = array_filter($ids);
        if (empty($ids)) {
            throw DataAbstractionLayerException::invalidCriteriaIds($ids, 'Ids should not be empty');
        }
        $this->validateIds($ids);

        $this->ids = $ids;
    }

    public function __toString(): string
    {
        $parsed = (new CriteriaArrayConverter(new AggregationParser()))->convert($this);

        return Json::encode($parsed);
    }

    public function testInvalidSerializerFieldLegacy(): void
    {
        $e = DataAbstractionLayerException::invalidSerializerField(FkField::classnew IdField('foo', 'foo'));

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

    public function testInvalidCriteriaIds(): void
    {
        $e = DataAbstractionLayerException::invalidCriteriaIds(['foo'], 'bar');

        static::assertSame(Response::HTTP_INTERNAL_SERVER_ERROR, $e->getStatusCode());
        static::assertSame(DataAbstractionLayerException::INVALID_CRITERIA_IDS, $e->getErrorCode());
    }

    public function testInvalidApiCriteriaIds(): void
    {
        $e = DataAbstractionLayerException::invalidApiCriteriaIds(
            DataAbstractionLayerException::invalidCriteriaIds(['foo'], 'bar')
        );

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