protected function formProcessRequest($app)
 {
     $this->getExtension($app)->config['csrf'] = false;
     $app['request'] = Request::create('/');
     $boltforms = new BoltForms($app);
     $boltforms->makeForm('testing_form');
     $fields = $this->formValues();
     $boltforms->addFieldArray('testing_form', $fields);
     $parameters = array('testing_form' => array('name' => 'Gawain Lynch', 'email' => '*****@*****.**', 'message' => 'Hello'));
     $app['request'] = Request::create('/', 'POST', $parameters);
     return $boltforms->processRequest('testing_form', array('success' => true));
 }
 public function testWriteToContentype()
 {
     $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']['contenttype'] = '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 Bolt\Users
     $storage = $this->getMock('\\Bolt\\Storage', array('saveContent'), array($app));
     $storage->expects($this->any())->method('saveContent')->willReturn(42);
     $app['storage'] = $storage;
     $app['request'] = Request::create('/', 'POST', $parameters);
     $result = $boltforms->processRequest('testing_form', array('success' => true));
     $this->assertTrue($result);
 }
 public function testProcessRequest()
 {
     $app = $this->getApp();
     $this->getExtension($app)->config['csrf'] = false;
     $app['request'] = Request::create('/');
     $boltforms = new BoltForms($app);
     $boltforms->makeForm('contact');
     $fields = $this->formValues();
     $boltforms->addFieldArray('contact', $fields);
     $parameters = array('contact' => array('name' => 'Gawain Lynch', 'email' => '*****@*****.**', 'message' => 'Hello'));
     $app['request'] = Request::create('/', 'POST', $parameters);
     $result = $boltforms->processRequest('contact', array('success' => true));
     $this->assertTrue($result);
 }
 public function testRedirectRecord()
 {
     $app = $this->getApp();
     $this->getExtension($app)->config['csrf'] = false;
     $this->getExtension($app)->config['testing_form']['feedback']['redirect']['target'] = 'page/koalas';
     $this->getExtension($app)->config['testing_form']['feedback']['redirect']['query'] = 'name';
     $matcher = $this->getMockBuilder('\\Bolt\\Routing\\UrlMatcher')->disableOriginalConstructor()->setMethods(array('match'))->getMock();
     $matcher->expects($this->any())->method('match')->will($this->returnValue('/page/koalas'));
     $app['url_matcher'] = $matcher;
     $app['request'] = Request::create('/');
     $boltforms = new BoltForms($app);
     $boltforms->makeForm('testing_form');
     $fields = $this->formValues();
     unset($fields['array_index']);
     unset($fields['array_assoc']);
     unset($fields['lookup']);
     $boltforms->addFieldArray('testing_form', $fields);
     $parameters = array('testing_form' => array('name' => 'Gawain Lynch', 'email' => '*****@*****.**', 'message' => 'Hello'));
     $app['request'] = Request::create('/', 'POST', $parameters);
     $result = $boltforms->processRequest('testing_form', array('success' => true));
     $this->assertTrue($result);
     $this->expectOutputRegex('#<meta http-equiv="refresh" content="1;url=/page/koalas\\?name=Gawain\\+Lynch" />#');
 }
예제 #5
0
 public function testSendEmailDebugFail()
 {
     $app = $this->getApp();
     $this->getExtension($app)->config['csrf'] = false;
     $this->getExtension($app)->config['debug']['enabled'] = true;
     $this->getExtension($app)->config['debug']['address'] = null;
     $this->getExtension($app)->config['testing_form']['notification']['enabled'] = true;
     $app['request'] = Request::create('/');
     $boltforms = new BoltForms($app);
     $boltforms->makeForm('testing_form');
     $fields = $this->formValues();
     $boltforms->addFieldArray('testing_form', $fields);
     $parameters = array('testing_form' => array('name' => 'Gawain Lynch', 'email' => '*****@*****.**', 'message' => 'Hello'));
     $app['request'] = Request::create('/', 'POST', $parameters);
     $this->setExpectedException('\\Bolt\\Extension\\Bolt\\BoltForms\\Exception\\EmailException', '[BoltForms] Debug email address can not be empty if debugging enabled!');
     $result = $boltforms->processRequest('testing_form', array('success' => true));
     $this->assertTrue($result);
 }
 public function testSessionValue()
 {
     $sessionValueField = array('type' => 'hidden', 'options' => array('label' => false), 'event' => array('name' => 'session_value', 'params' => array('key' => 'koala')));
     $app = $this->getApp(false);
     $this->getExtension($app)->config['csrf'] = false;
     $this->getExtension($app)->config['testing_form']['fields']['session_value'] = $sessionValueField;
     $app['request'] = Request::create('/');
     $boltforms = new BoltForms($app);
     $boltforms->makeForm('testing_form');
     $fields = $this->formValues();
     $fields['session_value'] = $sessionValueField;
     $boltforms->addFieldArray('testing_form', $fields);
     $parameters = array('testing_form' => array('name' => 'Gawain Lynch', 'email' => '*****@*****.**', 'message' => 'Hello'));
     $app['request'] = Request::create('/', 'POST', $parameters);
     $app->boot();
     $app['session']->set('koala', 'gum-leaves');
     $result = $boltforms->processRequest('testing_form', array('success' => true), true);
     $this->assertArrayHasKey('session_value', $result);
     $this->assertSame('gum-leaves', $result['session_value']);
 }