Beispiel #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;
 }
Beispiel #2
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();
 }