Issue #2266377 by dawehner, bkosborne, pwolanin: Speed up UrlGenerator a little by setting the 'external' option in the Url object .
parent
5cbb82bb0a
commit
abb88f9f78
|
@ -171,6 +171,8 @@ class Url extends DependencySerialization {
|
||||||
// Set empty route name and parameters.
|
// Set empty route name and parameters.
|
||||||
$this->routeName = NULL;
|
$this->routeName = NULL;
|
||||||
$this->routeParameters = array();
|
$this->routeParameters = array();
|
||||||
|
// Flag the path as external so the UrlGenerator does not need to check.
|
||||||
|
$this->options['external'] = TRUE;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,7 @@ class ExternalUrlTest extends UnitTestCase {
|
||||||
$this->urlGenerator = $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface');
|
$this->urlGenerator = $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface');
|
||||||
$this->urlGenerator->expects($this->any())
|
$this->urlGenerator->expects($this->any())
|
||||||
->method('generateFromPath')
|
->method('generateFromPath')
|
||||||
->will($this->returnCallback(function ($path) {
|
->will($this->returnArgument(0));
|
||||||
return $path;
|
|
||||||
}));
|
|
||||||
|
|
||||||
$this->router = $this->getMock('Drupal\Tests\Core\Routing\TestRouterInterface');
|
$this->router = $this->getMock('Drupal\Tests\Core\Routing\TestRouterInterface');
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
@ -143,7 +141,7 @@ class ExternalUrlTest extends UnitTestCase {
|
||||||
public function testToArray(Url $url) {
|
public function testToArray(Url $url) {
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'path' => $this->path,
|
'path' => $this->path,
|
||||||
'options' => array(),
|
'options' => array('external' => TRUE),
|
||||||
);
|
);
|
||||||
$this->assertSame($expected, $url->toArray());
|
$this->assertSame($expected, $url->toArray());
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,9 @@ use Drupal\Tests\UnitTestCase;
|
||||||
*
|
*
|
||||||
* @see \Drupal\Core\Utility\LinkGenerator
|
* @see \Drupal\Core\Utility\LinkGenerator
|
||||||
*
|
*
|
||||||
|
* @group Drupal
|
||||||
|
* @group Utility
|
||||||
|
*
|
||||||
* @coversDefaultClass \Drupal\Core\Utility\LinkGenerator
|
* @coversDefaultClass \Drupal\Core\Utility\LinkGenerator
|
||||||
*/
|
*/
|
||||||
class LinkGeneratorTest extends UnitTestCase {
|
class LinkGeneratorTest extends UnitTestCase {
|
||||||
|
@ -159,8 +162,8 @@ class LinkGeneratorTest extends UnitTestCase {
|
||||||
public function testGenerateFromUrlExternal() {
|
public function testGenerateFromUrlExternal() {
|
||||||
$this->urlGenerator->expects($this->once())
|
$this->urlGenerator->expects($this->once())
|
||||||
->method('generateFromPath')
|
->method('generateFromPath')
|
||||||
->with('http://drupal.org', array('set_active_class' => TRUE) + $this->defaultOptions)
|
->with('http://drupal.org', array('set_active_class' => TRUE, 'external' => TRUE) + $this->defaultOptions)
|
||||||
->will($this->returnValue('http://drupal.org'));
|
->will($this->returnArgument(0));
|
||||||
|
|
||||||
$this->moduleHandler->expects($this->once())
|
$this->moduleHandler->expects($this->once())
|
||||||
->method('alter')
|
->method('alter')
|
||||||
|
|
Loading…
Reference in New Issue