]> git.mxchange.org Git - friendica.git/blob - tests/src/Database/DBATest.php
c9413772195c9c279bc87f18e10e4cac10d9dfac
[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                 $configLoader = new ConfigFileLoader($basePath, $mode);
19                 $configCache = Factory\ConfigFactory::createCache($configLoader);
20                 $profiler = Factory\ProfilerFactory::create($configCache);
21                 Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
22                 $config = Factory\ConfigFactory::createConfig($configCache);
23                 Factory\ConfigFactory::createPConfig($configCache);
24                 $logger = Factory\LoggerFactory::create('test', $config, $profiler);
25                 $this->app = new App($config, $mode, $logger, $profiler, false);
26
27                 parent::setUp();
28
29                 // Default config
30                 Config::set('config', 'hostname', 'localhost');
31                 Config::set('system', 'throttle_limit_day', 100);
32                 Config::set('system', 'throttle_limit_week', 100);
33                 Config::set('system', 'throttle_limit_month', 100);
34                 Config::set('system', 'theme', 'system_theme');
35         }
36
37         /**
38          * @small
39          */
40         public function testExists() {
41
42                 $this->assertTrue(DBA::exists('config', []));
43                 $this->assertFalse(DBA::exists('notable', []));
44
45                 $this->assertTrue(DBA::exists('config', null));
46                 $this->assertFalse(DBA::exists('notable', null));
47
48                 $this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
49                 $this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));
50         }
51 }