public function testWriteToTable()
 {
     $app = $this->getApp();
     $this->getExtension($app)->config['csrf'] = false;
     $this->getExtension($app)->config['uploads']['enabled'] = true;
     $this->getExtension($app)->config['uploads']['base_directory'] = __DIR__;
     $this->getExtension($app)->config['testing_form']['database']['table'] = 'koala';
     $app['request'] = Request::create('/');
     $boltforms = new BoltForms($app);
     $boltforms->makeForm('testing_form');
     $fields = $this->formValues();
     $boltforms->addFieldArray('testing_form', $fields);
     $parameters = $this->getParameters($app);
     // Mock the database query
     $mocker = new Mock\DoctrineMockBuilder();
     $db = $mocker->getConnectionMock();
     $sm = $mocker->getSchemaManagerMock($db, true, array_keys($parameters['testing_form']));
     $db->expects($this->any())->method('getSchemaManager')->will($this->returnValue($sm));
     $db->expects($this->any())->method('insert')->will($this->returnValue(true));
     $app['db'] = $db;
     // Mock Bolt\Users
     $users = $this->getMock('\\Bolt\\Users', array('getUsers'), array($app));
     $users->expects($this->any())->method('getUsers')->willReturn(array('id' => 1));
     $app['users'] = $users;
     $app['request'] = Request::create('/', 'POST', $parameters);
     $result = $boltforms->processRequest('testing_form', array('success' => true));
     $this->assertTrue($result);
 }
 public function testWriteGetData()
 {
     $app = $this->getApp();
     $parameters = $this->getParameters($app);
     // Mock the database query
     $mocker = new Mock\DoctrineMockBuilder();
     $db = $mocker->getConnectionMock();
     $sm = $mocker->getSchemaManagerMock($db, true, array_keys($parameters['testing_form']));
     $db->expects($this->any())->method('getSchemaManager')->will($this->returnValue($sm));
     $db->expects($this->any())->method('insert')->will($this->returnValue(true));
     $app['db'] = $db;
     $parameters['testing_form']['message'] = $parameters['testing_form']['date'];
     $parameters['testing_form']['date'] = new \DateTime();
     $parameters['testing_form']['file'] = new FileUpload($app, 'testing_form', $parameters['testing_form']['file']);
     $formData = new FormData($parameters['testing_form']);
     $retval = $app['boltforms.database']->writeToTable('koalas', $formData);
     $this->assertNull($retval);
 }