-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Presenter: removed static from refUrl variable (#80)
- Loading branch information
Showing
2 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Nette\Application\UI\Presenter::link() | ||
*/ | ||
|
||
use Nette\Http, | ||
Nette\Application, | ||
Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
class TestPresenter extends Application\UI\Presenter | ||
{ | ||
|
||
protected function createTemplate($class = NULL) | ||
{ | ||
} | ||
|
||
} | ||
|
||
class MockPresenterFactory extends Nette\Object implements Nette\Application\IPresenterFactory | ||
{ | ||
function getPresenterClass(& $name) | ||
{ | ||
return str_replace(':', 'Module\\', $name) . 'Presenter'; | ||
} | ||
|
||
function createPresenter($name) | ||
{} | ||
} | ||
|
||
function testLink($domain) | ||
{ | ||
$url = new Http\UrlScript('http://' . $domain . '/index.php'); | ||
$url->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'); |