2018-07-21 08:43:43 -04:00
|
|
|
<?php
|
2019-02-27 06:32:56 -05:00
|
|
|
namespace Friendica\Test\src\Database;
|
2018-07-21 08:43:43 -04:00
|
|
|
|
2019-02-05 16:03:07 -05:00
|
|
|
use Friendica\App;
|
2018-07-21 08:43:43 -04:00
|
|
|
use Friendica\Core\Config;
|
|
|
|
use Friendica\Database\DBA;
|
2019-02-05 16:03:07 -05:00
|
|
|
use Friendica\Factory;
|
2018-07-21 08:43:43 -04:00
|
|
|
use Friendica\Test\DatabaseTest;
|
2019-02-05 16:03:07 -05:00
|
|
|
use Friendica\Util\BasePath;
|
2019-03-24 07:54:26 -04:00
|
|
|
use Friendica\Util\Config\ConfigFileLoader;
|
2018-07-21 08:43:43 -04:00
|
|
|
|
|
|
|
class DBATest extends DatabaseTest
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
2019-02-22 17:51:13 -05:00
|
|
|
$basePath = BasePath::create(dirname(__DIR__) . '/../../');
|
2019-03-13 21:36:49 -04:00
|
|
|
$mode = new App\Mode($basePath);
|
2019-04-05 23:16:12 -04:00
|
|
|
$router = new App\Router();
|
2019-03-24 07:54:26 -04:00
|
|
|
$configLoader = new ConfigFileLoader($basePath, $mode);
|
2019-02-10 13:52:21 -05:00
|
|
|
$configCache = Factory\ConfigFactory::createCache($configLoader);
|
2019-02-17 15:12:12 -05:00
|
|
|
$profiler = Factory\ProfilerFactory::create($configCache);
|
2019-02-22 17:51:13 -05:00
|
|
|
Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
|
2019-02-10 13:52:21 -05:00
|
|
|
$config = Factory\ConfigFactory::createConfig($configCache);
|
2019-02-17 15:12:12 -05:00
|
|
|
Factory\ConfigFactory::createPConfig($configCache);
|
2019-02-28 03:41:31 -05:00
|
|
|
$logger = Factory\LoggerFactory::create('test', $config, $profiler);
|
2019-04-05 23:16:12 -04:00
|
|
|
$this->app = new App($config, $mode, $router, $logger, $profiler, false);
|
2018-07-21 08:43:43 -04:00
|
|
|
|
2019-02-05 16:03:07 -05:00
|
|
|
parent::setUp();
|
2018-07-21 08:43:43 -04: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']));
|
|
|
|
}
|
|
|
|
}
|