]> git.mxchange.org Git - friendica.git/commitdiff
Fixing sort of BaseURL usage for App & Cache usage
authorPhilipp Holzer <admin+github@philipp.info>
Sun, 4 Aug 2019 17:02:16 +0000 (19:02 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Sun, 4 Aug 2019 18:01:15 +0000 (20:01 +0200)
src/Core/System.php
tests/include/ApiTest.php
tests/src/Content/Text/BBCodeTest.php

index 42587577dae573105a9f6ce462a0556fb7d8d5d2..89526bdb4e0dd51d869b32a690a5514da95156ab 100644 (file)
@@ -6,6 +6,7 @@ namespace Friendica\Core;
 
 use Friendica\BaseObject;
 use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Util\BaseURL;
 use Friendica\Util\XML;
 
 /**
@@ -29,7 +30,7 @@ class System extends BaseObject
         */
        public static function baseUrl($ssl = false)
        {
-               return self::getApp()->getBaseURL($ssl);
+               return self::getClass(BaseURL::class)->get($ssl);
        }
 
        /**
index d00aeeb73d0b8d9894848b293a06c9303ac32ff0..098337aab9cea8e80638a9cc811d158437ecc059 100644 (file)
@@ -65,9 +65,24 @@ class ApiTest extends DatabaseTest
                /** @var Database $dba */
                $dba = $this->dice->create(Database::class);
 
+               /** @var Configuration $config */
+               $this->config = $this->dice->create(Configuration::class);
+
+               $this->config->set('system', 'url', 'http://localhost');
+               $this->config->set('system', 'hostname', 'localhost');
+               $this->config->set('system', 'worker_dont_fork', true);
+
+               // Default config
+               $this->config->set('config', 'hostname', 'localhost');
+               $this->config->set('system', 'throttle_limit_day', 100);
+               $this->config->set('system', 'throttle_limit_week', 100);
+               $this->config->set('system', 'throttle_limit_month', 100);
+               $this->config->set('system', 'theme', 'system_theme');
+
                // Load the API dataset for the whole API
                $this->loadFixture(__DIR__ . '/../datasets/api.fixture.php', $dba);
 
+               /** @var App app */
                $this->app = BaseObject::getApp();
 
                $this->app->argc = 1;
@@ -106,20 +121,6 @@ class ApiTest extends DatabaseTest
                $_POST   = [];
                $_GET    = [];
                $_SERVER = [];
-
-               /** @var Configuration $config */
-               $this->config = $this->dice->create(Configuration::class);
-
-               $this->config->set('system', 'url', 'http://localhost');
-               $this->config->set('system', 'hostname', 'localhost');
-               $this->config->set('system', 'worker_dont_fork', true);
-
-               // Default config
-               $this->config->set('config', 'hostname', 'localhost');
-               $this->config->set('system', 'throttle_limit_day', 100);
-               $this->config->set('system', 'throttle_limit_week', 100);
-               $this->config->set('system', 'throttle_limit_month', 100);
-               $this->config->set('system', 'theme', 'system_theme');
        }
 
        /**
@@ -450,8 +451,8 @@ class ApiTest extends DatabaseTest
                        }
                ];
                $_SERVER['REQUEST_METHOD'] = 'method';
-               $this->configset('system', 'profiler', true);
-               $this->configset('rendertime', 'callstack', true);
+               $this->config->set('system', 'profiler', true);
+               $this->config->set('rendertime', 'callstack', true);
                $this->app->callstack = [
                        'database'       => ['some_function' => 200],
                        'database_write' => ['some_function' => 200],
index 3affe4e778a9cf78c8ee07b78744c581a6b00d25..6938f8ed5a05249bfa2e92b544c6943e144a3447 100644 (file)
@@ -7,6 +7,7 @@ use Friendica\Core\L10n\L10n;
 use Friendica\Test\MockedTest;
 use Friendica\Test\Util\AppMockTrait;
 use Friendica\Test\Util\VFSTrait;
+use Friendica\Util\BaseURL;
 
 class BBCodeTest extends MockedTest
 {
@@ -44,6 +45,12 @@ class BBCodeTest extends MockedTest
                $this->dice->shouldReceive('create')
                           ->with(L10n::class)
                           ->andReturn($l10nMock);
+
+               $baseUrlMock = \Mockery::mock(BaseURL::class);
+               $baseUrlMock->shouldReceive('get')->withAnyArgs()->andReturn('friendica.local');
+               $this->dice->shouldReceive('create')
+                          ->with(BaseURL::class)
+                          ->andReturn($baseUrlMock);
        }
 
        public function dataLinks()