From 626c85c07d3abce66cda913aeb18efc07626d5c8 Mon Sep 17 00:00:00 2001 From: shibafu Date: Sat, 19 Jan 2019 02:17:49 +0900 Subject: [PATCH] =?UTF-8?q?URL=E6=AD=A3=E8=A6=8F=E5=8C=96=E3=81=AE?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Unit/Utilities/FormatterTest.php | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/Unit/Utilities/FormatterTest.php 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