public function testSetCaptchaElement() { $options = $this->getMock('ZfcUser\\Options\\RegistrationOptionsInterface'); $options->expects($this->once())->method('getEnableUsername')->will($this->returnValue(false)); $options->expects($this->once())->method('getEnableDisplayName')->will($this->returnValue(false)); $options->expects($this->any())->method('getUseRegistrationFormCaptcha')->will($this->returnValue(false)); $captcha = $this->getMock('\\Zend\\Form\\Element\\Captcha'); $form = new Form(null, $options); $form->setCaptchaElement($captcha); $reflection = $this->helperMakePropertyAccessable($form, 'captchaElement'); $this->assertSame($captcha, $reflection->getValue($form)); }
public function getServiceConfig() { return array('invokables' => array('ZfcUser\\Authentication\\Adapter\\Db' => 'ZfcUser\\Authentication\\Adapter\\Db', 'ZfcUser\\Authentication\\Storage\\Db' => 'ZfcUser\\Authentication\\Storage\\Db', 'ZfcUser\\Form\\Login' => 'ZfcUser\\Form\\Login', 'zfcuser_user_service' => 'ZfcUser\\Service\\User', 'zfcuser_register_form_hydrator' => 'Zend\\Stdlib\\Hydrator\\ClassMethods'), 'factories' => array('zfcuser_redirect_callback' => function ($sm) { /* @var RouteInterface $router */ $router = $sm->get('Router'); /* @var Application $application */ $application = $sm->get('Application'); /* @var ModuleOptions $options */ $options = $sm->get('zfcuser_module_options'); return new RedirectCallback($application, $router, $options); }, 'zfcuser_module_options' => function ($sm) { $config = $sm->get('Config'); return new Options\ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array()); }, 'zfcuser_auth_service' => function ($sm) { return new \Zend\Authentication\AuthenticationService($sm->get('ZfcUser\\Authentication\\Storage\\Db'), $sm->get('ZfcUser\\Authentication\\Adapter\\AdapterChain')); }, 'ZfcUser\\Authentication\\Adapter\\AdapterChain' => 'ZfcUser\\Authentication\\Adapter\\AdapterChainServiceFactory', 'zfcuser_login_form' => function ($sm) { $options = $sm->get('zfcuser_module_options'); $form = new Form\Login(null, $options); $form->setInputFilter(new Form\LoginFilter($options)); return $form; }, 'zfcuser_register_form' => function ($sm) { $options = $sm->get('zfcuser_module_options'); var_dump($options); dia; $form = new Form\Register(null, $options); $form->setCaptchaElement($sm->get('zfcuser_captcha_element')); $form->setInputFilter(new Form\RegisterFilter(new Validator\NoRecordExists(array('mapper' => $sm->get('zfcuser_user_mapper'), 'key' => 'email')), new Validator\NoRecordExists(array('mapper' => $sm->get('zfcuser_user_mapper'), 'key' => 'username')), $options)); return $form; }, 'zfcuser_change_password_form' => function ($sm) { $options = $sm->get('zfcuser_module_options'); $form = new Form\ChangePassword(null, $sm->get('zfcuser_module_options')); $form->setInputFilter(new Form\ChangePasswordFilter($options)); return $form; }, 'zfcuser_change_email_form' => function ($sm) { $options = $sm->get('zfcuser_module_options'); $form = new Form\ChangeEmail(null, $options); $form->setInputFilter(new Form\ChangeEmailFilter($options, new Validator\NoRecordExists(array('mapper' => $sm->get('zfcuser_user_mapper'), 'key' => 'email')))); return $form; }, 'zfcuser_user_hydrator' => function ($sm) { $hydrator = new \Zend\Stdlib\Hydrator\ClassMethods(); return $hydrator; }, 'zfcuser_user_mapper' => function ($sm) { $options = $sm->get('zfcuser_module_options'); $mapper = new Mapper\User(); $mapper->setDbAdapter($sm->get('zfcuser_zend_db_adapter')); $entityClass = $options->getUserEntityClass(); $mapper->setEntityPrototype(new $entityClass()); $mapper->setHydrator(new Mapper\UserHydrator()); $mapper->setTableName($options->getTableName()); return $mapper; })); }