public function testFormInitialState() { // check the form properties foreach ($this->_formProperties as $propertyName => $propertyValue) { $this->assertEquals(true, $this->_form->hasAttribute($propertyName), "Form has no property {$propertyName} element"); $this->assertEquals($propertyValue, $this->_form->getAttribute($propertyName), "Form property {$propertyName} doesn't match {$propertyValue}"); } foreach ($this->_formFields as $fieldName => $properties) { $this->assertEquals(true, $this->_form->has($fieldName), "Form missing element '{$fieldName}'"); foreach ($properties as $propertyName => $propertyValue) { switch ($propertyName) { case 'type': $this->assertEquals($propertyValue, $this->_form->get($fieldName)->getAttribute('type'), "field {$fieldName} should have been of type: " . $this->_form->get($fieldName)->getAttribute('type')); break; case 'value': $this->assertEquals($propertyValue, $this->_form->get($fieldName)->getValue(), "field {$fieldName} should have value: " . $this->_form->get($fieldName)->getValue()); break; case 'label': $this->assertEquals($propertyValue, $this->_form->get($fieldName)->getLabel(), "field {$fieldName} should have label matching: " . $this->_form->get($fieldName)->getLabel()); break; case 'placeholder': $this->assertEquals($propertyValue, $this->_form->get($fieldName)->getAttribute('placeholder'), "field {$fieldName} should placeholder matching: {$propertyValue}"); break; } } } }
public function testFormElementsMoves() { $this->assertTrue(is_array($this->object->elements())); $this->assertFalse($this->object->has('test')); $element = new Elements\Text('test'); $element2 = new Elements\Text('test2'); $this->object->add($element); $this->object->add($element2); $this->assertTrue($this->object->has('test')); $this->assertEquals($element, $this->object->element('test')); $this->object->remove('test'); $this->assertFalse($this->object->has('test')); $this->assertEquals(1, count($this->object->elements())); $this->object->addAll(array(new Elements\Text('test2'), new Elements\Text('test3'))); $this->setExpectedException('Fwk\\Form\\Exceptions\\UnknownElementException'); $this->object->element('nonExistant'); }