diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2022-02-17 07:51:00 +0100 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2022-02-17 07:51:00 +0100 |
| commit | 38743404da21c61cc7fa65cf51e10eff21c08e21 (patch) | |
| tree | 0565678b2d62ae1fa14bc8393cafc8081c28229b /tests | |
| parent | 17c877e04cb7a01044caa9a73065430d0a573c86 (diff) | |
introduce js encodeURI() equivalent in php and use it for X-Location header, fixes #684
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/lib/FunctionsTest.php | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/unit/lib/FunctionsTest.php b/tests/unit/lib/FunctionsTest.php index 2d3c868..61ad409 100644 --- a/tests/unit/lib/FunctionsTest.php +++ b/tests/unit/lib/FunctionsTest.php @@ -42,7 +42,7 @@ class FunctionsTest extends \Codeception\Test\Unit $this->assertEquals(range(1, 7), array_flatten($array)); } - + function testRelsize() { // Test basic sizes and suffixed 's' if value is <> 1 @@ -62,7 +62,7 @@ class FunctionsTest extends \Codeception\Test\Unit $this->assertEquals('1 Exabyte', relsize(pow(1024, 6))); $this->assertEquals('1 Zettabyte', relsize(pow(1024, 7))); $this->assertEquals('1 Yottabyte', relsize(pow(1024, 8))); - + // Test displayed levels $this->assertEquals('1 Megabyte', relsize(1024 * 1024 + 2 * 1024 + 3, true, 1)); $this->assertEquals('1.5 Megabytes', relsize(1024 * 1024 + 512 * 1024 + 3, true, 1)); @@ -70,4 +70,18 @@ class FunctionsTest extends \Codeception\Test\Unit $this->assertEquals('1 Megabyte, 2 Kilobytes, 3 Bytes', relsize(1024 * 1024 + 2 * 1024 + 3, true, 3)); $this->assertEquals('1 Megabyte, 2 Kilobytes, 3 Bytes', relsize(1024 * 1024 + 2 * 1024 + 3, true, 0)); } + + public function testEncodeURI() + { + $input = 'A-Za-z0-9;,/?:@&=+$-_.!~*\'()#'; + $this->assertEquals($input, encodeURI($input)); + + $input = 'https://example.org/?x=шеллы'; + $output = 'https://example.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B'; + $this->assertEquals($output, encodeURI($input)); + + $input = 'https://mäuschen-hüpft.de/öffnungszeiten?menu=Spaß&page=23'; + $output = 'https://m%C3%A4uschen-h%C3%BCpft.de/%C3%B6ffnungszeiten?menu=Spa%C3%9F&page=23'; + $this->assertEquals($output, encodeURI($input)); + } } |
