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\Config\ConfigFileLoader;
12 class DBATest extends DatabaseTest
14 public function setUp()
16 $basePath = BasePath::create(dirname(__DIR__) . '/../../');
17 $mode = new App\Mode($basePath);
18 $configLoader = new ConfigFileLoader($basePath, $mode);
19 $configCache = Factory\ConfigFactory::createCache($configLoader);
20 $profiler = Factory\ProfilerFactory::create($configCache);
21 Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
22 $config = Factory\ConfigFactory::createConfig($configCache);
23 Factory\ConfigFactory::createPConfig($configCache);
24 $logger = Factory\LoggerFactory::create('test', $config, $profiler);
25 $this->app = new App($config, $mode, $logger, $profiler, false);
30 Config::set('config', 'hostname', 'localhost');
31 Config::set('system', 'throttle_limit_day', 100);
32 Config::set('system', 'throttle_limit_week', 100);
33 Config::set('system', 'throttle_limit_month', 100);
34 Config::set('system', 'theme', 'system_theme');
40 public function testExists() {
42 $this->assertTrue(DBA::exists('config', []));
43 $this->assertFalse(DBA::exists('notable', []));
45 $this->assertTrue(DBA::exists('config', null));
46 $this->assertFalse(DBA::exists('notable', null));
48 $this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
49 $this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));