You are here

public function UrlGeneratorTest::aliasManagerCallback in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::aliasManagerCallback()

Return value callback for the getAliasByPath() method on the mock alias manager.

Ensures that by default the call to getAliasByPath() will return the first argument that was passed in. We special-case the paths for which we wish it to return an actual alias.

Return value

string

File

core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php, line 187

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function aliasManagerCallback() {
  $args = func_get_args();
  switch ($args[0]) {
    case '/test/one':
      return '/hello/world';
    case '/test/two/5':
      return '/goodbye/cruel/world';
    case '/<front>':
      return '/';
    default:
      return $args[0];
  }
}