Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(encoding): add path encoding tests to image urls that resolve #80

Merged
merged 1 commit into from
May 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}
?>