2 namespace Friendica\Test\src\Database;
5 use Friendica\Core\Config;
6 use Friendica\Database\DBA;
8 use Friendica\Test\DatabaseTest;
9 use Friendica\Util\BasePath;
10 use Friendica\Util\BaseURL;
11 use Friendica\Util\Config\ConfigFileLoader;
13 class DBATest extends DatabaseTest
15 public function setUp()
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($basePath, $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);
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');
43 public function testExists() {
45 $this->assertTrue(DBA::exists('config', []));
46 $this->assertFalse(DBA::exists('notable', []));
48 $this->assertTrue(DBA::exists('config', null));
49 $this->assertFalse(DBA::exists('notable', null));
51 $this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
52 $this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));