diff --git a/tests/Unit/Utilities/FormatterTest.php b/tests/Unit/Utilities/FormatterTest.php new file mode 100644 index 0000000..dd9f0a2 --- /dev/null +++ b/tests/Unit/Utilities/FormatterTest.php @@ -0,0 +1,57 @@ +assertEquals($url, $formatter->normalizeUrl($url)); + } + + public function testNormalizeUrlWithSortedQuery() + { + $formatter = new Formatter(); + + $url = 'http://example.com/path/to?foo=bar&hoge=fuga'; + $this->assertEquals($url, $formatter->normalizeUrl($url)); + } + + public function testNormalizeUrlWithUnsortedQuery() + { + $formatter = new Formatter(); + + $url = 'http://example.com/path/to?hoge=fuga&foo=bar'; + $this->assertEquals('http://example.com/path/to?foo=bar&hoge=fuga', $formatter->normalizeUrl($url)); + } + + public function testNormalizeUrlWithSortedQueryAndFragment() + { + $formatter = new Formatter(); + + $url = 'http://example.com/path/to?foo=bar&hoge=fuga#fragment'; + $this->assertEquals($url, $formatter->normalizeUrl($url)); + } + + public function testNormalizeUrlWithFragment() + { + $formatter = new Formatter(); + + $url = 'http://example.com/path/to#fragment'; + $this->assertEquals($url, $formatter->normalizeUrl($url)); + } + + public function testNormalizeUrlWithSortedQueryAndZeroLengthFragment() + { + $formatter = new Formatter(); + + $url = 'http://example.com/path/to?foo=bar&hoge=fuga#'; + $this->assertEquals('http://example.com/path/to?foo=bar&hoge=fuga', $formatter->normalizeUrl($url)); + } +} \ No newline at end of file