예제 #1
0
 /**
  * Prepares the environment before running a test
  *
  */
 protected function setUp()
 {
     $cwd = __DIR__;
     // read navigation config
     $this->_files = $cwd . '/_files';
     $config = ConfigFactory::fromFile($this->_files . '/navigation.xml', true);
     // setup containers from config
     $this->_nav1 = new Navigation($config->get('nav_test1'));
     $this->_nav2 = new Navigation($config->get('nav_test2'));
     // setup view
     $view = new PhpRenderer();
     $view->resolver()->addPath($cwd . '/_files/mvc/views');
     // create helper
     $this->_helper = new $this->_helperName();
     $this->_helper->setView($view);
     // set nav1 in helper as default
     $this->_helper->setContainer($this->_nav1);
     // setup service manager
     $smConfig = array('modules' => array(), 'module_listener_options' => array('config_cache_enabled' => false, 'cache_dir' => 'data/cache', 'module_paths' => array(), 'extra_config' => array('service_manager' => array('factories' => array('Config' => function () use($config) {
         return array('navigation' => array('default' => $config->get('nav_test1')));
     })))));
     $sm = $this->serviceManager = new ServiceManager(new ServiceManagerConfig());
     $sm->setService('ApplicationConfig', $smConfig);
     $sm->get('ModuleManager')->loadModules();
     $sm->get('Application')->bootstrap();
     $sm->setFactory('Navigation', 'Zend\\Navigation\\Service\\DefaultNavigationFactory');
     $sm->setService('nav1', $this->_nav1);
     $sm->setService('nav2', $this->_nav2);
     $app = $this->serviceManager->get('Application');
     $app->getMvcEvent()->setRouteMatch(new RouteMatch(array('controller' => 'post', 'action' => 'view', 'id' => '1337')));
 }
예제 #2
0
파일: AbstractTest.php 프로젝트: rikaix/zf2
 /**
  * Prepares the environment before running a test
  *
  */
 protected function setUp()
 {
     $cwd = __DIR__;
     // read navigation config
     $this->_files = $cwd . '/_files';
     $config = ConfigFactory::fromFile($this->_files . '/navigation.xml', true);
     // setup containers from config
     $this->_nav1 = new Navigation($config->get('nav_test1'));
     $this->_nav2 = new Navigation($config->get('nav_test2'));
     // setup view
     $view = new PhpRenderer();
     $view->resolver()->addPath($cwd . '/_files/mvc/views');
     // create helper
     $this->_helper = new $this->_helperName();
     $this->_helper->setView($view);
     // set nav1 in helper as default
     $this->_helper->setContainer($this->_nav1);
 }