Unverified Commit be4d1ec8 authored by alexpott's avatar alexpott
Browse files

Issue #3114869 by andypost, Gábor Hojtsy, catch:...

Issue #3114869 by andypost, Gábor Hojtsy, catch: \Drupal\Core\Routing\Router::generate() is deprecated but it is on an interface
parent 0eef97e2
......@@ -331,7 +331,7 @@ public function getRouteCollection() {
* {@inheritdoc}
*/
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) {
@trigger_error('Use the \Drupal\Core\Url object instead', E_USER_DEPRECATED);
@trigger_error(__METHOD__ . '() is deprecated in drupal:8.3.0 and will throw an exception from drupal:10.0.0. Use the \Drupal\Core\Url object instead. See https://www.drupal.org/node/2820197', E_USER_DEPRECATED);
return $this->urlGenerator->generate($name, $parameters, $referenceType);
}
......
<?php
namespace Drupal\Tests\Core\Routing;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\Routing\Router;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Tests\UnitTestCase;
use Prophecy\Argument;
/**
* @coversDefaultClass \Drupal\Core\Routing\Router
* @group Routing
* @group legacy
*/
class RouterLegacyTest extends UnitTestCase {
/**
* @covers ::generate
* @expectedDeprecation Drupal\Core\Routing\Router::generate() is deprecated in drupal:8.3.0 and will throw an exception from drupal:10.0.0. Use the \Drupal\Core\Url object instead. See https://www.drupal.org/node/2820197
*/
public function testGenerateDeprecated() {
$route_provider = $this->prophesize(RouteProviderInterface::class);
$current_path_stack = $this->prophesize(CurrentPathStack::class);
$url_generator = $this->prophesize(UrlGeneratorInterface::class);
$route_name = 'test.route';
$route_path = '/test';
$url_generator
->generate($route_name, Argument::any(), Argument::any())
->willReturn($route_path);
$router = new Router($route_provider->reveal(), $current_path_stack->reveal(), $url_generator->reveal());
$this->assertEquals($route_path, $router->generate($route_name));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment