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