Skip to content

Commit

Permalink
test(encoding): test unicode, delims, and res char
Browse files Browse the repository at this point in the history
  • Loading branch information
luqven committed May 5, 2021
1 parent ddb7e42 commit 48e423e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/Imgix/Tests/PathEncodingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Imgix\UrlBuilder;

class PathEncodingTest extends \PHPUnit\Framework\TestCase {
// NOTE: all the expected urls bellow resolve to an actual image.
const HOST = "sdk-test.imgix.net";

public function testBracketEncoding() {
$builder = new UrlBuilder(self::HOST, true, "", false);
$url = $builder->createURL("/ <>[]{}|\\^%.jpg");
$this->assertEquals(
"https://sdk-test.imgix.net/%20%3C%3E%5B%5D%7B%7D%7C%5C%5E%25.jpg",
$url);
}

public function testSpecialCharsEncoding() {
$builder = new UrlBuilder(self::HOST, true, "", false);
$url = $builder->createURL("&$+,:;=?@#.jpg");
$this->assertEquals(
"https://sdk-test.imgix.net/%26%24%2B%2C:%3B%3D%3F@%23.jpg",
$url);
}

public function testUnicodeEncoding() {
$builder = new UrlBuilder(self::HOST, true, "", false);
$url = $builder->createURL("/ساندویچ.jpg");
$this->assertEquals(
"https://sdk-test.imgix.net/%D8%B3%D8%A7%D9%86%D8%AF%D9%88%DB%8C%DA%86.jpg",
$url);
}

}
?>

0 comments on commit 48e423e

Please sign in to comment.