/** * Tests the getRouteParameters method for a route with upcasted parameters. * * @covers ::getRouteParameters */ public function testGetRouteParametersForDynamicRouteWithUpcastedParameters() { $this->pluginDefinition = array('route_name' => 'test_route'); $route = new Route('/test-route/{parameter}'); $this->routeProvider->expects($this->once())->method('getRouteByName')->with('test_route')->will($this->returnValue($route)); $this->setupLocalTaskDefault(); $route_match = new RouteMatch('', $route, array('parameter' => (object) 'example2'), array('parameter' => 'example')); $this->assertEquals(array('parameter' => 'example'), $this->localTaskBase->getRouteParameters($route_match)); }
/** * Tests the getRouteParameters method for a route with upcasted parameters. * * @see \Drupal\Core\Menu\LocalTaskDefault::getRouteParameters() */ public function testGetRouteParametersForDynamicRouteWithUpcastedParameters() { $this->pluginDefinition = array('route_name' => 'test_route'); $this->routeProvider->expects($this->once())->method('getRouteByName')->with('test_route')->will($this->returnValue(new Route('/test-route/{parameter}'))); $this->setupLocalTaskDefault(); $request = new Request(); $raw_variables = new ParameterBag(); $raw_variables->set('parameter', 'example'); $request->attributes->set('parameter', (object) array('example2')); $request->attributes->set('_raw_variables', $raw_variables); $this->assertEquals(array('parameter' => 'example'), $this->localTaskBase->getRouteParameters($request)); }
/** * {@inheritdoc} */ public function getRouteParameters(RouteMatchInterface $route_match) { // Override the node here with the latest revision. $this->entity = $route_match->getParameter($this->pluginDefinition['entity_type_id']); return parent::getRouteParameters($route_match); }