Merge pull request from ArthurHoaro/hotfix/title-retrieve-the-return

Fixes  - Title retrieving is failing with multiple use case
This commit is contained in:
Arthur 2016-05-03 19:53:57 +02:00
commit 47be060983
6 changed files with 142 additions and 16 deletions

View file

@ -35,4 +35,31 @@ class GetHttpUrlTest extends PHPUnit_Framework_TestCase
$this->assertFalse($headers);
$this->assertFalse($content);
}
/**
* Test getAbsoluteUrl with relative target URL.
*/
public function testGetAbsoluteUrlWithRelative()
{
$origin = 'http://non.existent/blabla/?test';
$target = '/stuff.php';
$expected = 'http://non.existent/stuff.php';
$this->assertEquals($expected, getAbsoluteUrl($origin, $target));
$target = 'stuff.php';
$expected = 'http://non.existent/blabla/stuff.php';
$this->assertEquals($expected, getAbsoluteUrl($origin, $target));
}
/**
* Test getAbsoluteUrl with absolute target URL.
*/
public function testGetAbsoluteUrlWithAbsolute()
{
$origin = 'http://non.existent/blabla/?test';
$target = 'http://other.url/stuff.php';
$this->assertEquals($target, getAbsoluteUrl($origin, $target));
}
}

View file

@ -181,4 +181,19 @@ class UrlTest extends PHPUnit_Framework_TestCase
$url = new Url('ftp://save.tld/mysave');
$this->assertFalse($url->isHttp());
}
/**
* Test IndToAscii.
*/
function testIndToAscii()
{
$ind = 'http://www.académie-française.fr/';
$expected = 'http://www.xn--acadmie-franaise-npb1a.fr/';
$url = new Url($ind);
$this->assertEquals($expected, $url->indToAscii());
$notInd = 'http://www.academie-francaise.fr/';
$url = new Url($notInd);
$this->assertEquals($notInd, $url->indToAscii());
}
}