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

@ -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 @@ class GetHttpUrlTest extends PHPUnit_Framework_TestCase
{
// 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 @@ class GetUrlSchemeTest extends PHPUnit_Framework_TestCase
}
/**
* 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).