diff --git a/src/Tests/TokenCurrentPageTest.php b/src/Tests/TokenCurrentPageTest.php
index 075921e..2eda343 100644
--- a/src/Tests/TokenCurrentPageTest.php
+++ b/src/Tests/TokenCurrentPageTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\token\Tests;
 
+use Drupal\Core\Url;
 /**
  * Test the [current-page:*] tokens.
  *
@@ -19,14 +20,14 @@ class TokenCurrentPageTest extends TokenTestBase {
   function testCurrentPageTokens() {
     $tokens = array(
       '[current-page:title]' => t('Log in'),
-      '[current-page:url]' => \Drupal::url('user.login', [], array('absolute' => TRUE)),
-      '[current-page:url:absolute]' => \Drupal::url('user.login', [], array('absolute' => TRUE)),
-      '[current-page:url:relative]' => \Drupal::url('user.login'),
+      '[current-page:url]' => Url::fromRoute('user.login', [], array('absolute' => TRUE))->toString(),
+      '[current-page:url:absolute]' => Url::fromRoute('user.login', [], array('absolute' => TRUE))->toString(),
+      '[current-page:url:relative]' => Url::fromRoute('user.login')->toString(),
       '[current-page:url:path]' => '/user/login',
       '[current-page:url:args:value:0]' => 'user',
       '[current-page:url:args:value:1]' => 'login',
       '[current-page:url:args:value:2]' => NULL,
-      '[current-page:url:unaliased]' => \Drupal::url('user.login', [], array('absolute' => TRUE, 'alias' => TRUE)),
+      '[current-page:url:unaliased]' => Url::fromRoute('user.login', [], array('absolute' => TRUE, 'alias' => TRUE))->toString(),
       '[current-page:page-number]' => 1,
       '[current-page:query:foo]' => NULL,
       '[current-page:query:bar]' => NULL,
diff --git a/src/Tests/TokenMenuTest.php b/src/Tests/TokenMenuTest.php
index 2077a34..327c5a7 100644
--- a/src/Tests/TokenMenuTest.php
+++ b/src/Tests/TokenMenuTest.php
@@ -3,6 +3,7 @@
 namespace Drupal\token\Tests;
 
 use Drupal\node\Entity\Node;
+use Drupal\Core\Url;
 
 /**
  * Tests menu tokens.
@@ -56,13 +57,13 @@ class TokenMenuTest extends TokenTestBase {
       'menu:machine-name' => $menu->id(),
       'menu:description' => 'The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.',
       'menu:menu-link-count' => '2',
-      'menu:edit-url' => \Drupal::url('entity.menu.edit_form', ['menu' => 'main-menu'], array('absolute' => TRUE)),
-      'url' => \Drupal::url('system.admin_config', [], array('absolute' => TRUE)),
-      'url:absolute' => \Drupal::url('system.admin_config', [], array('absolute' => TRUE)),
-      'url:relative' => \Drupal::url('system.admin_config', [], array('absolute' => FALSE)),
+      'menu:edit-url' => Url::fromRoute('entity.menu.edit_form', ['menu' => 'main-menu'], array('absolute' => TRUE))->toString(),
+      'url' => Url::fromRoute('system.admin_config', [], array('absolute' => TRUE))->toString(),
+      'url:absolute' => Url::fromRoute('system.admin_config', [], array('absolute' => TRUE))->toString(),
+      'url:relative' => Url::fromRoute('system.admin_config', [], array('absolute' => FALSE))->toString(),
       'url:path' => '/admin/config',
       'url:alias' => '/admin/config',
-      'edit-url' => \Drupal::url('entity.menu_link_content.canonical', ['menu_link_content' => $parent_link->id()], array('absolute' => TRUE)),
+      'edit-url' => Url::fromRoute('entity.menu_link_content.canonical', ['menu_link_content' => $parent_link->id()], array('absolute' => TRUE))->toString(),
       'parent' => 'Administration',
       'parent:id' => $root_link->getPluginId(),
       'parent:title' => 'Administration',
diff --git a/tests/src/Kernel/CommentTest.php b/tests/src/Kernel/CommentTest.php
index e35cf3f..499f087 100644
--- a/tests/src/Kernel/CommentTest.php
+++ b/tests/src/Kernel/CommentTest.php
@@ -6,6 +6,7 @@ use Drupal\comment\Entity\Comment;
 use Drupal\comment\Tests\CommentTestTrait;
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
+use Drupal\Core\Url;
 
 /**
  * Tests comment tokens.
@@ -86,7 +87,7 @@ class CommentTest extends KernelTestBase {
     $comment->save();
 
     // Fix http://example.com/index.php/comment/1 fails 'url:path' test.
-    $comment_path = \Drupal::url('entity.comment.canonical', array('comment' => $comment->id()));
+    $comment_path = Url::fromRoute('entity.comment.canonical', array('comment' => $comment->id()))->toString();
 
     $tokens = array(
       'url' => $comment->urlInfo('canonical', ['fragment' => "comment-{$comment->id()}"])->setAbsolute()->toString(),
diff --git a/tests/src/Kernel/NodeTest.php b/tests/src/Kernel/NodeTest.php
index 0ae554e..31d1a39 100644
--- a/tests/src/Kernel/NodeTest.php
+++ b/tests/src/Kernel/NodeTest.php
@@ -4,6 +4,7 @@ namespace Drupal\Tests\token\Kernel;
 
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
+use Drupal\Core\Url;
 
 /**
  * Test the node and content type tokens.
@@ -53,15 +54,15 @@ class NodeTest extends KernelTestBase {
     $tokens = array(
       'log' => $page->revision_log->value,
       'url:path' => '/content/source-node',
-      'url:absolute' => \Drupal::url('entity.node.canonical', ['node' => $page->id()], array('absolute' => TRUE)),
-      'url:relative' => \Drupal::url('entity.node.canonical', ['node' => $page->id()], array('absolute' => FALSE)),
+      'url:absolute' => Url::fromRoute('entity.node.canonical', ['node' => $page->id()], array('absolute' => TRUE))->toString,
+      'url:relative' => Url::fromRoute('entity.node.canonical', ['node' => $page->id()], array('absolute' => FALSE))->toString(),
       'url:unaliased:path' => "/node/{$page->id()}",
       'content-type' => 'Basic page',
       'content-type:name' => 'Basic page',
       'content-type:machine-name' => 'page',
       'content-type:description' => "Use <em>basic pages</em> for your static content, such as an 'About us' page.",
       'content-type:node-count' => 1,
-      'content-type:edit-url' => \Drupal::url('entity.node_type.edit_form', ['node_type' => 'page'], array('absolute' => TRUE)),
+      'content-type:edit-url' => Url::fromRoute('entity.node_type.edit_form', ['node_type' => 'page'], array('absolute' => TRUE))->toString(),
       // Deprecated tokens.
       'type' => 'page',
       'type-name' => 'Basic page',
@@ -77,15 +78,15 @@ class NodeTest extends KernelTestBase {
     $tokens = array(
       'log' => '',
       'url:path' => "/node/{$article->id()}",
-      'url:absolute' => \Drupal::url('entity.node.canonical', ['node' => $article->id()], array('absolute' => TRUE)),
-      'url:relative' => \Drupal::url('entity.node.canonical', ['node' => $article->id()], array('absolute' => FALSE)),
+      'url:absolute' => Url::fromRoute('entity.node.canonical', ['node' => $article->id()], array('absolute' => TRUE))->toString(),
+      'url:relative' => Url::fromRoute('entity.node.canonical', ['node' => $article->id()], array('absolute' => FALSE))->toString(),
       'url:unaliased:path' => "/node/{$article->id()}",
       'content-type' => 'Article',
       'content-type:name' => 'Article',
       'content-type:machine-name' => 'article',
       'content-type:description' => "Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.",
       'content-type:node-count' => 1,
-      'content-type:edit-url' => \Drupal::url('entity.node_type.edit_form', ['node_type' => 'article'], array('absolute' => TRUE)),
+      'content-type:edit-url' => Url::fromRoute('entity.node_type.edit_form', ['node_type' => 'article'], array('absolute' => TRUE))->toString(),
       // Deprecated tokens.
       'type' => 'article',
       'type-name' => 'Article',
diff --git a/tests/src/Kernel/TaxonomyTest.php b/tests/src/Kernel/TaxonomyTest.php
index 311c22b..3ed8873 100644
--- a/tests/src/Kernel/TaxonomyTest.php
+++ b/tests/src/Kernel/TaxonomyTest.php
@@ -4,6 +4,7 @@ namespace Drupal\Tests\token\Kernel;
 
 use Drupal\Component\Utility\Unicode;
 use Drupal\taxonomy\Entity\Vocabulary;
+use Drupal\Core\Url;
 
 /**
  * Tests taxonomy tokens.
@@ -43,12 +44,12 @@ class TaxonomyTest extends KernelTestBase {
   function testTaxonomyTokens() {
     $root_term = $this->addTerm($this->vocab, array('name' => 'Root term', 'path' => array('alias' => '/root-term')));
     $tokens = array(
-      'url' => \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $root_term->id()], array('absolute' => TRUE)),
-      'url:absolute' => \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $root_term->id()], array('absolute' => TRUE)),
-      'url:relative' => \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $root_term->id()], array('absolute' => FALSE)),
+      'url' => Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term' => $root_term->id()], array('absolute' => TRUE))->toString(),
+      'url:absolute' => Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term' => $root_term->id()], array('absolute' => TRUE))->toString(),
+      'url:relative' => Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term' => $root_term->id()], array('absolute' => FALSE))->toString(),
       'url:path' => '/root-term',
       'url:unaliased:path' => "/taxonomy/term/{$root_term->id()}",
-      'edit-url' => \Drupal::url('entity.taxonomy_term.edit_form', ['taxonomy_term' => $root_term->id()], array('absolute' => TRUE)),
+      'edit-url' => Url::fromRoute('entity.taxonomy_term.edit_form', ['taxonomy_term' => $root_term->id()], array('absolute' => TRUE))->toString(),
       'parents' => NULL,
       'parents:count' => NULL,
       'parents:keys' => NULL,
@@ -60,12 +61,12 @@ class TaxonomyTest extends KernelTestBase {
 
     $parent_term = $this->addTerm($this->vocab, array('name' => 'Parent term', 'parent' => $root_term->id()));
     $tokens = array(
-      'url' => \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $parent_term->id()], array('absolute' => TRUE)),
-      'url:absolute' => \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $parent_term->id()], array('absolute' => TRUE)),
-      'url:relative' => \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $parent_term->id()], array('absolute' => FALSE)),
+      'url' => Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term' => $parent_term->id()], array('absolute' => TRUE))->toString(),
+      'url:absolute' => Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term' => $parent_term->id()], array('absolute' => TRUE))->toString(),
+      'url:relative' => Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term' => $parent_term->id()], array('absolute' => FALSE))->toString(),
       'url:path' => "/taxonomy/term/{$parent_term->id()}",
       'url:unaliased:path' => "/taxonomy/term/{$parent_term->id()}",
-      'edit-url' => \Drupal::url('entity.taxonomy_term.edit_form', ['taxonomy_term' => $parent_term->id()], array('absolute' => TRUE)),
+      'edit-url' => Url::fromRoute('entity.taxonomy_term.edit_form', ['taxonomy_term' => $parent_term->id()], array('absolute' => TRUE))->toString(),
       'parents' => 'Root term',
       'parents:count' => 1,
       'parents:keys' => $root_term->id(),
@@ -92,7 +93,7 @@ class TaxonomyTest extends KernelTestBase {
     $vocabulary = $this->vocab;
     $tokens = array(
       'machine-name' => 'tags',
-      'edit-url' => \Drupal::url('entity.taxonomy_vocabulary.edit_form', ['taxonomy_vocabulary' => $vocabulary->id()], array('absolute' => TRUE)),
+      'edit-url' => Url::fromRoute('entity.taxonomy_vocabulary.edit_form', ['taxonomy_vocabulary' => $vocabulary->id()], array('absolute' => TRUE))->toString(),
     );
     $this->assertTokens('vocabulary', array('vocabulary' => $vocabulary), $tokens);
   }
diff --git a/token.tokens.inc b/token.tokens.inc
index f38955a..cd081a9 100644
--- a/token.tokens.inc
+++ b/token.tokens.inc
@@ -497,7 +497,7 @@ function token_tokens($type, array $tokens, array $data = array(), array $option
     foreach ($tokens as $name => $original) {
       switch ($name) {
         case 'edit-url':
-          $replacements[$original] = \Drupal::url('entity.taxonomy_term.edit_form', ['taxonomy_term' => $term->id()], $url_options);
+          $replacements[$original] = Url::fromRoute('entity.taxonomy_term.edit_form', ['taxonomy_term' => $term->id()], $url_options)->toString();
           break;
 
         case 'parents':
@@ -545,7 +545,7 @@ function token_tokens($type, array $tokens, array $data = array(), array $option
           $replacements[$original] = $vocabulary->id();
           break;
         case 'edit-url':
-          $replacements[$original] = \Drupal::url('entity.taxonomy_vocabulary.edit_form', ['taxonomy_vocabulary' => $vocabulary->id()], $url_options);
+          $replacements[$original] = Url::fromRoute('entity.taxonomy_vocabulary.edit_form', ['taxonomy_vocabulary' => $vocabulary->id()], $url_options)->toString();
           break;
       }
     }
@@ -1153,7 +1153,7 @@ function menu_ui_tokens($type, $tokens, array $data = array(), array $options =
           break;
 
         case 'edit-url':
-          $replacements[$original] = \Drupal::url('entity.menu.edit_form', ['menu' => $menu->id()], $url_options);
+          $replacements[$original] = Url::fromRoute('entity.menu.edit_form', ['menu' => $menu->id()], $url_options)->toString();
           break;
       }
     }
