/** * Create and return the router * * Retrieves the "router" key of the Configuration service, and uses it * to instantiate the router. Uses the TreeRouteStack implementation by * default. * * @param ServiceLocatorInterface $serviceLocator * @return TreeRouteStack */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Configuration'); $routes = isset($config['router']) ? $config['router'] : array(); $router = Router::factory($routes); return $router; }
public function setUp() { $this->request = new Request(); $this->helper = new QueryUrl($this->request); $this->router = TreeRouteStack::factory(['routes' => ['route-name' => new Literal('/foo/bar')]]); $this->helper->setRouter($this->router); }
protected function setUp() { //check if child class implements the correct interface if (!$this instanceof TestCaseAdapterInterface) { throw new \Exception(__CLASS__ . " : Line " . __LINE__ . " : Test Case could not executed. It must implement FrontCore\\TestsConfig\\TestCaseAdapterInterface", 500); } //end if //check if bootstrap instance has been set if (!$this->bootstrap) { throw new \Exception(__CLASS__ . " : Line " . __LINE__ . " : Test Case could not executed. Bootstrap instance is not set", 500); } //end if $this->serviceManager = $this->bootstrap->getServiceManager(); //$this->controller = new IndexController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->event = new MvcEvent(); $config = $this->serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); //$this->controller->setEvent($this->event); //$this->controller->setServiceLocator($serviceManager); //create logged in user $arr_user_data = array("id" => "1", "uname" => "user", "pword" => "5f4dcc3b5aa765d61d8327deb882cf99", "api_key" => "2c0f-828c-b184-f33f-2944-ad2d-f51c-e17a-7a13-ef2a-f581-8e2b", "phpunit" => TRUE); $objUserSession = $this->serviceManager->get("FrontUserLogin\\Models\\FrontUserSession")->createUserSession((object) $arr_user_data); }
public function setUp() { $basePath = __DIR__ . '/../../../../../'; $this->setApplicationConfig(include $basePath . 'config/application.config.php'); $serviceManager = Bootstrap::getServiceManager(); $this->controller = new \Galaxy\Controller\IndexController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); $mockAuth = $this->getMock('ZfcUser\\Entity\\UserInterface'); $ZfcUserMock = $this->getMock('User\\Entity\\User'); $ZfcUserMock->expects($this->any())->method('getId')->will($this->returnValue('3')); $authMock = $this->getMock('ZfcUser\\Controller\\Plugin\\ZfcUserAuthentication'); $authMock->expects($this->any())->method('hasIdentity')->will($this->returnValue(true)); $authMock->expects($this->any())->method('getIdentity')->will($this->returnValue($ZfcUserMock)); $this->controller->getPluginManager()->setService('zfcUserAuthentication', $authMock); parent::setUp(); }
protected function setUpController(\Zend\Mvc\Controller\AbstractActionController $controller) { $config = (include 'config/application.config.php'); $serviceManager = new ServiceManager(new ServiceManagerConfig()); $serviceManager->setService('ApplicationConfig', $config); $serviceManager->get('ModuleManager')->loadModules(); $serviceManager->setAllowOverride(true); $this->controller = $controller; $this->request = new Request(); $this->response = new Response(); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->event = new MvcEvent(); $this->event->setRequest($this->request)->setResponse($this->response); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); $this->setupForwardPlugin(); $this->setupParamsPlugin(); $this->setupFormPlugin(); $this->setupGridControllerPlugin(); $this->setupControllerFilePlugin(); }
public function setUp() { $config = (include __DIR__ . '/../../../config/module.config.php'); $renderer = new PhpRenderer(); $renderer->setResolver(new TemplateMapResolver($config['view_manager']['template_map'])); $router = TreeRouteStack::factory($config['router']); $this->helper = new QrCodeHelper($renderer, $router, new QrCodeServiceMock('foobar')); }
/** * {@inheritDoc} */ public function getServiceConfig() { return array('factories' => array('Application' => function (ServiceLocatorInterface $sl) { return new App($sl->get('Config'), $sl); }, 'Router' => function () { return HttpRouter::factory(array()); }, 'HttpRouter' => function (ServiceLocatorInterface $sl) { return $sl->get('Router'); })); }
public function getController($controllerClass, $controllerName, $action, $params = []) { $config = $this->getConfig(); $controller = $this->getServiceManager()->get('ControllerLoader')->get($controllerClass); $event = new MvcEvent(); $routerConfig = isset($config['router']) ? $config['router'] : []; $router = TreeRouteStack::factory($routerConfig); $event->setRouter($router); $event->setRouteMatch(new RouteMatch(['controller' => $controllerName, 'action' => $action] + $params)); $controller->setEvent($event); return $controller; }
protected function setUp() { $this->controller = new ConfigurationRestController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'rest_configuration')); $this->event = new MvcEvent(); $config = Bootstrap::getServiceManager()->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator(Bootstrap::getServiceManager()); }
/** * @return ServiceLocatorInterface */ private function createServiceLocator(MvcEvent $e = null) { $sm = new ServiceManager(); $sm->setService('Request', new Request()); $sm->setService('Response', new Response()); $sm->setService('EventManager', new EventManager()); $sm->setService('Router', TreeRouteStack::factory(['routes' => []])); $e = $e ?: new MvcEvent(); $app = $this->getMock('Zend\\Mvc\\Application', [], [[], $sm]); $app->expects($this->any())->method('getMvcEvent')->willReturn($e); $sm->setService('Application', $app); $helperManager = new HelperPluginManager(); $helperManager->setServiceLocator($sm); return $helperManager; }
/** * @return ServiceLocatorInterface */ private function createServiceLocator(MvcEvent $e = null) { $sm = new ServiceManager(); $sm->setService('Request', new Request()); $sm->setService('Response', new Response()); $sm->setService('EventManager', new EventManager()); $sm->setService('Router', TreeRouteStack::factory(['routes' => []])); $e = $e ?: new MvcEvent(); $app = $this->prophesize('Zend\\Mvc\\Application'); $app->getMvcEvent()->willReturn($e); $sm->setService('Application', $app->reveal()); $helperManager = new HelperPluginManager(); $helperManager->setServiceLocator($sm); return $helperManager; }
protected function setUp() { $serviceManager = $this->getServiceManager(); $this->controller = new IndexController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); }
protected function setUp() { $serviceManagerGrabber = new ServiceManagerGrabber(); $this->serviceManager = $serviceManagerGrabber->getServiceManager(); $this->serviceManager->setAllowOverride(true); $this->serviceManager->setService('doctrine.entitymanager.orm_default', $this->getEntityManagerMock()); $config = $this->serviceManager->get('Config'); $this->request = new PhpEnviromentRequest(); $this->router = HttpRouter::factory(isset($config['router']) ? $config['router'] : array()); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->routeMatch->setParam('lang', 'it'); $this->event = new MvcEvent(); $this->event->setRouter($this->router); $this->event->setRouteMatch($this->routeMatch); }
protected function setUp() { $this->serviceManager = ServiceManagerFactory::getServiceManager(); $this->controller = new IndexController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(['controller' => IndexController::class]); $this->event = new MvcEvent(); $config = $this->serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : []; $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($this->serviceManager); }
public function setUp() { parent::setUp(); $this->_serviceManager = \Bootstrap::getServiceManager(); $this->controller = new GridController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array()); $this->event = new MvcEvent(); $config = $this->_serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($this->_serviceManager); }
public function setUp() { parent::setUp(); $this->controller = new $this->controllerStringName(); $this->request = $this->controller->getRequest(); $this->response = $this->controller->getResponse(); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->event = new MvcEvent(); $config = $this->getService('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($this->serviceManager); }
protected function setUp() { $this->service = $this->getMockBuilder('OpsWay\\TocatBudget\\Service\\MyService')->disableOriginalConstructor()->getMock(); $serviceManager = Bootstrap::getServiceManager(); $this->controller = new MyController($this->service); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'other')); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); }
protected function setUp() { $serviceManager = Bootstrap::getServiceManager(); $this->fileSystem = vfsStream::setup('public', null, array('img' => array('test.jpg' => file_get_contents(__DIR__ . '/../../_files/test.jpg')), 'processed' => array())); $imageProcessing = $serviceManager->get('TckImageResizer\\Service\\ImageProcessing'); $this->controller = new IndexController($imageProcessing, vfsStream::url('public')); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); }
public function setUp() { $serviceManager = Bootstrap::getServiceManager(); $this->setApplicationConfig($serviceManager->get('ApplicationConfig')); $this->controller = new UserController($this->getApplicationServiceLocator()); $this->controller->setTranslator($serviceManager->get('Translator')); $this->routeMatch = new RouteMatch(array('controller' => 'user')); $this->event = new MvcEvent(); $config = $serviceManager->get('config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); parent::setUp(); }
/** * @see PHPUnit_Framework_TestCase::setUp() */ protected function setUp() { $oServiceManager = \TranslatorToolsTest\Bootstrap::getServiceManager(); $this->configuration = \Zend\Stdlib\ArrayUtils::merge($oServiceManager->get('Config'), include __DIR__ . '/../configuration.php'); $bAllowOverride = $oServiceManager->getAllowOverride(); if (!$bAllowOverride) { $oServiceManager->setAllowOverride(true); } $oServiceManager->setService('Config', $this->configuration)->setAllowOverride($bAllowOverride); $this->controller = new \TranslatorTools\Controller\ToolsController(); $this->request = new \Zend\Http\Request(); $this->routeMatch = new \Zend\Mvc\Router\RouteMatch(array('controller' => 'tools')); $this->event = new \Zend\Mvc\MvcEvent(); $this->event->setRouter(\Zend\Mvc\Router\Http\TreeRouteStack::factory(isset($this->configuration['router']) ? $this->configuration['router'] : array()))->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($oServiceManager); }
/** * Create and return the router * * Retrieves the "router" key of the Config service, and uses it * to instantiate the router. Uses the TreeRouteStack implementation by * default. * * @param ServiceLocatorInterface $serviceLocator * @param string|null $cName * @param string|null $rName * @return \Zend\Mvc\Router\RouteStackInterface */ public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null) { $config = $serviceLocator->get('Configuration'); if ($rName === 'ConsoleRouter' || $cName === 'router' && Console::isConsole()) { // We are in a console, use console router. if (isset($config['console']) && isset($config['console']['router'])) { $routerConfig = $config['console']['router']; } else { $routerConfig = array(); } $router = ConsoleRouter::factory($routerConfig); } else { // This is an HTTP request, so use HTTP router $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); } return $router; }
/** * Setup for tests * * @return null */ public function setUp() { $config = ['Rcm\\Api\\Page\\Check' => ['type' => 'Segment', 'options' => ['route' => '/rcm/page/check[/:pageType]/:pageId', 'defaults' => ['controller' => 'Rcm\\Controller\\PageCheckController']]]]; $this->mockPageValidator = $this->getMockBuilder('\\Rcm\\Validator\\Page')->disableOriginalConstructor()->getMock(); $serviceManager = new ServiceManager(); $serviceManager->setService('Rcm\\Validator\\Page', $this->mockPageValidator); /** @var \Rcm\Service\LayoutManager $mockLayoutManager */ $this->controller = new PageCheckController($serviceManager); $this->request = new Request(); $this->request->setMethod('GET'); $this->routeMatch = new RouteMatch(['controller' => 'Rcm\\Controller\\PageCheckController']); $this->event = new MvcEvent(); $routerConfig = $config; $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); }
public function setUp() { $this->setApplicationConfig(include __DIR__ . '/../../../../../config/application.config.php'); parent::setUp(); $serviceManager = Bootstrap::getServiceManager(); $this->controller = new CrudController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); $this->controller->em = $this->getMock('Doctrine\\ORM\\EntityManager', array('getRepository', 'getClassMetadata', 'persist', 'flush', 'find'), array(), '', false); }
public function setUp() { $serviceManager = Bootstrap::getServiceManager(); $this->setApplicationConfig($serviceManager->get('ApplicationConfig')); $this->controller = new ListingController($this->getApplicationServiceLocator()); $this->controller->setTranslator($serviceManager->get('Translator')); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'listing')); $this->event = new MvcEvent(); $config = $serviceManager->get('config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->entityManager = $this->controller->getServiceLocator()->get('entity-manager'); $this->listingEntityClassName = get_class(new Listing()); parent::setUp(); }
protected function setUp() { Bootstrap::setUpAclDatabase(); // Gather variables $serviceManager = Bootstrap::getServiceManager(); $this->controller = new AuthorizedController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array()); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); // Setup the actual testcase. $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); // Arranging the zfc-user services. $authMock = $this->getMock('ZfcUser\\Controller\\Plugin\\ZfcUserAuthentication'); $this->controller->getPluginManager()->setService('zfcUserAuthentication', $authMock); }
protected function setUp() { $serviceManager = Bootstrap::getServiceManager(); $this->controller = new IndexController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'index')); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $serviceManager->setAllowOverride(true); $serviceManager->setService('AuthService', new AuthenticationService(new Storage\NonPersistent(), new TestAdapter())); $albumTableMock = $this->getMockBuilder('Zend\\Mvc\\Controller\\ControllerManager')->disableOriginalConstructor()->getMock(); $albumTableMock->expects($this->any())->method('get')->will($this->returnValue($this->controller)); $serviceManager->setService('ControllerManager', $albumTableMock); $this->event->setApplication(new Application($config, $serviceManager)); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); }
protected function setUp() { $this->setBootstrap(__DIR__ . '/../../../../bootstrap.php'); $application = (require $this->bootstrap); $this->application = $application; $this->sm = $application->getServiceManager(); $serviceManager = $this->sm; $this->controller = new Admin_PostController(); $this->request = new Request(); $this->routeMatch = new RouteMatch(array('controller' => 'JcBlog\\Controller\\Admin\\Index')); $this->event = new MvcEvent(); $config = $serviceManager->get('Config'); $app = $serviceManager->get('application'); $app instanceof Application; $this->controller->setPluginManager(new PluginManager(new Config(array('invokables' => array('backTo' => 'AtBase\\Mvc\\Controller\\Plugin\\BackTo'))))); $routerConfig = isset($config['router']) ? $config['router'] : array(); $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); $this->controller->setServiceLocator($serviceManager); }
/** * Setup for tests * * @return null */ public function setUp() { $this->mockPageRepo = $this->getMockBuilder('\\Rcm\\Repository\\Page')->disableOriginalConstructor()->getMock(); $this->mockPageRepo->expects($this->any())->method('getPageByName')->will($this->returnCallback([$this, 'pageRepoMockCallback'])); $mockLayoutManager = $this->getMockBuilder('\\Rcm\\Service\\LayoutManager')->disableOriginalConstructor()->getMock(); $mockLayoutManager->expects($this->any())->method('getSiteLayout')->will($this->returnCallback([$this, 'layoutManagerMockCallback'])); $this->mockUserServicePlugin = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\RcmIsAllowed')->disableOriginalConstructor()->getMock(); $this->mockIsPageAllowed = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\RcmIsPageAllowed')->disableOriginalConstructor()->getMock(); $this->mockShouldShowRevisions = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\ShouldShowRevisions')->disableOriginalConstructor()->getMock(); $this->mockRedirectToPage = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\RedirectToPage')->disableOriginalConstructor()->getMock(); $this->mockIsSiteAdmin = $this->getMockBuilder('\\Rcm\\Controller\\Plugin\\IsSiteAdmin')->disableOriginalConstructor()->getMock(); $this->currentSite = new Site(); $this->currentSite->setSiteId(1); $this->currentSite->setNotFoundPage('not-found'); $config = ['contentManager' => ['type' => 'Zend\\Mvc\\Router\\Http\\Segment', 'options' => ['route' => '/rcm[/:page][/:revision]', 'defaults' => ['controller' => 'Rcm\\Controller\\IndexController', 'action' => 'index']]], 'contentManagerWithPageType' => ['type' => 'Zend\\Mvc\\Router\\Http\\Segment', 'options' => ['route' => '/rcm/:pageType/:page[/:revision]', 'constraints' => ['pageType' => '[a-z]'], 'defaults' => ['controller' => 'Rcm\\Controller\\IndexController', 'action' => 'index']]]]; /** @var \Rcm\Service\LayoutManager $mockLayoutManager */ $this->controller = new IndexController($mockLayoutManager, $this->currentSite, $this->mockPageRepo); $this->controller->getPluginManager()->setService('rcmIsAllowed', $this->mockUserServicePlugin)->setService('shouldShowRevisions', $this->mockShouldShowRevisions)->setService('redirectToPage', $this->mockRedirectToPage)->setService('rcmIsSiteAdmin', $this->mockIsSiteAdmin)->setService('rcmIsPageAllowed', $this->mockIsPageAllowed); $this->request = new Request(); $this->routeMatch = new RouteMatch(['controller' => 'index']); $this->event = new MvcEvent(); $routerConfig = $config; $router = HttpRouter::factory($routerConfig); $this->event->setRouter($router); $this->event->setRouteMatch($this->routeMatch); $this->controller->setEvent($this->event); }
/** * Create and return router * * @param ServiceLocatorInterface $serviceLocator * @param string|null $cName * @param string|null $rName * @return HttpRouter */ public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null) { $config = $serviceLocator->get('Config'); $routerConfig = isset($config['router']) ? $config['router'] : array(); return HttpRouter::factory($routerConfig); }
/** * @return mixed */ public function recoverRouter() { $this->assertServiceManager(); try { $this->setService('router', $this->recoverService('serviceManager')->get('router')); } catch (ServiceNotCreatedException $ex) { $this->setService('router', HttpRouter::factory(array())); } return $this->recoverService('router'); }