]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
namespacing: move HTTP utilities along \Shaarli\Http\ classes
authorVirtualTam <virtualtam@flibidi.net>
Sun, 2 Dec 2018 23:34:53 +0000 (00:34 +0100)
committerVirtualTam <virtualtam@flibidi.net>
Sat, 12 Jan 2019 21:47:48 +0000 (22:47 +0100)
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
16 files changed:
application/http/HttpUtils.php [moved from application/HttpUtils.php with 99% similarity]
application/http/Url.php
application/http/UrlUtils.php [moved from application/Url.php with 95% similarity]
index.php
tests/http/HttpUtils/ClientIpIdTest.php [moved from tests/HttpUtils/ClientIpIdTest.php with 89% similarity]
tests/http/HttpUtils/GetHttpUrlTest.php [moved from tests/HttpUtils/GetHttpUrlTest.php with 85% similarity]
tests/http/HttpUtils/GetIpAdressFromProxyTest.php [moved from tests/HttpUtils/GetIpAdressFromProxyTest.php with 91% similarity]
tests/http/HttpUtils/IndexUrlTest.php [moved from tests/HttpUtils/IndexUrlTest.php with 92% similarity]
tests/http/HttpUtils/IsHttpsTest.php [moved from tests/HttpUtils/IsHttpsTest.php with 89% similarity]
tests/http/HttpUtils/PageUrlTest.php [moved from tests/HttpUtils/PageUrlTest.php with 93% similarity]
tests/http/HttpUtils/ServerUrlTest.php [moved from tests/HttpUtils/ServerUrlTest.php with 97% similarity]
tests/http/UrlTest.php
tests/http/UrlUtils/CleanupUrlTest.php [moved from tests/Url/CleanupUrlTest.php with 96% similarity]
tests/http/UrlUtils/GetUrlSchemeTest.php [moved from tests/Url/GetUrlSchemeTest.php with 76% similarity]
tests/http/UrlUtils/UnparseUrlTest.php [moved from tests/Url/UnparseUrlTest.php with 76% similarity]
tests/http/UrlUtils/WhitelistProtocolsTest.php [moved from tests/Url/WhitelistProtocolsTest.php with 91% similarity]

similarity index 99%
rename from application/HttpUtils.php
rename to application/http/HttpUtils.php
index 51af5d0d7c1fd3aee079aaf6f268accf6d2abd36..2ea9195d3550bfd4bfd912ef35cb4b669a5c83c2 100644 (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 =
index 260231c6f1b97b9761762bdff0bfdb0c5f1ebf17..90444a2f4beaf0ad15df3be06ff36d4431d61811 100644 (file)
@@ -206,7 +206,7 @@ class Url
     }
 
     /**
-     * Test if the Url is an HTTP one.
+     * Test if the UrlUtils is an HTTP one.
      *
      * @return true is HTTP, false otherwise.
      */
similarity index 95%
rename from application/Url.php
rename to application/http/UrlUtils.php
index 81f72fb06f46fdbccffce0e41bd302b1db45b8cd..4bc84b823d7ce8d3d44dec028facb6ab28610aed 100644 (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.
  */
index 6d1ae3fc3b0cb1ab7b1d6e2edbecb368f98c3965..66fe30f1921ed3fdb842c275c85d04e42cf4a74c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -59,16 +59,16 @@ require_once __DIR__ . '/vendor/autoload.php';
 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';
similarity index 89%
rename from tests/HttpUtils/ClientIpIdTest.php
rename to tests/http/HttpUtils/ClientIpIdTest.php
index c15ac5cc0a4814733cd7bfdd79eccaccec29e0c4..982e57e0b6ff37ae8b42b1a5a11707ddf0bb08b9 100644 (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
similarity index 85%
rename from tests/HttpUtils/GetHttpUrlTest.php
rename to tests/http/HttpUtils/GetHttpUrlTest.php
index ea53de5f27feabec829489c442c728bf5b661cf4..3dc5bc9b03c38c9b0cad7763b2578b6e0ed017c5 100644 (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);
     }
 
similarity index 91%
rename from tests/HttpUtils/GetIpAdressFromProxyTest.php
rename to tests/http/HttpUtils/GetIpAdressFromProxyTest.php
index 7af5bd9db058c356e9b0b13a52cc2ffc430b2337..fe3a639e296ed3fe6512c7186f43f9d49fb7694c 100644 (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
 {
 
     /**
similarity index 92%
rename from tests/HttpUtils/IndexUrlTest.php
rename to tests/http/HttpUtils/IndexUrlTest.php
index 337dcab0b070fa9b6439eb11d9009815c6ee2450..bcbe59cbf6abe493a392f429fb96f1c54cb2d46c 100644 (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
similarity index 89%
rename from tests/HttpUtils/IsHttpsTest.php
rename to tests/http/HttpUtils/IsHttpsTest.php
index 097f2bcf0c56b5e2364548ffc360402ea3e05f38..348956c645e6c40891ab42655237e75d7b810403 100644 (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
 {
 
     /**
similarity index 93%
rename from tests/HttpUtils/PageUrlTest.php
rename to tests/http/HttpUtils/PageUrlTest.php
index 4dbbe9cf40bb57d40fe0f862c80367b116acb780..f199171684bad9694e6d3545b13b2a55c14d14ef 100644 (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
similarity index 97%
rename from tests/HttpUtils/ServerUrlTest.php
rename to tests/http/HttpUtils/ServerUrlTest.php
index 324b827acc11e9612c933fa89893dfd318f523a3..9caf104983ffd75427cb6a9a9c35cb1a29f042d0 100644 (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
index 011b416d90df05b67c27af177dba415c7f379f4b..342b78a43b3b41c602a192905aacc59975fe078c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Url's tests
+ * UrlUtils's tests
  */
 
 namespace Shaarli\Http;
similarity index 96%
rename from tests/Url/CleanupUrlTest.php
rename to tests/http/UrlUtils/CleanupUrlTest.php
index 24791948337a94be0692a6e97b4c20faa94d2de2..6c4d124bed845f4d5205dda31df2f61b0a0d99d0 100644 (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
similarity index 76%
rename from tests/Url/GetUrlSchemeTest.php
rename to tests/http/UrlUtils/GetUrlSchemeTest.php
index 18b932d6f3a350c9f7191a5faf7517ffbdd02b76..2b97f7be649a4c120fb31c24f13ab19f70b7c3a1 100644 (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()
     {
similarity index 76%
rename from tests/Url/UnparseUrlTest.php
rename to tests/http/UrlUtils/UnparseUrlTest.php
index e314b48468b789688fec09dda194074c670de0e3..040d8c54ed5a1fca14490ec36ebdb2994005252f 100644 (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
similarity index 91%
rename from tests/Url/WhitelistProtocolsTest.php
rename to tests/http/UrlUtils/WhitelistProtocolsTest.php
index a315680483259e4e340a6323f4c12069d00075c5..69512dbd18787a2129b83c97662cf31fbba91f9a 100644 (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).