Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/PHPUnit/Unit/UrlTest.php')
-rw-r--r--tests/PHPUnit/Unit/UrlTest.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/UrlTest.php b/tests/PHPUnit/Unit/UrlTest.php
index 6f9c50d614..bb4a2ab1ba 100644
--- a/tests/PHPUnit/Unit/UrlTest.php
+++ b/tests/PHPUnit/Unit/UrlTest.php
@@ -73,6 +73,43 @@ class UrlTest extends \PHPUnit_Framework_TestCase
}
/**
+ * @dataProvider getProtocol
+ */
+ public function test_getCurrentScheme_ProtoHeaderShouldPrecedenceHttpsHeader($proto)
+ {
+ $_SERVER['HTTPS'] = 'on';
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = $proto;
+ $this->assertEquals($proto, Url::getCurrentScheme());
+
+ unset($_SERVER['HTTP_X_FORWARDED_PROTO']);
+ unset($_SERVER['HTTPS']);
+ }
+
+ /**
+ * @dataProvider getProtocol
+ */
+ public function test_getCurrentScheme_shouldDetectSecureFromHttpsHeader()
+ {
+ $_SERVER['HTTPS'] = 'on';
+ $this->assertEquals('https', Url::getCurrentScheme());
+
+ unset($_SERVER['HTTPS']);
+ }
+
+ /**
+ * @dataProvider getProtocol
+ */
+ public function test_getCurrentScheme_shouldBeHttpByDefault()
+ {
+ $this->assertEquals('http', Url::getCurrentScheme());
+ }
+
+ public function getProtocol()
+ {
+ return array(array('http'), array('https'));
+ }
+
+ /**
* Dataprovider for testIsLocalUrl
*/
public function getLocalUrls()