]> git.mxchange.org Git - friendica.git/blob - tests/src/Database/DBATest.php
Adding basepath, urlpath, hostname and ssl_policy to installation
[friendica.git] / tests / src / Database / DBATest.php
1 <?php
2 namespace Friendica\Test\src\Database;
3
4 use Friendica\App;
5 use Friendica\Core\Config;
6 use Friendica\Database\DBA;
7 use Friendica\Factory;
8 use Friendica\Test\DatabaseTest;
9 use Friendica\Util\BasePath;
10 use Friendica\Util\BaseURL;
11 use Friendica\Util\Config\ConfigFileLoader;
12
13 class DBATest extends DatabaseTest
14 {
15         public function setUp()
16         {
17                 $basePath = BasePath::create(dirname(__DIR__) . '/../../');
18                 $mode = new App\Mode($basePath);
19                 $router = new App\Router();
20                 $configLoader = new ConfigFileLoader($basePath, $mode);
21                 $configCache = Factory\ConfigFactory::createCache($configLoader);
22                 $profiler = Factory\ProfilerFactory::create($configCache);
23                 Factory\DBFactory::init($configCache, $profiler, $_SERVER);
24                 $config = Factory\ConfigFactory::createConfig($configCache);
25                 Factory\ConfigFactory::createPConfig($configCache);
26                 $logger = Factory\LoggerFactory::create('test', $config, $profiler);
27                 $baseUrl = new BaseURL($config, $_SERVER);
28                 $this->app = new App($config, $mode, $router, $baseUrl, $logger, $profiler, false);
29
30                 parent::setUp();
31
32                 // Default config
33                 Config::set('config', 'hostname', 'localhost');
34                 Config::set('system', 'throttle_limit_day', 100);
35                 Config::set('system', 'throttle_limit_week', 100);
36                 Config::set('system', 'throttle_limit_month', 100);
37                 Config::set('system', 'theme', 'system_theme');
38         }
39
40         /**
41          * @small
42          */
43         public function testExists() {
44
45                 $this->assertTrue(DBA::exists('config', []));
46                 $this->assertFalse(DBA::exists('notable', []));
47
48                 $this->assertTrue(DBA::exists('config', null));
49                 $this->assertFalse(DBA::exists('notable', null));
50
51                 $this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
52                 $this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));
53         }
54 }