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 JsonLDHelper(); $plugin->setController($controller); $plugin->setUrlHelper($urlHelper); $plugin->setServerUrlHelper($serverUrlHelper); $propertyExtractor = new PropertyExtractor($serverUrlHelper, $urlHelper); $propertyCollectionExtractor = new PropertyCollectionExtractor($propertyExtractor); $plugin->setPropertyCollectionExtractor($propertyCollectionExtractor); }
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); }