Commit 08f9c8d8 authored by alexpott's avatar alexpott

Issue #2558189 by JeroenT, pwolanin, Cyberschorsch, SteffenR, Mile23: Remove...

Issue #2558189 by JeroenT, pwolanin, Cyberschorsch, SteffenR, Mile23: Remove usage of deprecated UrlGeneratorInterface::generateFromPath() in system module
parent ab1885c0
...@@ -132,7 +132,7 @@ function testDrupalRenderFormElements() { ...@@ -132,7 +132,7 @@ function testDrupalRenderFormElements() {
), ),
); );
$this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array( $this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array(
':href' => \Drupal::urlGenerator()->generateFromPath('common-test/destination', ['absolute' => TRUE]), ':href' => URL::fromRoute('common_test.destination')->setAbsolute()->toString(),
':title' => $element['#title'], ':title' => $element['#title'],
)); ));
......
...@@ -82,14 +82,14 @@ function testUrlAlter() { ...@@ -82,14 +82,14 @@ function testUrlAlter() {
* A string with the original path that is run through generateFrommPath(). * A string with the original path that is run through generateFrommPath().
* @param $final * @param $final
* A string with the expected result after generateFrommPath(). * A string with the expected result after generateFrommPath().
*
* @return * @return
* TRUE if $original was correctly altered to $final, FALSE otherwise. * TRUE if $original was correctly altered to $final, FALSE otherwise.
*/ */
protected function assertUrlOutboundAlter($original, $final) { protected function assertUrlOutboundAlter($original, $final) {
// Test outbound altering. // Test outbound altering.
$result = $this->container->get('url_generator')->generateFromPath(ltrim($original, '/')); $result = $this->container->get('path_processor_manager')->processOutbound($original);
$final = Url::fromUri('internal:' . $final)->toString(); return $this->assertIdentical($result, $final, format_string('Altered outbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
$this->assertIdentical($result, $final, format_string('Altered outbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
} }
/** /**
...@@ -99,12 +99,13 @@ protected function assertUrlOutboundAlter($original, $final) { ...@@ -99,12 +99,13 @@ protected function assertUrlOutboundAlter($original, $final) {
* The original path before it has been altered by inbound URL processing. * The original path before it has been altered by inbound URL processing.
* @param $final * @param $final
* A string with the expected result. * A string with the expected result.
*
* @return * @return
* TRUE if $original was correctly altered to $final, FALSE otherwise. * TRUE if $original was correctly altered to $final, FALSE otherwise.
*/ */
protected function assertUrlInboundAlter($original, $final) { protected function assertUrlInboundAlter($original, $final) {
// Test inbound altering. // Test inbound altering.
$result = $this->container->get('path.alias_manager')->getPathByAlias($original); $result = $this->container->get('path.alias_manager')->getPathByAlias($original);
$this->assertIdentical($result, $final, format_string('Altered inbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result))); return $this->assertIdentical($result, $final, format_string('Altered inbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
} }
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
use Drupal\simpletest\WebTestBase; use Drupal\simpletest\WebTestBase;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Drupal\Core\Url;
/** /**
* Functional class for the full integrated routing system. * Functional class for the full integrated routing system.
...@@ -181,10 +182,10 @@ public function testControllerResolutionPage() { ...@@ -181,10 +182,10 @@ public function testControllerResolutionPage() {
* Checks the generate method on the url generator using the front router. * Checks the generate method on the url generator using the front router.
*/ */
public function testUrlGeneratorFront() { public function testUrlGeneratorFront() {
global $base_path; $front_url = Url::fromRoute('<front>', [], ['absolute' => TRUE]);
// Compare to the site base URL.
$this->assertEqual($this->container->get('url_generator')->generate('<front>'), $base_path); $base_url = Url::fromUri('base:/', ['absolute' => TRUE]);
$this->assertEqual($this->container->get('url_generator')->generateFromPath('<front>'), $base_path); $this->assertIdentical($base_url->toString(), $front_url->toString());
} }
/** /**
......
...@@ -27,9 +27,7 @@ public function processInbound($path, Request $request) { ...@@ -27,9 +27,7 @@ public function processInbound($path, Request $request) {
} }
// Rewrite community/ to forum/. // Rewrite community/ to forum/.
if ($path == '/community' || strpos($path, '/community/') === 0) { $path = preg_replace('@^/community(.*)@', '/forum$1', $path);
$path = '/forum' . substr($path, 9);
}
if ($path == '/url-alter-test/bar') { if ($path == '/url-alter-test/bar') {
$path = '/url-alter-test/foo'; $path = '/url-alter-test/foo';
......
...@@ -31,9 +31,7 @@ public function processInbound($path, Request $request) { ...@@ -31,9 +31,7 @@ public function processInbound($path, Request $request) {
} }
// Rewrite community/ to forum/. // Rewrite community/ to forum/.
if ($path == '/community' || strpos($path, '/community/') === 0) { $path = preg_replace('@^/community(.*)@', '/forum$1', $path);
$path = '/forum' . substr($path, 10);
}
if ($path == '/url-alter-test/bar') { if ($path == '/url-alter-test/bar') {
$path = '/url-alter-test/foo'; $path = '/url-alter-test/foo';
...@@ -57,10 +55,7 @@ public function processOutbound($path, &$options = array(), Request $request = N ...@@ -57,10 +55,7 @@ public function processOutbound($path, &$options = array(), Request $request = N
} }
// Rewrite forum/ to community/. // Rewrite forum/ to community/.
if ($path == '/forum' || strpos($path, '/forum/') === 0) { return preg_replace('@^/forum(.*)@', '/community$1', $path);
$path = '/community' . substr($path, 5);
}
return $path;
} }
} }
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