Ejemplo n.º 1
0
 public function setUp()
 {
     $this->router = $router = new TreeRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $route2 = new Segment('/help');
     $router->addRoute('docs', $route2);
     $router->addRoute('hostname', ['type' => 'hostname', 'options' => ['route' => 'localhost.localdomain'], 'child_routes' => ['resource' => ['type' => 'segment', 'options' => ['route' => '/resource[/:id]'], 'may_terminate' => true, 'child_routes' => ['children' => ['type' => 'literal', 'options' => ['route' => '/children']]]], 'users' => ['type' => 'segment', 'options' => ['route' => '/users[/:id]']], 'contacts' => ['type' => 'segment', 'options' => ['route' => '/contacts[/:id]']], 'embedded' => ['type' => 'segment', 'options' => ['route' => '/embedded[/:id]']], 'embedded_custom' => ['type' => 'segment', 'options' => ['route' => '/embedded_custom[/:custom_id]']]]]);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $router->setRequestUri(new Http('http://localhost.localdomain/resource'));
     $controller = $this->controller = $this->getMock('Zend\\Mvc\\Controller\\AbstractRestfulController');
     $controller->expects($this->any())->method('getEvent')->will($this->returnValue($event));
     $this->urlHelper = $urlHelper = new UrlHelper();
     $urlHelper->setRouter($router);
     $this->serverUrlHelper = $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $this->plugin = $plugin = new HalHelper();
     $plugin->setController($controller);
     $plugin->setUrlHelper($urlHelper);
     $plugin->setServerUrlHelper($serverUrlHelper);
     $linkExtractor = new LinkExtractor($serverUrlHelper, $urlHelper);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $plugin->setLinkCollectionExtractor($linkCollectionExtractor);
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     $routerClass = class_exists(V2TreeRouteStack::class) ? V2TreeRouteStack::class : TreeRouteStack::class;
     $routeClass = class_exists(V2Segment::class) ? V2Segment::class : Segment::class;
     $this->router = $router = new $routerClass();
     $route = new $routeClass('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $route2 = new $routeClass('/help');
     $router->addRoute('docs', $route2);
     $router->addRoute('hostname', ['type' => 'hostname', 'options' => ['route' => 'localhost.localdomain'], 'child_routes' => ['resource' => ['type' => 'segment', 'options' => ['route' => '/resource[/:id]'], 'may_terminate' => true, 'child_routes' => ['children' => ['type' => 'literal', 'options' => ['route' => '/children']]]], 'users' => ['type' => 'segment', 'options' => ['route' => '/users[/:id]']], 'contacts' => ['type' => 'segment', 'options' => ['route' => '/contacts[/:id]']], 'embedded' => ['type' => 'segment', 'options' => ['route' => '/embedded[/:id]']], 'embedded_custom' => ['type' => 'segment', 'options' => ['route' => '/embedded_custom[/:custom_id]']]]]);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $router->setRequestUri(new Http('http://localhost.localdomain/resource'));
     $controller = $this->controller = $this->prophesize(AbstractRestfulController::class);
     $controller->getEvent()->willReturn($event);
     $this->urlHelper = $urlHelper = new UrlHelper();
     $urlHelper->setRouter($router);
     $this->serverUrlHelper = $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $this->plugin = $plugin = new HalHelper();
     $plugin->setController($controller->reveal());
     $linkUrlBuilder = new LinkUrlBuilder($serverUrlHelper, $urlHelper);
     $plugin->setLinkUrlBuilder($linkUrlBuilder);
     $linkExtractor = new LinkExtractor($linkUrlBuilder);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $plugin->setLinkCollectionExtractor($linkCollectionExtractor);
 }
 public function setUp()
 {
     $this->controller = $controller = new ResourceController();
     $this->router = $router = new SimpleRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $event->setRouteMatch(new RouteMatch(array()));
     $controller->setEvent($event);
     $controller->setRoute('resource');
     $pluginManager = new PluginManager();
     $controller->setPluginManager($pluginManager);
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $linksHelper = new Plugin\HalLinks();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $pluginManager->setService('HalLinks', $linksHelper);
     $linksHelper->setController($controller);
     $this->resource = $resource = new Resource();
     $controller->setResource($resource);
 }
Ejemplo n.º 4
0
 public function setUp()
 {
     $this->controller = $controller = new RestController();
     $this->router = $router = new SimpleRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $event->setRouteMatch(new RouteMatch([]));
     $controller->setEvent($event);
     $controller->setRoute('resource');
     $pluginManager = new PluginManager();
     $pluginManager->setService('bodyParams', new BodyParams());
     $controller->setPluginManager($pluginManager);
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $linksHelper = new HalHelper();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $linkExtractor = new LinkExtractor($serverUrlHelper, $urlHelper);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $linksHelper->setLinkCollectionExtractor($linkCollectionExtractor);
     $pluginManager->setService('Hal', $linksHelper);
     $linksHelper->setController($controller);
     $this->resource = $resource = new Resource();
     $controller->setResource($resource);
 }
    public function setupHelpers()
    {
        if (!$this->router) {
            $this->setupRouter();
        }

        $urlHelper = new UrlHelper();
        $urlHelper->setRouter($this->router);

        $serverUrlHelper = new ServerUrlHelper();
        $serverUrlHelper->setScheme('http');
        $serverUrlHelper->setHost('localhost.localdomain');

        $linksHelper = new HalHelper();
        $linksHelper->setUrlHelper($urlHelper);
        $linksHelper->setServerUrlHelper($serverUrlHelper);

        $this->helpers = $helpers = new HelperPluginManager();
        $helpers->setService('url', $urlHelper);
        $helpers->setService('serverUrl', $serverUrlHelper);
        $helpers->setService('hal', $linksHelper);

        $this->plugins = $plugins = new ControllerPluginManager();
        $plugins->setService('hal', $linksHelper);
    }
 /**
  * Create and return the view helper manager
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ViewHelperInterface
  * @throws Exception\RuntimeException
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $pluginManagerClass = static::PLUGIN_MANAGER_CLASS;
     $plugins = new $pluginManagerClass();
     $plugins->setServiceLocator($serviceLocator);
     $configuration = $serviceLocator->get('Config');
     if (isset($configuration['di']) && $serviceLocator->has('Di')) {
         $di = $serviceLocator->get('Di');
         $plugins->addAbstractFactory(new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI));
     }
     foreach ($this->defaultHelperMapClasses as $configClass) {
         if (is_string($configClass) && class_exists($configClass)) {
             $config = new $configClass();
         }
         if (!$config instanceof ConfigInterface) {
             throw new Exception\RuntimeException(sprintf('Invalid service manager configuration class provided; received "%s", expected class implementing %s', $configClass, 'Zend\\ServiceManager\\ConfigInterface'));
         }
         $config->configureServiceManager($plugins);
     }
     // Configure URL view helper with router
     $plugins->setFactory('url', function ($sm) use($serviceLocator) {
         $helper = new ViewHelper\Url();
         $helper->setRouter($serviceLocator->get('Router'));
         $match = $serviceLocator->get('application')->getMvcEvent()->getRouteMatch();
         if ($match instanceof RouteMatch) {
             $helper->setRouteMatch($match);
         }
         return $helper;
     });
     $plugins->setFactory('basepath', function ($sm) use($serviceLocator) {
         $config = $serviceLocator->get('Config');
         $config = $config['view_manager'];
         $basePathHelper = new ViewHelper\BasePath();
         if (isset($config['base_path'])) {
             $basePath = $config['base_path'];
         } else {
             $basePath = $serviceLocator->get('Request')->getBasePath();
         }
         $basePathHelper->setBasePath($basePath);
         return $basePathHelper;
     });
     /**
      * Configure doctype view helper with doctype from configuration, if available.
      *
      * Other view helpers depend on this to decide which spec to generate their tags
      * based on. This is why it must be set early instead of later in the layout phtml.
      */
     $plugins->setFactory('doctype', function ($sm) use($serviceLocator) {
         $config = $serviceLocator->get('Config');
         $config = $config['view_manager'];
         $doctypeHelper = new ViewHelper\Doctype();
         if (isset($config['doctype'])) {
             $doctypeHelper->setDoctype($config['doctype']);
         }
         return $doctypeHelper;
     });
     return $plugins;
 }
Ejemplo n.º 7
0
 /**
  * Create and return the view helper manager
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return ViewHelperInterface
  * @throws Exception\RuntimeException
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $plugins = parent::createService($serviceLocator);
     foreach ($this->defaultHelperMapClasses as $configClass) {
         if (is_string($configClass) && class_exists($configClass)) {
             $config = new $configClass();
             if (!$config instanceof ConfigInterface) {
                 throw new Exception\RuntimeException(sprintf('Invalid service manager configuration class provided; received "%s", expected class implementing %s', $configClass, 'Zend\\ServiceManager\\ConfigInterface'));
             }
             $config->configureServiceManager($plugins);
         }
     }
     // Configure URL view helper with router
     $plugins->setFactory('url', function () use($serviceLocator) {
         $helper = new ViewHelper\Url();
         $router = Console::isConsole() ? 'HttpRouter' : 'Router';
         $helper->setRouter($serviceLocator->get($router));
         $match = $serviceLocator->get('application')->getMvcEvent()->getRouteMatch();
         if ($match instanceof RouteMatch) {
             $helper->setRouteMatch($match);
         }
         return $helper;
     });
     $plugins->setFactory('basepath', function () use($serviceLocator) {
         $config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array();
         $basePathHelper = new ViewHelper\BasePath();
         if (Console::isConsole() && isset($config['view_manager']) && isset($config['view_manager']['base_path_console'])) {
             $basePathHelper->setBasePath($config['view_manager']['base_path_console']);
             return $basePathHelper;
         }
         if (isset($config['view_manager']) && isset($config['view_manager']['base_path'])) {
             $basePathHelper->setBasePath($config['view_manager']['base_path']);
             return $basePathHelper;
         }
         $request = $serviceLocator->get('Request');
         if (is_callable(array($request, 'getBasePath'))) {
             $basePathHelper->setBasePath($request->getBasePath());
         }
         return $basePathHelper;
     });
     /**
      * Configure doctype view helper with doctype from configuration, if available.
      *
      * Other view helpers depend on this to decide which spec to generate their tags
      * based on. This is why it must be set early instead of later in the layout phtml.
      */
     $plugins->setFactory('doctype', function () use($serviceLocator) {
         $config = $serviceLocator->has('Config') ? $serviceLocator->get('Config') : array();
         $config = isset($config['view_manager']) ? $config['view_manager'] : array();
         $doctypeHelper = new ViewHelper\Doctype();
         if (isset($config['doctype']) && $config['doctype']) {
             $doctypeHelper->setDoctype($config['doctype']);
         }
         return $doctypeHelper;
     });
     return $plugins;
 }
 /**
  * Create and return a factory for creating a URL helper.
  *
  * Retrieves the application and router from the servicemanager,
  * and the route match from the MvcEvent composed by the application,
  * using them to configure the helper.
  *
  * @param ContainerInterface $services
  * @return callable
  */
 private function createUrlHelperFactory(ContainerInterface $services)
 {
     return function () use($services) {
         $helper = new ViewHelper\Url();
         $helper->setRouter($services->get('HttpRouter'));
         $match = $services->get('Application')->getMvcEvent()->getRouteMatch();
         if ($match instanceof RouteMatch) {
             $helper->setRouteMatch($match);
         }
         return $helper;
     };
 }
Ejemplo n.º 9
0
 /**
  * @return UrlHelper
  */
 protected function getUrlHelper()
 {
     if ($this->urlHelper) {
         return $this->urlHelper;
     }
     if (method_exists($this->view, 'plugin')) {
         $this->urlHelper = $this->view->plugin($this->defaultUrlHelper);
     }
     if (!$this->urlHelper instanceof UrlHelper) {
         $this->urlHelper = new UrlHelper();
         $this->urlHelper->setView($this->getView());
     }
     return $this->urlHelper;
 }
Ejemplo n.º 10
0
 public function testHrefGeneratedIsRouteAware()
 {
     $page = new Page\Mvc(array('label' => 'foo', 'action' => 'myaction', 'controller' => 'mycontroller', 'route' => 'myroute', 'params' => array('page' => 1337)));
     $route = new RegexRoute('(lolcat/(?<action>[^/]+)/(?<page>\\d+))', '/lolcat/%action%/%page%', array('controller' => 'foobar', 'action' => 'bazbat', 'page' => 1));
     $router = new TreeRouteStack();
     $router->addRoute('myroute', $route);
     $routeMatch = new RouteMatch(array('controller' => 'foobar', 'action' => 'bazbat', 'page' => 1));
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($router);
     $urlHelper->setRouteMatch($routeMatch);
     $page->setUrlHelper($urlHelper);
     $page->setRouteMatch($routeMatch);
     $this->assertEquals('/lolcat/myaction/1337', $page->getHref());
 }
Ejemplo n.º 11
0
 /**
  * Get link to browse results (or null if no valid URL available)
  *
  * @param string $source AlphaBrowse index currently being used
  * @param array  $item   Item to link to
  *
  * @return string
  */
 public function getUrl($source, $item)
 {
     if ($item['count'] <= 0) {
         return null;
     }
     // Linking using bib ids is generally more reliable than doing searches for
     // headings, but headings give shorter queries and don't look as strange.
     if ($item['count'] < 5) {
         $safeIds = array_map([$this, 'escapeForSolr'], $item['ids']);
         $query = ['type' => 'ids', 'lookfor' => implode(' ', $safeIds)];
         if ($item['count'] == 1) {
             $query['jumpto'] = 1;
         }
     } else {
         $query = ['type' => ucwords($source) . 'Browse', 'lookfor' => $this->escapeForSolr($item['heading'])];
     }
     return $this->url->__invoke('search-results', [], ['query' => $query]);
 }
Ejemplo n.º 12
0
 /**
  * Create information representing an advanced search tab.
  *
  * @param string $class Search class ID
  * @param string $label Display text for tab
  *
  * @return array
  */
 protected function createAdvancedTab($class, $label)
 {
     // If an advanced search is available, link there; otherwise, just go
     // to the search home:
     $options = $this->results->get($class)->getOptions();
     $advSearch = $options->getAdvancedSearchAction();
     $url = $this->url->__invoke($advSearch ? $advSearch : $options->getSearchHomeAction());
     return ['class' => $class, 'label' => $label, 'selected' => false, 'url' => $url];
 }
 public function setUpHelpers()
 {
     if (isset($this->helpers)) {
         return;
     }
     $this->setupRouter();
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $this->linksHelper = $linksHelper = new HalHelper();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $this->helpers = $helpers = new HelperPluginManager();
     $helpers->setService('url', $urlHelper);
     $helpers->setService('serverUrl', $serverUrlHelper);
     $helpers->setService('hal', $linksHelper);
 }
Ejemplo n.º 14
0
 /**
  * Generates a url given the name of a route.
  *
  * @see    Zend\Mvc\Router\RouteInterface::assemble()
  * @param  string               $name               Name of the route
  * @param  array                $params             Parameters for the link
  * @param  array|\Traversable    $options            Options for the route
  * @param  bool                 $reuseMatchedParams Whether to reuse matched parameters
  * @return string Url                         For the link href attribute
  * @throws Exception\RuntimeException         If no RouteStackInterface was provided
  * @throws Exception\RuntimeException         If no RouteMatch was provided
  * @throws Exception\RuntimeException         If RouteMatch didn't contain a matched route name
  * @throws Exception\InvalidArgumentException If the params object was not an array or \Traversable object
  */
 public function __invoke($name = null, $params = [], $options = [], $reuseMatchedParams = false)
 {
     $url = parent::__invoke($name, $params, $options, $reuseMatchedParams);
     $locale = $this->moduleOptions->getCurrentLocale();
     if (isset($params['locale'])) {
         $locale = $params['locale'];
     }
     $url = '/' . $locale . $url;
     return $url;
 }
Ejemplo n.º 15
0
 /**
  * Generate URL to given controller and action
  *
  * @param string $controller Optional controller name (default: current controller)
  * @param string $action Optional action name (default: current action)
  * @param array $params Optional associative array of query parameters
  * @param bool $inheritParams Include request query parameters. Parameters in $params take precedence.
  * @return string Target URL
  */
 public function __invoke($controller = null, $action = null, $params = array(), $inheritParams = false)
 {
     $route = array();
     if ($controller) {
         $route['controller'] = $controller;
     }
     if ($action) {
         $route['action'] = $action;
     }
     if ($inheritParams and $this->_request instanceof \Zend\Http\Request) {
         // Merge current request parameters (parameters from $params take precedence)
         $params = array_merge($this->_request->getQuery()->toArray(), $params);
     }
     $options = array();
     if (!empty($params)) {
         // Cast values to string to support values that would otherwise get
         // ignored by Url helper, like objects implementing __toString()
         foreach ($params as $name => $value) {
             $options['query'][$name] = (string) $value;
         }
     }
     return $this->_url->__invoke('console', $route, $options, true);
 }
 public function setupHelpers()
 {
     if (!$this->router) {
         $this->setupRouter();
     }
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $propertiesHelper = new JsonLDHelper();
     $propertiesHelper->setUrlHelper($urlHelper);
     $propertiesHelper->setServerUrlHelper($serverUrlHelper);
     $propertyExtractor = new PropertyExtractor($serverUrlHelper, $urlHelper);
     $propertyCollectionExtractor = new PropertyCollectionExtractor($propertyExtractor);
     $propertiesHelper->setPropertyCollectionExtractor($propertyCollectionExtractor);
     $this->helpers = $helpers = new HelperPluginManager();
     $helpers->setService('url', $urlHelper);
     $helpers->setService('serverUrl', $serverUrlHelper);
     $helpers->setService('JsonLD', $propertiesHelper);
     $this->plugins = $plugins = new ControllerPluginManager();
     $plugins->setService('JsonLD', $propertiesHelper);
 }
Ejemplo n.º 17
0
 public function __invoke($name = null, $params = [], $options = [], $reuseMatchedParams = false)
 {
     if (null === $this->router) {
         throw new Exception\RuntimeException('No RouteStackInterface instance provided');
     }
     if (3 === func_num_args() && is_bool($options)) {
         $reuseMatchedParams = $options;
         $options = [];
     }
     // Inherit query parameters
     if ($reuseMatchedParams) {
         $providedQueryParams = isset($options['query']) ? $options['query'] : [];
         $currentQueryParams = $this->request->getQuery()->toArray();
         $options['query'] = array_merge($currentQueryParams, $providedQueryParams);
     }
     return parent::__invoke($name, $params, $options, $reuseMatchedParams);
 }
Ejemplo n.º 18
0
 public function __invoke($name = null, $params = [], $options = [], $reuseMatchedParams = false)
 {
     $uri = parent::__invoke($name, $params, $options, $reuseMatchedParams);
     if (false !== strpos($uri, '/admin')) {
         return $uri;
     }
     if (isset($params['locale'])) {
         $code = $params['locale'];
     } else {
         $locale = $this->translator->getLocale();
         $code = preg_replace('/\\_.*/', '', $locale);
     }
     $array = explode('/', $uri);
     $array = array_diff($array, ['']);
     array_unshift($array, $code);
     $uri = '/' . implode('/', $array);
     return $uri;
 }
Ejemplo n.º 19
0
 public function __invoke($name = null, $params = [], $options = [], $reuseMatchedParams = false, $useAlias = true)
 {
     $useCanonical = isset($options['force_canonical']) && $options['force_canonical'];
     $link = parent::__invoke($name, $params, $options, $reuseMatchedParams);
     if (!$useAlias) {
         return $link;
     }
     try {
         $aliasManager = $this->getAliasManager();
         $instance = $this->getInstanceManager()->getInstanceFromRequest();
         if ($useCanonical) {
             $options['force_canonical'] = false;
             $source = parent::__invoke($name, $params, $options, $reuseMatchedParams);
             $link = $aliasManager->findAliasBySource($source, $instance);
             return $this->getView()->serverUrl($link);
         }
         $link = $aliasManager->findAliasBySource($link, $instance);
     } catch (AliasNotFoundException $e) {
         // No alias was found -> nothing to do
     }
     return $link;
 }
Ejemplo n.º 20
0
 public function testIsActiveReturnsTrueWhenMatchingRoute()
 {
     $page = new Page\Mvc(array('label' => 'spiffyjrwashere', 'route' => 'lolfish'));
     $route = new LiteralRoute('/lolfish');
     $router = new TreeRouteStack();
     $router->addRoute('lolfish', $route);
     $routeMatch = new RouteMatch(array());
     $routeMatch->setMatchedRouteName('lolfish');
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($router);
     $urlHelper->setRouteMatch($routeMatch);
     $page->setUrlHelper($urlHelper);
     $page->setRouteMatch($routeMatch);
     $this->assertEquals(true, $page->isActive());
 }
Ejemplo n.º 21
0
 public function testRemovesModuleRouteListenerParamsWhenReusingMatchedParameters()
 {
     $router = new \Zend\Mvc\Router\Http\TreeRouteStack();
     $router->addRoute('default', array('type' => 'Zend\\Mvc\\Router\\Http\\Segment', 'options' => array('route' => '/:controller/:action', 'defaults' => array(ModuleRouteListener::MODULE_NAMESPACE => 'ZendTest\\Mvc\\Controller\\TestAsset', 'controller' => 'SampleController', 'action' => 'Dash')), 'child_routes' => array('wildcard' => array('type' => 'Zend\\Mvc\\Router\\Http\\Wildcard', 'options' => array('param_delimiter' => '=', 'key_value_delimiter' => '%')))));
     $routeMatch = new RouteMatch(array(ModuleRouteListener::MODULE_NAMESPACE => 'ZendTest\\Mvc\\Controller\\TestAsset', 'controller' => 'Rainbow'));
     $routeMatch->setMatchedRouteName('default/wildcard');
     $event = new MvcEvent();
     $event->setRouter($router)->setRouteMatch($routeMatch);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->onRoute($event);
     $helper = new UrlHelper();
     $helper->setRouter($router);
     $helper->setRouteMatch($routeMatch);
     $url = $helper->__invoke('default/wildcard', array('Twenty' => 'Cooler'), true);
     $this->assertEquals('/Rainbow/Dash=Twenty%Cooler', $url);
 }
Ejemplo n.º 22
0
 public function getViewUrl()
 {
     return Url::direct(array('game_id' => $this->game_id, 'game_name' => $this->homeTeam . 'vs' . $this->awayTeam), 'game-view');
 }