示例#1
0
 protected function setUp()
 {
     $serviceManager = new ServiceManager();
     $serviceLocator = new FormElementManager();
     $serviceLocator->setServiceLocator($serviceManager);
     $pAccounts = $this->getMock('Balance\\Model\\Persistence\\ValueOptionsInterface');
     $pAccounts->method('getValueOptions')->will($this->returnValue([]));
     $serviceManager->setService('Balance\\Model\\Persistence\\Accounts', $pAccounts);
     $serviceLocator->setService('Currency', new CurrencyElement());
     $view = new View();
     $view->getEventManager()->attach(ViewEvent::EVENT_RENDERER, function () {
         $renderer = (new PhpRenderer())->setResolver(new TemplateMapResolver(['layout/page-header' => './module/Balance/view/layout/page-header.phtml', 'balance/postings/edit' => './module/Balance/view/balance/postings/edit.phtml', 'tests/postings/before-entries-a' => './module/Balance/test/BalanceTest/View/Scripts/postings-before-entries-a.phtml', 'tests/postings/before-entries-b' => './module/Balance/test/BalanceTest/View/Scripts/postings-before-entries-b.phtml']));
         $helpers = $renderer->getHelperPluginManager();
         $helpers->get('BasePath')->setBasePath('/');
         $match = $this->getMockBuilder('Zend\\Mvc\\Router\\RouteMatch')->disableOriginalConstructor()->getMock();
         $match->method('getMatchedRouteName')->will($this->returnValue('default'));
         $helpers->get('Url')->setRouter($this->getMock('Zend\\Mvc\\Router\\RouteStackInterface'))->setRouteMatch($match);
         $configs = new HelperConfig();
         $configs->configureServiceManager($helpers);
         return $renderer;
     });
     $form = new PostingsForm();
     $form->setServiceLocator($serviceLocator);
     $model = (new ViewModel())->setTemplate('balance/postings/edit')->setVariable('form', $form)->setOption('has_parent', true);
     $form->init();
     $this->view = $view;
     $this->model = $model;
 }
 public function testCanCreateService()
 {
     $serviceManager = new ServiceManager();
     $serviceManager->setService('UghAuthentication\\InputFilter\\Login', new InputFilter());
     $formServiceManager = new FormElementManager();
     $formServiceManager->setServiceLocator($serviceManager);
     $factory = new LoginFactory();
     $inputFilter = $factory->createService($formServiceManager);
     $this->assertInstanceOf('UghAuthentication\\Form\\Login', $inputFilter);
 }
 public function testFactory()
 {
     $serviceManager = new ServiceManager();
     $serviceManager->setService('zfcuser_module_options', new ModuleOptions());
     $formElementManager = new FormElementManager();
     $formElementManager->setServiceLocator($serviceManager);
     $serviceManager->setService('FormElementManager', $formElementManager);
     $factory = new LoginFactory();
     $this->assertInstanceOf('ZfcUser\\Form\\Login', $factory->createService($formElementManager));
 }
 public function testFactory()
 {
     $serviceManager = new ServiceManager();
     $serviceManager->setService('zfcuser_module_options', new ModuleOptions());
     $serviceManager->setService('zfcuser_user_mapper', new UserMapper());
     $serviceManager->setService('zfcuser_register_form_hydrator', new ClassMethods());
     $formElementManager = new FormElementManager();
     $formElementManager->setServiceLocator($serviceManager);
     $serviceManager->setService('FormElementManager', $formElementManager);
     $factory = new RegisterFactory();
     $this->assertInstanceOf('ZfcUser\\Form\\Register', $factory->createService($formElementManager));
 }
 public function testSetLocaleFromConfigWithServiceManagerSubclass()
 {
     $default = new DefaultLocale();
     $default->setLocale('en_US');
     $sm = new ServiceManager();
     $sm->setService('config', array('locale' => 'uk_UA'));
     $fm = new FormElementManager();
     $fm->setServiceLocator($sm);
     $default->setLocaleFromConfig($fm);
     $this->assertSame('uk_UA', $default->getLocale());
     return $default;
 }
示例#6
0
 public function testInitWithoutPersistence()
 {
     $this->setExpectedException('Balance\\Form\\FormException', 'Invalid Model');
     $form = new Postings();
     // Localizador de Serviços Superior
     $serviceLocator = new ServiceManager();
     // Gerenciador de Formulários
     $formElementManager = new FormElementManager();
     // Dependência
     $formElementManager->setServiceLocator($serviceLocator);
     // Configurar Localizador de Serviços Superior
     $form->setServiceLocator($formElementManager);
     // Camada de Modelo de Contas
     $serviceLocator->setService('Balance\\Model\\Persistence\\Accounts', $this->getMock('Balance\\Model\\Persistence\\PersistenceInterface'));
     $form->init();
 }
 public function setUp()
 {
     $services = $this->services = new ServiceManager();
     $elements = new FormElementManager();
     $filters = new FilterPluginManager();
     $hydrators = new HydratorPluginManager();
     $inputFilters = new InputFilterPluginManager();
     $validators = new ValidatorPluginManager();
     $elements->setServiceLocator($services);
     $filters->setServiceLocator($services);
     $hydrators->setServiceLocator($services);
     $inputFilters->setServiceLocator($services);
     $validators->setServiceLocator($services);
     $services->setService('FilterManager', $filters);
     $services->setService('FormElementManager', $elements);
     $services->setService('HydratorManager', $hydrators);
     $services->setService('InputFilterManager', $inputFilters);
     $services->setService('ValidatorManager', $validators);
     $inputFilters->setInvokableClass('FooInputFilter', 'Zend\\InputFilter\\InputFilter');
     $forms = $this->forms = new FormAbstractServiceFactory();
     $services->addAbstractFactory($forms);
 }
 /**
  * Generic test for the constructor
  *
  * @return null
  * @covers \RcmAdmin\Factory\NewPageFormFactory
  */
 public function testCreateService()
 {
     $mockCurrentSite = $this->getMockBuilder('\\Rcm\\Entity\\Site')->disableOriginalConstructor()->getMock();
     $mockEntityManager = $this->getMockBuilder('\\Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $mockPageRepo = $this->getMockBuilder('\\Rcm\\Repository\\Page')->disableOriginalConstructor()->getMock();
     $mockEntityManager->expects($this->any())->method('getRepository')->will($this->returnValue($mockPageRepo));
     $mockLayoutManager = $this->getMockBuilder('\\Rcm\\Service\\LayoutManager')->disableOriginalConstructor()->getMock();
     $mockMainLayoutValidator = $this->getMockBuilder('\\Rcm\\Validator\\MainLayout')->disableOriginalConstructor()->getMock();
     $mockPageValidator = $this->getMockBuilder('\\Rcm\\Validator\\Page')->disableOriginalConstructor()->getMock();
     $mockPageTemplateValidator = $this->getMockBuilder('\\Rcm\\Validator\\PageTemplate')->disableOriginalConstructor()->getMock();
     $serviceManager = new ServiceManager();
     $serviceManager->setService('Rcm\\Validator\\PageTemplate', $mockPageTemplateValidator);
     $serviceManager->setService('Rcm\\Validator\\Page', $mockPageValidator);
     $serviceManager->setService('Rcm\\Validator\\MainLayout', $mockMainLayoutValidator);
     $serviceManager->setService('Rcm\\Service\\CurrentSite', $mockCurrentSite);
     $serviceManager->setService('Doctrine\\ORM\\EntityManager', $mockEntityManager);
     $serviceManager->setService('Rcm\\Service\\LayoutManager', $mockLayoutManager);
     $formManager = new FormElementManager();
     $formManager->setServiceLocator($serviceManager);
     $factory = new NewPageFormFactory();
     $object = $factory->createService($formManager);
     $this->assertTrue($object instanceof NewPageForm);
 }
示例#9
0
 public function setUp()
 {
     $elementManager = new FormElementManager();
     $elementManager->setServiceLocator(new ServiceManager());
     $this->factory = new FormFactory($elementManager);
 }