コード例 #1
0
 public function testGenerate()
 {
     $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->generate(array(__NAMESPACE__ . '\\TestEntity'));
     $this->assertEquals('{"SimpleThings\\\\JsValidationBundle\\\\Tests\\\\Services\\\\TestEntity":{"field1":{"range":{"minMessage":"This value should be {{ limit }} or more.","maxMessage":"This value should be {{ limit }} or less.","invalidMessage":"This value should be a valid number.","min":10,"max":null,"payload":null,"groups":["Default","TestEntity"]}}}}', $data);
 }
コード例 #2
0
 /**
  * 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);
 }