2018-07-21 14:43:43 +02:00
|
|
|
<?php
|
|
|
|
namespace Friendica\Test\Database;
|
|
|
|
|
2019-02-05 22:03:07 +01:00
|
|
|
use Friendica\App;
|
2018-07-21 14:43:43 +02:00
|
|
|
use Friendica\Core\Config;
|
2019-02-10 19:52:21 +01:00
|
|
|
use Friendica\Core\Config\Cache;
|
2018-07-21 14:43:43 +02:00
|
|
|
use Friendica\Database\DBA;
|
2019-02-05 22:03:07 +01:00
|
|
|
use Friendica\Factory;
|
2018-07-21 14:43:43 +02:00
|
|
|
use Friendica\Test\DatabaseTest;
|
2019-02-05 22:03:07 +01:00
|
|
|
use Friendica\Util\BasePath;
|
2018-07-21 14:43:43 +02:00
|
|
|
|
|
|
|
class DBATest extends DatabaseTest
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
2019-02-05 22:03:07 +01:00
|
|
|
$basedir = BasePath::create(dirname(__DIR__) . '/../../');
|
2019-02-10 19:52:21 +01:00
|
|
|
$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);
|
2019-02-05 22:03:07 +01:00
|
|
|
$logger = Factory\LoggerFactory::create('test', $config);
|
2019-02-16 23:19:54 +01:00
|
|
|
$profiler = Factory\ProfilerFactory::create($logger, $config);
|
|
|
|
$this->app = new App($config, $logger, $profiler, false);
|
2019-02-05 22:03:07 +01:00
|
|
|
$this->logOutput = FActory\LoggerFactory::enableTest($this->app->getLogger());
|
2018-07-21 14:43:43 +02:00
|
|
|
|
2019-02-05 22:03:07 +01:00
|
|
|
parent::setUp();
|
2018-07-21 14:43:43 +02:00
|
|
|
|
|
|
|
// 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']));
|
|
|
|
}
|
|
|
|
}
|