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

56 lines
1.7 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;
2019-07-15 20:13:53 +02:00
use Friendica\Core\Config\Cache\PConfigCache;
use Friendica\Core\L10n\L10n;
use Friendica\Database\DBA;
2019-02-05 22:03:07 +01:00
use Friendica\Factory;
use Friendica\Test\DatabaseTest;
2019-04-08 23:12:34 +02:00
use Friendica\Util\BaseURL;
class DBATest extends DatabaseTest
{
public function setUp()
{
2019-07-04 21:39:49 +02:00
$configModel = new \Friendica\Model\Config\Config(self::$dba);
$configFactory = new Factory\ConfigFactory();
$config = $configFactory->createConfig(self::$configCache, $configModel);
2019-07-15 20:13:53 +02:00
$pconfigModel = new \Friendica\Model\Config\PConfig(self::$dba);
$configFactory->createPConfig(self::$configCache, new PConfigCache(), $pconfigModel);
$loggerFactory = new Factory\LoggerFactory();
$logger = $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();
$l10n = new L10n($config,
self::$dba,
$logger);
$this->app = new App(self::$dba, $config, self::$mode, $router, $baseUrl, $logger, self::$profiler, $l10n, 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']));
}
}