ClassMetaData example



    public function testGroupsAreNullByDefault()
    {
        $constraint = new Valid();

        $this->assertNull($constraint->groups);
    }

    public function testAttributes()
    {
        $metadata = new ClassMetaData(ValidDummy::class);
        $loader = new AttributeLoader();
        self::assertTrue($loader->loadClassMetadata($metadata));

        [$bConstraint] = $metadata->properties['b']->getConstraints();
        self::assertFalse($bConstraint->traverse);
        self::assertSame(['traverse_group']$bConstraint->groups);

        [$cConstraint] = $metadata->properties['c']->getConstraints();
        self::assertSame(['my_group']$cConstraint->groups);
        self::assertSame('some attached data', $cConstraint->payload);
    }
}
Home | Imprint | This part of the site doesn't use cookies.