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());
 }
Example #2
0
 public function testValuesAreTransformedCorrectly()
 {
     // The value is first passed to the normalization transformer...
     $normTransformer = $this->createMockTransformer();
     $normTransformer->expects($this->exactly(2))->method('transform')->will($this->returnValue('norm[0]'));
     // ...and then to the value transformer
     $valueTransformer = $this->createMockTransformer();
     $valueTransformer->expects($this->exactly(2))->method('transform')->will($this->returnValue('transform[norm[0]]'));
     $field = new TestField('title', array('value_transformer' => $valueTransformer, 'normalization_transformer' => $normTransformer));
     $field->setData(0);
     $this->assertEquals(0, $field->getData());
     $this->assertEquals('norm[0]', $field->getNormalizedData());
     $this->assertEquals('transform[norm[0]]', $field->getDisplayedData());
 }