Skip to content

Commit

Permalink
tests: testing HTTP vs HTTPS routes
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 3, 2019
1 parent 6df12ee commit a19d24b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
19 changes: 19 additions & 0 deletions tests/Route/secured.phpt
Expand Up @@ -5,6 +5,8 @@
*/

use Nette\Application\Routers\Route;
use Nette\Application\Request;
use Nette\Http\Url;
use Tester\Assert;


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


$route = new Route('<param>', [
'presenter' => 'Presenter',
]);

$url = $route->constructUrl(
new Request('Presenter', NULL, ['param' => 'any']),
new Url('https://example.org')
);
Assert::same('http://example.org/any', $url);


$route = new Route('<param>', [
'presenter' => 'Presenter',
], Route::SECURED);
Expand All @@ -21,3 +34,9 @@ testRouteIn($route, '/any', 'Presenter', [
'param' => 'any',
'test' => 'testvalue',
], 'https://example.com/any?test=testvalue');

$url = $route->constructUrl(
new Request('Presenter', NULL, ['param' => 'any']),
new Url('http://example.org')
);
Assert::same('https://example.org/any', $url);
9 changes: 7 additions & 2 deletions tests/SimpleRouter/basic.phpt
Expand Up @@ -34,5 +34,10 @@ Assert::same('12', $req->getParameters()['id']);
Assert::same('testvalue', $req->getParameters()['test']);
Assert::same('anyvalue', $req->getParameters()['any']);

$url = $router->constructUrl($req, $httpRequest->getUrl());
Assert::same('http://nette.org/file.php?action=action&test=testvalue&presenter=myPresenter', $url);
$res = $router->constructUrl($req, $httpRequest->getUrl());
Assert::same('http://nette.org/file.php?action=action&test=testvalue&presenter=myPresenter', $res);


$url = new Http\UrlScript('https://nette.org/file.php');
$res = $router->constructUrl($req, $url);
Assert::same('http://nette.org/file.php?action=action&test=testvalue&presenter=myPresenter', $res);

0 comments on commit a19d24b

Please sign in to comment.