示例#1
0
 public function testIsEmptyReturnsFalseIfAnyFieldIsFilled()
 {
     $form = new Form();
     $field1 = new TestField('foo');
     $field1->setData('baz');
     $field2 = new TestField('bar');
     $field2->setData(null);
     $form->add($field1);
     $form->add($field2);
     $this->assertFalse($form->isEmpty());
 }
示例#2
0
 public function testUpdateObjectDoesNotUpdatePropertyIfPropertyPathIsEmpty()
 {
     $object = new Author();
     $field = new TestField('firstName', array('property_path' => null));
     $field->bind('Bernhard');
     $field->updateObject($object);
     $this->assertEquals(null, $object->firstName);
 }
示例#3
0
 public function testIsTransformationSuccessfulReturnsFalseIfReverseTransformThrowsException()
 {
     // The value is passed to the value transformer
     $transformer = $this->createMockTransformer();
     $transformer->expects($this->once())->method('reverseTransform')->will($this->throwException(new TransformationFailedException()));
     $field = new TestField('title', array('trim' => false, 'value_transformer' => $transformer));
     $field->submit('a');
     $this->assertEquals('a', $field->getDisplayedData());
     $this->assertFalse($field->isTransformationSuccessful());
 }
示例#4
0
 public function testUpdateObjectThrowsExceptionIfGetterIsNotPublic()
 {
     $field = new TestField('privateSetter');
     $field->bind('foobar');
     $this->setExpectedException('Symfony\\Component\\Form\\Exception\\PropertyAccessDeniedException');
     $field->updateObject(new Author());
 }