From fb53532c783cd969d23f505de65d7d5fe64b2b76 Mon Sep 17 00:00:00 2001 From: Josef Cech Date: Wed, 27 May 2015 15:48:39 +0200 Subject: [PATCH] Presenter: removed static from refUrl variable --- src/Application/UI/Presenter.php | 7 ++- tests/Application/Presenter.twoDomains.phpt | 56 +++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 tests/Application/Presenter.twoDomains.phpt diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 4e5968fed..976b2e8af 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -126,6 +126,9 @@ abstract class Presenter extends Control implements Application\IPresenter /** @var ITemplateFactory */ private $templateFactory; + /** @var Nette\Http\Url */ + private $refUrlCache; + public function __construct() { @@ -973,9 +976,9 @@ protected function createRequest($component, $destination, array $args, $mode) } // CONSTRUCT URL - static $refUrl; + $refUrl = $this->refUrlCache; if ($refUrl === NULL) { - $refUrl = new Http\Url($this->httpRequest->getUrl()); + $this->refUrlCache = $refUrl = new Http\Url($this->httpRequest->getUrl()); $refUrl->setPath($this->httpRequest->getUrl()->getScriptPath()); } if (!$this->router) { diff --git a/tests/Application/Presenter.twoDomains.phpt b/tests/Application/Presenter.twoDomains.phpt new file mode 100644 index 000000000..badb81b53 --- /dev/null +++ b/tests/Application/Presenter.twoDomains.phpt @@ -0,0 +1,56 @@ +setScriptPath('/index.php'); + + $presenter = new TestPresenter; + $presenter->injectPrimary( + NULL, + new MockPresenterFactory, + new Application\Routers\SimpleRouter, + new Http\Request($url), + new Http\Response + ); + + $request = new Application\Request('Test', Http\Request::GET, []); + $presenter->run($request); + + Assert::same( 'http://' . $domain . '/index.php?action=default&presenter=Test', $presenter->link('//this') ); +} + +testLink('first.localhost'); +testLink('second.localhost');