URL正規化のテストを追加
This commit is contained in:
parent
b6bf1f99d8
commit
626c85c07d
57
tests/Unit/Utilities/FormatterTest.php
Normal file
57
tests/Unit/Utilities/FormatterTest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Utilities;
|
||||
|
||||
use App\Utilities\Formatter;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FormatterTest extends TestCase
|
||||
{
|
||||
public function testNormalizeUrlWithoutQuery()
|
||||
{
|
||||
$formatter = new Formatter();
|
||||
|
||||
$url = 'http://example.com/path/to';
|
||||
$this->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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user