2 namespace Friendica\Test\src\Database;
5 use Friendica\Core\Config;
6 use Friendica\Core\Config\Cache;
7 use Friendica\Database\DBA;
9 use Friendica\Test\DatabaseTest;
10 use Friendica\Util\BasePath;
12 class DBATest extends DatabaseTest
14 public function setUp()
16 $basePath = BasePath::create(dirname(__DIR__) . '/../../');
17 $configLoader = new Cache\ConfigCacheLoader($basePath);
18 $configCache = Factory\ConfigFactory::createCache($configLoader);
19 $profiler = Factory\ProfilerFactory::create($configCache);
20 Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
21 $config = Factory\ConfigFactory::createConfig($configCache);
22 Factory\ConfigFactory::createPConfig($configCache);
23 $logger = Factory\LoggerFactory::create('test', $config);
24 $this->app = new App($basePath, $config, $logger, $profiler, false);
29 Config::set('config', 'hostname', 'localhost');
30 Config::set('system', 'throttle_limit_day', 100);
31 Config::set('system', 'throttle_limit_week', 100);
32 Config::set('system', 'throttle_limit_month', 100);
33 Config::set('system', 'theme', 'system_theme');
39 public function testExists() {
41 $this->assertTrue(DBA::exists('config', []));
42 $this->assertFalse(DBA::exists('notable', []));
44 $this->assertTrue(DBA::exists('config', null));
45 $this->assertFalse(DBA::exists('notable', null));
47 $this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
48 $this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));