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());
 }
Beispiel #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);
 }
Beispiel #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());
 }
Beispiel #4
0
 public function testUpdateObjectThrowsExceptionIfGetterIsNotPublic()
 {
     $field = new TestField('privateSetter');
     $field->bind('foobar');
     $this->setExpectedException('Symfony\\Component\\Form\\Exception\\PropertyAccessDeniedException');
     $field->updateObject(new Author());
 }