]> git.mxchange.org Git - friendica.git/commitdiff
Replace IHTTPResult for CurlResult usages
authorPhilipp <admin@philipp.info>
Fri, 20 Aug 2021 17:48:14 +0000 (19:48 +0200)
committerPhilipp <admin@philipp.info>
Fri, 20 Aug 2021 17:58:42 +0000 (19:58 +0200)
src/Model/GServer.php
src/Network/CurlResult.php
src/Network/IHTTPRequest.php
tests/src/Core/InstallerTest.php

index 7e1d178ddfe1bf6986f36cc9464b00b95f165148..eb99b1bbc8fa06677adb74d6aa1b8fb4881f9ac9 100644 (file)
@@ -32,7 +32,7 @@ use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Module\Register;
-use Friendica\Network\CurlResult;
+use Friendica\Network\IHTTPResult;
 use Friendica\Protocol\Relay;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -171,7 +171,7 @@ class GServer
                if (($now - $contact_time) < (60 * 60 * 24)) {
                        return DateTimeFormat::utc('now +1 day');
                }
-               
+
                // If the last contact was less than a week before then try again in a week
                if (($now - $contact_time) < (60 * 60 * 24 * 7)) {
                        return DateTimeFormat::utc('now +1 week');
@@ -671,18 +671,19 @@ class GServer
        /**
         * Detect server type by using the nodeinfo data
         *
-        * @param string     $url        address of the server
-        * @param CurlResult $curlResult
+        * @param string      $url        address of the server
+        * @param IHTTPResult $httpResult
+        *
         * @return array Server data
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       private static function fetchNodeinfo(string $url, CurlResult $curlResult)
+       private static function fetchNodeinfo(string $url, IHTTPResult $httpResult)
        {
-               if (!$curlResult->isSuccess()) {
+               if (!$httpResult->isSuccess()) {
                        return [];
                }
 
-               $nodeinfo = json_decode($curlResult->getBody(), true);
+               $nodeinfo = json_decode($httpResult->getBody(), true);
 
                if (!is_array($nodeinfo) || empty($nodeinfo['links'])) {
                        return [];
@@ -1748,8 +1749,8 @@ class GServer
         *
         * @param int $gsid     Server id
         * @param int $protocol Protocol id
-        * @return void 
-        * @throws Exception 
+        * @return void
+        * @throws Exception
         */
        public static function setProtocol(int $gsid, int $protocol)
        {
@@ -1808,8 +1809,8 @@ class GServer
         * Fetch the protocol of the given server
         *
         * @param int $gsid Server id
-        * @return int 
-        * @throws Exception 
+        * @return int
+        * @throws Exception
         */
        public static function getProtocol(int $gsid)
        {
index 547bb4d2855eeb8ba8eb5ccdfa4fae77b1f99b53..6fb0153b6c7663e86c43b5b5e0d3d1080f9a360c 100644 (file)
@@ -101,7 +101,7 @@ class CurlResult implements IHTTPResult
         *
         * @param string $url optional URL
         *
-        * @return CurlResult a CURL with error response
+        * @return IHTTPResult a CURL with error response
         * @throws InternalServerErrorException
         */
        public static function createErrorCurl($url = '')
index e2ace44db6cb282e7ecde314aaadaea1cd311b85..efe9f5f8b223faa4b982c1c9de934b34dba6aaec 100644 (file)
@@ -52,7 +52,7 @@ interface IHTTPRequest
         * @param string $accept_content  supply Accept: header with 'accept_content' as the value
         * @param string $cookiejar       Path to cookie jar file
         *
-        * @return CurlResult With all relevant information, 'body' contains the actual fetched content.
+        * @return IHTTPResult With all relevant information, 'body' contains the actual fetched content.
         */
        public function fetchFull(string $url, int $timeout = 0, string $accept_content = '', string $cookiejar = '');
 
@@ -80,7 +80,7 @@ interface IHTTPRequest
         *                           'cookiejar' => path to cookie jar file
         *                           'header' => header array
         *
-        * @return CurlResult
+        * @return IHTTPResult
         */
        public function get(string $url, array $opts = []);
 
@@ -92,7 +92,7 @@ interface IHTTPRequest
         * @param array  $headers HTTP headers
         * @param int    $timeout The timeout in seconds, default system config value or 60 seconds
         *
-        * @return CurlResult The content
+        * @return IHTTPResult The content
         */
        public function post(string $url, $params, array $headers = [], int $timeout = 0);
 
index 8cd1a3fad91e8b117f38f61af02988fa26cca5c6..8c72b7b2b909b1c03d4cc5b6647efcb1150d49ff 100644 (file)
@@ -25,7 +25,7 @@ namespace Friendica\Core;
 use Dice\Dice;
 use Friendica\Core\Config\Cache;
 use Friendica\DI;
-use Friendica\Network\CurlResult;
+use Friendica\Network\IHTTPResult;
 use Friendica\Network\IHTTPRequest;
 use Friendica\Test\MockedTest;
 use Friendica\Test\Util\VFSTrait;
@@ -319,14 +319,14 @@ class InstallerTest extends MockedTest
                $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
 
                // Mocking the CURL Response
-               $curlResult = Mockery::mock(CurlResult::class);
-               $curlResult
+               $IHTTPResult = Mockery::mock(IHTTPResult::class);
+               $IHTTPResult
                        ->shouldReceive('getReturnCode')
                        ->andReturn('404');
-               $curlResult
+               $IHTTPResult
                        ->shouldReceive('getRedirectUrl')
                        ->andReturn('');
-               $curlResult
+               $IHTTPResult
                        ->shouldReceive('getError')
                        ->andReturn('test Error');
 
@@ -335,11 +335,11 @@ class InstallerTest extends MockedTest
                $networkMock
                        ->shouldReceive('fetchFull')
                        ->with('https://test/install/testrewrite')
-                       ->andReturn($curlResult);
+                       ->andReturn($IHTTPResult);
                $networkMock
                        ->shouldReceive('fetchFull')
                        ->with('http://test/install/testrewrite')
-                       ->andReturn($curlResult);
+                       ->andReturn($IHTTPResult);
 
                $this->dice->shouldReceive('create')
                     ->with(IHTTPRequest::class)
@@ -366,14 +366,14 @@ class InstallerTest extends MockedTest
                $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
 
                // Mocking the failed CURL Response
-               $curlResultF = Mockery::mock(CurlResult::class);
-               $curlResultF
+               $IHTTPResultF = Mockery::mock(IHTTPResult::class);
+               $IHTTPResultF
                        ->shouldReceive('getReturnCode')
                        ->andReturn('404');
 
                // Mocking the working CURL Response
-               $curlResultW = Mockery::mock(CurlResult::class);
-               $curlResultW
+               $IHTTPResultW = Mockery::mock(IHTTPResult::class);
+               $IHTTPResultW
                        ->shouldReceive('getReturnCode')
                        ->andReturn('204');
 
@@ -382,11 +382,11 @@ class InstallerTest extends MockedTest
                $networkMock
                        ->shouldReceive('fetchFull')
                        ->with('https://test/install/testrewrite')
-                       ->andReturn($curlResultF);
+                       ->andReturn($IHTTPResultF);
                $networkMock
                        ->shouldReceive('fetchFull')
                        ->with('http://test/install/testrewrite')
-                       ->andReturn($curlResultW);
+                       ->andReturn($IHTTPResultW);
 
                $this->dice->shouldReceive('create')
                           ->with(IHTTPRequest::class)