Skip to content

Commit 5863e84

Browse files
committed
tests: testing HTTP vs HTTPS routes
1 parent 5b60e95 commit 5863e84

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

tests/Routers/Route.secured.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66

77
use Nette\Application\Routers\Route;
8+
use Nette\Application\Request;
9+
use Nette\Http\Url;
810
use Tester\Assert;
911

1012

@@ -13,6 +15,17 @@ require __DIR__ . '/../bootstrap.php';
1315
require __DIR__ . '/Route.php';
1416

1517

18+
$route = new Route('<param>', [
19+
'presenter' => 'Presenter',
20+
]);
21+
22+
$url = $route->constructUrl(
23+
new Request('Presenter', NULL, ['param' => 'any']),
24+
new Url('https://example.org')
25+
);
26+
Assert::same('http://example.org/any', $url);
27+
28+
1629
$route = new Route('<param>', [
1730
'presenter' => 'Presenter',
1831
], Route::SECURED);
@@ -21,3 +34,9 @@ testRouteIn($route, '/any', 'Presenter', [
2134
'param' => 'any',
2235
'test' => 'testvalue',
2336
], 'https://example.com/any?test=testvalue');
37+
38+
$url = $route->constructUrl(
39+
new Request('Presenter', NULL, ['param' => 'any']),
40+
new Url('http://example.org')
41+
);
42+
Assert::same('https://example.org/any', $url);

tests/Routers/SimpleRouter.phpt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,10 @@ Assert::same('12', $req->getParameter('id'));
3434
Assert::same('testvalue', $req->getParameter('test'));
3535
Assert::same('anyvalue', $req->getParameter('any'));
3636

37-
$url = $router->constructUrl($req, $httpRequest->getUrl());
38-
Assert::same('http://nette.org/file.php?action=action&test=testvalue&presenter=myPresenter', $url);
37+
$res = $router->constructUrl($req, $httpRequest->getUrl());
38+
Assert::same('http://nette.org/file.php?action=action&test=testvalue&presenter=myPresenter', $res);
39+
40+
41+
$url = new Http\UrlScript('https://nette.org/file.php');
42+
$res = $router->constructUrl($req, $url);
43+
Assert::same('http://nette.org/file.php?action=action&test=testvalue&presenter=myPresenter', $res);

0 commit comments

Comments
 (0)