X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FUrl%2FUrlTest.php;h=db229ce0d87c544ff912fd5240cc6a15dccaa950;hb=067c2dd8f5f6eb6cc808ddc4bd30aec104caf73d;hp=a64a73eae183e82672e3647c8a8249cdfa26c189;hpb=11609d9fd8ba53f049e6c913d8e3affab6cfc9ce;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/Url/UrlTest.php b/tests/Url/UrlTest.php index a64a73ea..db229ce0 100644 --- a/tests/Url/UrlTest.php +++ b/tests/Url/UrlTest.php @@ -16,7 +16,7 @@ class UrlTest extends PHPUnit_Framework_TestCase /** * Helper method */ - private function assertUrlIsCleaned($query='', $fragment='') + private function assertUrlIsCleaned($query = '', $fragment = '') { $url = new Url(self::$baseUrl.$query.$fragment); $url->cleanup(); @@ -85,6 +85,7 @@ class UrlTest extends PHPUnit_Framework_TestCase $this->assertUrlIsCleaned('?utm_term=1n4l'); $this->assertUrlIsCleaned('?xtor=some-url'); + $this->assertUrlIsCleaned('?PHPSESSID=012345678910111213'); } /** @@ -134,13 +135,13 @@ class UrlTest extends PHPUnit_Framework_TestCase 'about://reader?url=' . urlencode(self::$baseUrl .'?my=stuff&is=kept') ); $this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup()); - } /** * Test default http scheme. */ - public function testDefaultScheme() { + public function testDefaultScheme() + { $url = new Url(self::$baseUrl); $this->assertEquals('http', $url->getScheme()); $url = new Url('domain.tld'); @@ -156,7 +157,7 @@ class UrlTest extends PHPUnit_Framework_TestCase /** * Test add trailing slash. */ - function testAddTrailingSlash() + public function testAddTrailingSlash() { $strOn = 'http://randomstr.com/test/'; $strOff = 'http://randomstr.com/test'; @@ -167,7 +168,7 @@ class UrlTest extends PHPUnit_Framework_TestCase /** * Test valid HTTP url. */ - function testUrlIsHttp() + public function testUrlIsHttp() { $url = new Url(self::$baseUrl); $this->assertTrue($url->isHttp()); @@ -176,9 +177,24 @@ class UrlTest extends PHPUnit_Framework_TestCase /** * Test non HTTP url. */ - function testUrlIsNotHttp() + public function testUrlIsNotHttp() { $url = new Url('ftp://save.tld/mysave'); $this->assertFalse($url->isHttp()); } + + /** + * Test International Domain Name to ASCII conversion + */ + public function testIdnToAscii() + { + $ind = 'http://www.académie-française.fr/'; + $expected = 'http://www.xn--acadmie-franaise-npb1a.fr/'; + $url = new Url($ind); + $this->assertEquals($expected, $url->idnToAscii()); + + $notInd = 'http://www.academie-francaise.fr/'; + $url = new Url($notInd); + $this->assertEquals($notInd, $url->idnToAscii()); + } }