// External URL
$data[] =
[Url::
fromUri('https://www.drupal.org'
), TRUE
];
// Existing routed URL.
$url = Url::
fromRoute('example.existing_route'
);
$url_generator =
$this->
createMock('Drupal\Core\Routing\UrlGeneratorInterface'
);
$url_generator->
expects($this->
any()) ->
method('generateFromRoute'
) ->
with('example.existing_route',
[],
[]) ->
willReturn('/example/existing'
);
$url->
setUrlGenerator($url_generator);
$data[] =
[$url, TRUE
];
// Non-existent routed URL.
$url = Url::
fromRoute('example.not_existing_route'
);
$url_generator =
$this->
createMock('Drupal\Core\Routing\UrlGeneratorInterface'
);
$url_generator->
expects($this->
any()) ->
method('generateFromRoute'
) ->
with('example.not_existing_route',
[],
[]) ->
willThrowException(new RouteNotFoundException());