friendica_2021-01/tests/src/Database/DBATest.php

51 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2019-02-27 12:32:56 +01:00
namespace Friendica\Test\src\Database;
2019-02-05 22:03:07 +01:00
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\Config\Cache;
use Friendica\Database\DBA;
2019-02-05 22:03:07 +01:00
use Friendica\Factory;
use Friendica\Test\DatabaseTest;
2019-02-05 22:03:07 +01:00
use Friendica\Util\BasePath;
class DBATest extends DatabaseTest
{
public function setUp()
{
$basePath = BasePath::create(dirname(__DIR__) . '/../../');
$configLoader = new Cache\ConfigCacheLoader($basePath);
$configCache = Factory\ConfigFactory::createCache($configLoader);
$profiler = Factory\ProfilerFactory::create($configCache);
Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
$config = Factory\ConfigFactory::createConfig($configCache);
Factory\ConfigFactory::createPConfig($configCache);
2019-02-28 09:41:31 +01:00
$logger = Factory\LoggerFactory::create('test', $config, $profiler);
$this->app = new App($basePath, $config, $logger, $profiler, false);
2019-02-05 22:03:07 +01:00
parent::setUp();
// Default config
Config::set('config', 'hostname', 'localhost');
Config::set('system', 'throttle_limit_day', 100);
Config::set('system', 'throttle_limit_week', 100);
Config::set('system', 'throttle_limit_month', 100);
Config::set('system', 'theme', 'system_theme');
}
/**
* @small
*/
public function testExists() {
$this->assertTrue(DBA::exists('config', []));
$this->assertFalse(DBA::exists('notable', []));
$this->assertTrue(DBA::exists('config', null));
$this->assertFalse(DBA::exists('notable', null));
$this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
$this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));
}
}