friendica/tests/src/Database/DBATest.php
Philipp Holzer eafcf3592d
Config FollowUp
- New Configuration (Config is now only holding the instance)
- New PConfiguration (PConfig is now only holding the instance)

- Config & PConfig-Adapter don't need "ConfigCache" anymore

- DB-Connection is now outside App->reload() for better dependency-chaining
2019-02-17 20:40:27 +01:00

52 lines
1.6 KiB
PHP

<?php
namespace Friendica\Test\Database;
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\Config\Cache;
use Friendica\Database\DBA;
use Friendica\Factory;
use Friendica\Test\DatabaseTest;
use Friendica\Util\BasePath;
class DBATest extends DatabaseTest
{
public function setUp()
{
$basedir = BasePath::create(dirname(__DIR__) . '/../../');
$configLoader = new Cache\ConfigCacheLoader($basedir);
$configCache = Factory\ConfigFactory::createCache($configLoader);
Factory\DBFactory::init($configCache, $_SERVER);
$config = Factory\ConfigFactory::createConfig($configCache);
$pconfig = Factory\ConfigFactory::createPConfig($configCache);
$logger = Factory\LoggerFactory::create('test', $config);
$profiler = Factory\ProfilerFactory::create($logger, $config);
$this->app = new App($config, $logger, $profiler, false);
$this->logOutput = FActory\LoggerFactory::enableTest($this->app->getLogger());
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']));
}
}