public function testGenerateClass() { $constraint = new Range(array('min' => 10)); $cm = new ClassMetadata(__NAMESPACE__ . '\\TestEntity'); $cm->addPropertyConstraint('field1', $constraint); $this->metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue($cm)); $data = $this->generator->generateClass(__NAMESPACE__ . '\\TestEntity'); $this->assertArrayHasKey('field1', $data); $this->assertArrayHasKey('range', $data['field1']); $this->assertEquals($constraint, $data['field1']['range']); }
/** * Generates a JSON representation of the validation constraints that are * exported to the client-side. * * @return string */ public function getValidationConstraints() { return $this->generator->generate($this->objects); }