]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Util/BaseURLTest.php
Revert node.config.php into Config table
[friendica.git] / tests / src / Util / BaseURLTest.php
index b9c23a1d8b12d3b7d24dc6b9be9d556b772372d1..a72ffc607b72d3acb6f29f9d7a194ab555689627 100644 (file)
@@ -23,17 +23,18 @@ namespace Friendica\Test\src\Util;
 
 use Friendica\App\BaseURL;
 use Friendica\Core\Config\Capability\IManageConfigValues;
-use Friendica\Core\Config\Capability\ISetConfigValuesTransactionally;
-use Friendica\Core\Config\Model\Config;
-use Friendica\Core\Config\Model\ConfigTransaction;
+use Friendica\Core\Config\Model\DatabaseConfig;
+use Friendica\Core\Config\Model\ReadOnlyFileConfig;
 use Friendica\Core\Config\Util\ConfigFileManager;
 use Friendica\Core\Config\ValueObject\Cache;
-use Friendica\Test\MockedTest;
+use Friendica\Test\DatabaseTest;
+use Friendica\Test\Util\CreateDatabaseTrait;
 use Friendica\Test\Util\VFSTrait;
 
-class BaseURLTest extends MockedTest
+class BaseURLTest extends DatabaseTest
 {
        use VFSTrait;
+       use CreateDatabaseTrait;
 
        protected function setUp(): void
        {
@@ -202,47 +203,6 @@ class BaseURLTest extends MockedTest
                ];
        }
 
-       /**
-        * Test the default config determination
-        * @dataProvider dataDefault
-        */
-       public function testCheck($server, $input, $assert)
-       {
-               $configMock = \Mockery::mock(IManageConfigValues::class);
-               $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
-               $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
-               $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
-               $configMock->shouldReceive('get')->with('system', 'url')->andReturn($input['url']);
-
-               // If we don't have an urlPath as an input, we assert it, we will save it to the DB for the next time
-               if (!isset($input['urlPath']) && isset($assert['urlPath'])) {
-                       $configMock->shouldReceive('set')->with('system', 'urlpath', $assert['urlPath'])->once();
-               }
-
-               // If we don't have the ssl_policy as an input, we assert it, we will save it to the DB for the next time
-               if (!isset($input['sslPolicy']) && isset($assert['sslPolicy'])) {
-                       $configMock->shouldReceive('set')->with('system', 'ssl_policy', $assert['sslPolicy'])->once();
-               }
-
-               // If we don't have the hostname as an input, we assert it, we will save it to the DB for the next time
-               if (empty($input['hostname']) && !empty($assert['hostname'])) {
-                       $configMock->shouldReceive('set')->with('config', 'hostname', $assert['hostname'])->once();
-               }
-
-               // If we don't have an URL at first, but we assert it, we will save it to the DB for the next time
-               if (empty($input['url']) && !empty($assert['url'])) {
-                       $configMock->shouldReceive('set')->with('system', 'url', $assert['url'])->once();
-               }
-
-               $baseUrl = new BaseURL($configMock, $server);
-
-               self::assertEquals($assert['hostname'], $baseUrl->getHostname());
-               self::assertEquals($assert['urlPath'], $baseUrl->getUrlPath());
-               self::assertEquals($assert['sslPolicy'], $baseUrl->getSSLPolicy());
-               self::assertEquals($assert['scheme'], $baseUrl->getScheme());
-               self::assertEquals($assert['url'], $baseUrl->get());
-       }
-
        public function dataSave()
        {
                return [
@@ -345,8 +305,7 @@ class BaseURLTest extends MockedTest
         */
        public function testSave($input, $save, $url)
        {
-               $configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
-               $config = new Config($configFileManager, new Cache([
+               $config = new DatabaseConfig($this->getDbInstance(), new Cache([
                        'config' => [
                                'hostname' => $input['hostname'] ?? null,
                        ],
@@ -375,8 +334,7 @@ class BaseURLTest extends MockedTest
         */
        public function testSaveByUrl($input, $save, $url)
        {
-               $configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
-               $config = new Config($configFileManager, new Cache([
+               $config = new DatabaseConfig($this->getDbInstance(), new Cache([
                        'config' => [
                                'hostname' => $input['hostname'] ?? null,
                        ],