Commit abb88f9f authored by catch's avatar catch

Issue #2266377 by dawehner, bkosborne, pwolanin: Speed up UrlGenerator a...

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