Example #1
0
 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');
 }
Example #2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = $form = new Form();
     $check = new Elements\Checkbox('test_check');
     $text = new Elements\TextArea('test_textarea');
     $check->filter(new Validation\NotEmptyFilter(), 'check must be checked');
     $text->filter(new Validation\NotEmptyFilter(), 'text must not be blank');
     $form->addAll(array($check, $text));
 }