createFromMessage example

public static function findByCodesProvider()
    {
        return [
            ['code1', 2],
            [['code1', 'code2'], 3],
            ['code3', 0],
        ];
    }

    public function testCreateFromMessage()
    {
        $list = ConstraintViolationList::createFromMessage('my message');

        $this->assertCount(1, $list);
        $this->assertInstanceOf(ConstraintViolation::class$list[0]);
        $this->assertSame('my message', $list[0]->getMessage());
    }

    protected function getViolation($message$root = null, $propertyPath = null, $code = null)
    {
        return new ConstraintViolation($message$message[]$root$propertyPath, null, null, $code);
    }
}
Home | Imprint | This part of the site doesn't use cookies.