public function testAddFields() { $app = $this->getApp(); $app['request'] = Request::create('/'); $boltforms = new BoltForms($app); $boltforms->makeForm('testing_form'); $fields = $this->formFieldConfig(); $boltforms->addFieldArray('testing_form', $fields); $form = $boltforms->getForm('testing_form'); foreach ($fields as $field => $values) { $this->assertTrue($form->has($field)); } }
public function testEventInvalidSetData() { $app = $this->getApp(); $app['request'] = Request::create('/'); $boltforms = new BoltForms($app); $boltforms->makeForm('testing_form'); $fields = $this->formFieldConfig(); $boltforms->addFieldArray('testing_form', $fields); $evt = new FormEvent($boltforms->getForm('testing_form'), array('koala' => 'leaves')); $event = new BoltFormsEvent($evt, FormEvents::POST_SUBMIT); $this->assertInstanceOf('Symfony\\Component\\Form\\FormEvent', $event->getEvent()); $this->assertInstanceOf('Symfony\\Component\\Form\\FormInterface', $event->getForm()); $this->assertSame(array('koala' => 'leaves'), $event->getData()); $this->setExpectedException('\\RuntimeException'); $event->getEvent()->setName(FormEvents::POST_SUBMIT); $event->setData('fail'); }