-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Request: Fix Referrer getter for malformed data + test
- Loading branch information
1 parent
1731439
commit b182d4e
Showing
2 changed files
with
50 additions
and
3 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,40 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Nette\Http\Request headers. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\Http; | ||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
test('', function () { | ||
$request = new Http\Request(new Http\UrlScript); | ||
|
||
Assert::null($request->getReferer()); | ||
}); | ||
|
||
|
||
test('', function () { | ||
$request = new Http\Request(new Http\UrlScript, null, null, null, [ | ||
'referer' => 'http://nette.org:8080/file.php?q=search', | ||
]); | ||
|
||
Assert::same('http://nette.org:8080/file.php?q=search', $request->getReferer()->getAbsoluteUrl()); | ||
}); | ||
|
||
|
||
test('', function () { | ||
$request = new Http\Request(new Http\UrlScript, null, null, null, [ | ||
'referer' => '/////', | ||
]); | ||
|
||
Assert::error(function () use ($request) { | ||
Assert::null($request->getReferer()); | ||
}, E_USER_NOTICE, 'Unable to parse Malformed Referer URI: /////'); | ||
}); |