Merge pull request from ArthurHoaro/tag-http-referer

Prevent redirection loop everytime we rely on HTTP_REFERER
This commit is contained in:
VirtualTam 2015-07-12 19:56:13 +02:00
commit 5b0ebbc5de
3 changed files with 108 additions and 44 deletions

View file

@ -93,5 +93,30 @@ class UtilsTest extends PHPUnit_Framework_TestCase
$this->assertFalse(checkDateFormat('Y-m-d', '2015-06'));
$this->assertFalse(checkDateFormat('Ymd', 'DeLorean'));
}
/**
* Test generate location with valid data.
*/
public function testGenerateLocation() {
$ref = 'http://localhost/?test';
$this->assertEquals($ref, generateLocation($ref, 'localhost'));
$ref = 'http://localhost:8080/?test';
$this->assertEquals($ref, generateLocation($ref, 'localhost:8080'));
}
/**
* Test generate location - anti loop.
*/
public function testGenerateLocationLoop() {
$ref = 'http://localhost/?test';
$this->assertEquals('?', generateLocation($ref, 'localhost', ['test']));
}
/**
* Test generate location - from other domain.
*/
public function testGenerateLocationOut() {
$ref = 'http://somewebsite.com/?test';
$this->assertEquals('?', generateLocation($ref, 'localhost'));
}
}
?>