]> git.mxchange.org Git - friendica.git/blob - tests/src/Database/DBATest.php
889ae6af0d8b4c7256209f58e309fb7c129e7450
[friendica.git] / tests / src / Database / DBATest.php
1 <?php
2 namespace Friendica\Test\src\Database;
3
4 use Friendica\App;
5 use Friendica\Core\Config;
6 use Friendica\Database\DBA;
7 use Friendica\Factory;
8 use Friendica\Test\DatabaseTest;
9 use Friendica\Util\BasePath;
10 use Friendica\Util\Config\ConfigFileLoader;
11
12 class DBATest extends DatabaseTest
13 {
14         public function setUp()
15         {
16                 $basePath = BasePath::create(dirname(__DIR__) . '/../../');
17                 $mode = new App\Mode($basePath);
18                 $router = new App\Router();
19                 $configLoader = new ConfigFileLoader($basePath, $mode);
20                 $configCache = Factory\ConfigFactory::createCache($configLoader);
21                 $profiler = Factory\ProfilerFactory::create($configCache);
22                 Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
23                 $config = Factory\ConfigFactory::createConfig($configCache);
24                 Factory\ConfigFactory::createPConfig($configCache);
25                 $logger = Factory\LoggerFactory::create('test', $config, $profiler);
26                 $this->app = new App($config, $mode, $router, $logger, $profiler, false);
27
28                 parent::setUp();
29
30                 // Default config
31                 Config::set('config', 'hostname', 'localhost');
32                 Config::set('system', 'throttle_limit_day', 100);
33                 Config::set('system', 'throttle_limit_week', 100);
34                 Config::set('system', 'throttle_limit_month', 100);
35                 Config::set('system', 'theme', 'system_theme');
36         }
37
38         /**
39          * @small
40          */
41         public function testExists() {
42
43                 $this->assertTrue(DBA::exists('config', []));
44                 $this->assertFalse(DBA::exists('notable', []));
45
46                 $this->assertTrue(DBA::exists('config', null));
47                 $this->assertFalse(DBA::exists('notable', null));
48
49                 $this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
50                 $this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));
51         }
52 }