2018-07-21 14:43:43 +02:00
|
|
|
<?php
|
2019-02-27 12:32:56 +01:00
|
|
|
namespace Friendica\Test\src\Database;
|
2018-07-21 14:43:43 +02:00
|
|
|
|
2019-02-05 22:03:07 +01:00
|
|
|
use Friendica\App;
|
2018-07-21 14:43:43 +02:00
|
|
|
use Friendica\Core\Config;
|
2019-07-15 20:13:53 +02:00
|
|
|
use Friendica\Core\Config\Cache\PConfigCache;
|
2019-07-09 21:44:02 +02:00
|
|
|
use Friendica\Core\L10n\L10n;
|
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-04-08 23:12:34 +02:00
|
|
|
use Friendica\Util\BaseURL;
|
2018-07-21 14:43:43 +02:00
|
|
|
|
|
|
|
class DBATest extends DatabaseTest
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
2019-07-04 21:39:49 +02:00
|
|
|
$configModel = new \Friendica\Model\Config\Config(self::$dba);
|
|
|
|
$config = Factory\ConfigFactory::createConfig(self::$configCache, $configModel);
|
2019-07-15 20:13:53 +02:00
|
|
|
$pconfigModel = new \Friendica\Model\Config\PConfig(self::$dba);
|
|
|
|
Factory\ConfigFactory::createPConfig(self::$configCache, new PConfigCache(), $pconfigModel);
|
2019-07-04 21:39:49 +02:00
|
|
|
$logger = Factory\LoggerFactory::create('test', self::$dba, $config, self::$profiler);
|
2019-04-08 23:12:34 +02:00
|
|
|
$baseUrl = new BaseURL($config, $_SERVER);
|
2019-07-04 21:39:49 +02:00
|
|
|
$router = new App\Router();
|
2019-07-16 16:50:49 +02:00
|
|
|
$l10n = new L10n(L10n::detectLanguage($config->get('system', 'language')),
|
2019-07-09 21:44:02 +02:00
|
|
|
self::$dba,
|
|
|
|
$logger);
|
|
|
|
$this->app = new App(self::$dba, $config, self::$mode, $router, $baseUrl, $logger, self::$profiler, $l10n, false);
|
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']));
|
|
|
|
}
|
|
|
|
}
|