public function testCreateForm() { $factory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface'); $app = new Application(Application::ENV_TEST); $app['form.factory'] = $factory; $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock(); $type = $this->getMock('Symfony\\Component\\Form\\FormTypeInterface'); $data = ['some' => 'data']; $options = []; $parent = $this->getMockBuilder('Symfony\\Component\\Form\\FormBuilder')->disableOriginalConstructor()->getMock(); $factory->expects($this->once())->method('create')->with($this->equalTo($type), $this->equalTo($data), $this->equalTo($options), $this->equalTo($parent))->will($this->returnValue($form)); $this->assertEquals($form, $app->form($type, $data, $options, $parent)); }
/** * Authenticate to phraseanet * * @param Application $app A Silex application where the controller is mounted on * @param Request $request The current request * @return RedirectResponse */ public function authenticate(PhraseaApplication $app, Request $request) { $form = $app->form(new PhraseaAuthenticationForm()); $redirector = function (array $params = []) use($app) { return $app->redirectPath('homepage', $params); }; try { return $this->doAuthentication($app, $request, $form, $redirector); } catch (AuthenticationException $e) { return $e->getResponse(); } }