Skip to content

Commit f0724d6

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

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

tests/Routers/Route.basic.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,9 @@ testRouteIn($route, '/presenter', 'Presenter', [
6464
], '/presenter/?test=testvalue');
6565

6666
testRouteIn($route, '/');
67+
68+
testRouteIn($route, '/presenter', 'Presenter', [
69+
'id' => '',
70+
'action' => 'default',
71+
'test' => 'testvalue',
72+
], '/presenter/?test=testvalue', TRUE);

tests/Routers/Route.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use Tester\Assert;
88

99

10-
function testRouteIn(Nette\Application\IRouter $route, $url, $expectedPresenter = NULL, $expectedParams = NULL, $expectedUrl = NULL)
10+
function testRouteIn(Nette\Application\IRouter $route, $url, $expectedPresenter = NULL, $expectedParams = NULL, $expectedUrl = NULL, $https = FALSE)
1111
{
12-
$url = new Nette\Http\UrlScript("http://example.com$url");
12+
$url = new Nette\Http\UrlScript(($https ? 'https' : 'http') . "://example.com$url");
1313
$url->appendQuery([
1414
'test' => 'testvalue',
1515
'presenter' => 'querypresenter',

tests/Routers/Route.secured.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ testRouteIn($route, '/any', 'Presenter', [
2121
'param' => 'any',
2222
'test' => 'testvalue',
2323
], 'https://example.com/any?test=testvalue');
24+
25+
testRouteIn($route, '/any', 'Presenter', [
26+
'param' => 'any',
27+
'test' => 'testvalue',
28+
], 'https://example.com/any?test=testvalue', TRUE);

tests/Routers/Route.withAbsolutePath.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ testRouteIn($route, '/abc', 'Default', [
2323
'action' => 'default',
2424
'test' => 'testvalue',
2525
], '/abc/?test=testvalue');
26+
27+
testRouteIn($route, '/abc', 'Default', [
28+
'abspath' => 'abc',
29+
'action' => 'default',
30+
'test' => 'testvalue',
31+
], '/abc/?test=testvalue', TRUE);

tests/Routers/Route.withHost.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ testRouteIn($route, '/abc', 'Default', [
2525
'action' => 'default',
2626
'test' => 'testvalue',
2727
], '/abc?test=testvalue');
28+
29+
testRouteIn($route, '/abc', 'Default', [
30+
'host' => 'example',
31+
'domain' => 'com',
32+
'path' => 'abc',
33+
'action' => 'default',
34+
'test' => 'testvalue',
35+
], '/abc?test=testvalue', TRUE);

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)