namespacing: move HTTP utilities along \Shaarli\Http\ classes

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
VirtualTam 2018-12-03 00:34:53 +01:00
parent fb1b182fbf
commit 51753e403f
16 changed files with 56 additions and 35 deletions

View file

@ -41,7 +41,7 @@ function get_http_response($url, $timeout = 30, $maxBytes = 4194304, $curlWriteF
$cleanUrl = $urlObj->idnToAscii();
if (!filter_var($cleanUrl, FILTER_VALIDATE_URL) || !$urlObj->isHttp()) {
return array(array(0 => 'Invalid HTTP Url'), false);
return array(array(0 => 'Invalid HTTP UrlUtils'), false);
}
$userAgent =

View file

@ -206,7 +206,7 @@ public function getHost()
}
/**
* Test if the Url is an HTTP one.
* Test if the UrlUtils is an HTTP one.
*
* @return true is HTTP, false otherwise.
*/

View file

@ -28,7 +28,7 @@ function unparse_url($parsedUrl)
/**
* Removes undesired query parameters and fragments
*
* @param string url Url to be cleaned
* @param string url UrlUtils to be cleaned
*
* @return string the string representation of this URL after cleanup
*/
@ -41,7 +41,7 @@ function cleanup_url($url)
/**
* Get URL scheme.
*
* @param string url Url for which the scheme is requested
* @param string url UrlUtils for which the scheme is requested
*
* @return mixed the URL scheme or false if none is provided.
*/

View file

@ -59,16 +59,16 @@
require_once 'application/ApplicationUtils.php';
require_once 'application/config/ConfigPlugin.php';
require_once 'application/feed/Cache.php';
require_once 'application/http/HttpUtils.php';
require_once 'application/http/UrlUtils.php';
require_once 'application/FileUtils.php';
require_once 'application/History.php';
require_once 'application/HttpUtils.php';
require_once 'application/LinkDB.php';
require_once 'application/LinkFilter.php';
require_once 'application/LinkUtils.php';
require_once 'application/NetscapeBookmarkUtils.php';
require_once 'application/PageBuilder.php';
require_once 'application/TimeZone.php';
require_once 'application/Url.php';
require_once 'application/Utils.php';
require_once 'application/PluginManager.php';
require_once 'application/Router.php';

View file

@ -3,12 +3,14 @@
* HttpUtils' tests
*/
require_once 'application/HttpUtils.php';
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for client_ip_id()
*/
class ClientIpIdTest extends PHPUnit_Framework_TestCase
class ClientIpIdTest extends \PHPUnit\Framework\TestCase
{
/**
* Get a remote client ID based on its IP

View file

@ -3,12 +3,14 @@
* HttpUtils' tests
*/
require_once 'application/HttpUtils.php';
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for get_http_response()
*/
class GetHttpUrlTest extends PHPUnit_Framework_TestCase
class GetHttpUrlTest extends \PHPUnit\Framework\TestCase
{
/**
* Get an invalid local URL
@ -17,12 +19,12 @@ public function testGetInvalidLocalUrl()
{
// Local
list($headers, $content) = get_http_response('/non/existent', 1);
$this->assertEquals('Invalid HTTP Url', $headers[0]);
$this->assertEquals('Invalid HTTP UrlUtils', $headers[0]);
$this->assertFalse($content);
// Non HTTP
list($headers, $content) = get_http_response('ftp://save.tld/mysave', 1);
$this->assertEquals('Invalid HTTP Url', $headers[0]);
$this->assertEquals('Invalid HTTP UrlUtils', $headers[0]);
$this->assertFalse($content);
}

View file

@ -1,11 +1,13 @@
<?php
require_once 'application/HttpUtils.php';
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for getIpAddressFromProxy()
*/
class GetIpAdressFromProxyTest extends PHPUnit_Framework_TestCase
class GetIpAdressFromProxyTest extends \PHPUnit\Framework\TestCase
{
/**

View file

@ -3,12 +3,14 @@
* HttpUtils' tests
*/
require_once 'application/HttpUtils.php';
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for index_url()
*/
class IndexUrlTest extends PHPUnit_Framework_TestCase
class IndexUrlTest extends \PHPUnit\Framework\TestCase
{
/**
* If on the main page, remove "index.php" from the URL resource

View file

@ -1,12 +1,15 @@
<?php
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Class IsHttpsTest
*
* Test class for is_https() function.
*/
class IsHttpsTest extends PHPUnit_Framework_TestCase
class IsHttpsTest extends \PHPUnit\Framework\TestCase
{
/**

View file

@ -3,12 +3,14 @@
* HttpUtils' tests
*/
require_once 'application/HttpUtils.php';
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for page_url()
*/
class PageUrlTest extends PHPUnit_Framework_TestCase
class PageUrlTest extends \PHPUnit\Framework\TestCase
{
/**
* If on the main page, remove "index.php" from the URL resource

View file

@ -3,12 +3,14 @@
* HttpUtils' tests
*/
require_once 'application/HttpUtils.php';
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for server_url()
*/
class ServerUrlTest extends PHPUnit_Framework_TestCase
class ServerUrlTest extends \PHPUnit\Framework\TestCase
{
/**
* Detect if the server uses SSL

View file

@ -1,6 +1,6 @@
<?php
/**
* Url's tests
* UrlUtils's tests
*/
namespace Shaarli\Http;

View file

@ -3,9 +3,11 @@
* Unitary tests for cleanup_url()
*/
require_once 'application/Url.php';
namespace Shaarli\Http;
class CleanupUrlTest extends PHPUnit_Framework_TestCase
require_once 'application/http/UrlUtils.php';
class CleanupUrlTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string reference URL

View file

@ -3,12 +3,14 @@
* Unitary tests for get_url_scheme()
*/
require_once 'application/Url.php';
namespace Shaarli\Http;
class GetUrlSchemeTest extends PHPUnit_Framework_TestCase
require_once 'application/http/UrlUtils.php';
class GetUrlSchemeTest extends \PHPUnit\Framework\TestCase
{
/**
* Get empty scheme string for empty Url
* Get empty scheme string for empty UrlUtils
*/
public function testGetUrlSchemeEmpty()
{
@ -16,7 +18,7 @@ public function testGetUrlSchemeEmpty()
}
/**
* Get normal scheme of Url
* Get normal scheme of UrlUtils
*/
public function testGetUrlScheme()
{

View file

@ -1,14 +1,16 @@
<?php
/**
* Unpares Url's tests
* Unpares UrlUtils's tests
*/
require_once 'application/Url.php';
namespace Shaarli\Http;
require_once 'application/http/UrlUtils.php';
/**
* Unitary tests for unparse_url()
*/
class UnparseUrlTest extends PHPUnit_Framework_TestCase
class UnparseUrlTest extends \PHPUnit\Framework\TestCase
{
/**
* Thanks for building nothing

View file

@ -1,15 +1,15 @@
<?php
require_once 'application/Url.php';
namespace Shaarli\Http;
use Shaarli\Config\ConfigManager;
require_once 'application/http/UrlUtils.php';
/**
* Class WhitelistProtocolsTest
*
* Test whitelist_protocols() function of Url.
* Test whitelist_protocols() function of UrlUtils.
*/
class WhitelistProtocolsTest extends PHPUnit_Framework_TestCase
class WhitelistProtocolsTest extends \PHPUnit\Framework\TestCase
{
/**
* Test whitelist_protocols() on a note (relative URL).