longitude-one/doctrine-spatial

First parameter of point constructor could be an array, but arguments of this array aren't count.

Alexandre-T opened this issue · 0 comments

If the first argument of point constructor is an array, but the number of its elements aren't checked.

These tests fail:

    /**
     * Test argument 1 with too many values - Two invalid parameters.
     *
     * @param class-string<AbstractPoint> $abstractPoint
     */
    #[DataProvider('pointTypeProvider')]
    public function testInvalidArrayWithTooManyValues(string $abstractPoint): void
    {
        $this->expectException(InvalidValueException::class);
        $this->expectExceptionMessage(sprintf('Invalid parameters passed to %s::__construct: array(1, 2, 3, 4)', $abstractPoint));

        new $abstractPoint([1,2,3,4]);
    }

    /**
     * Test argument 1 with too few values - Two invalid parameters.
     *
     * @param class-string<AbstractPoint> $abstractPoint
     */
    #[DataProvider('pointTypeProvider')]
    public function testInvalidArrayWithTooFewValues(string $abstractPoint): void
    {
        $this->expectException(InvalidValueException::class);
        $this->expectExceptionMessage(sprintf('Invalid parameters passed to %s::__construct: array(1)', $abstractPoint));

        new $abstractPoint([1]);
    }