]> git.mxchange.org Git - friendica.git/blob - tests/src/Database/DBATest.php
Merge pull request #6605 from nupplaphil/config_mock
[friendica.git] / tests / src / Database / DBATest.php
1 <?php
2 namespace Friendica\Test\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
11 class DBATest extends DatabaseTest
12 {
13         public function setUp()
14         {
15                 $basedir = BasePath::create(dirname(__DIR__) . '/../../');
16                 $configLoader = new Config\ConfigCacheLoader($basedir);
17                 $config = Factory\ConfigFactory::createCache($configLoader);
18                 $logger = Factory\LoggerFactory::create('test', $config);
19                 $this->app = new App($config, $logger, false);
20                 $this->logOutput = FActory\LoggerFactory::enableTest($this->app->getLogger());
21
22                 parent::setUp();
23
24                 // Default config
25                 Config::set('config', 'hostname', 'localhost');
26                 Config::set('system', 'throttle_limit_day', 100);
27                 Config::set('system', 'throttle_limit_week', 100);
28                 Config::set('system', 'throttle_limit_month', 100);
29                 Config::set('system', 'theme', 'system_theme');
30         }
31
32         /**
33          * @small
34          */
35         public function testExists() {
36
37                 $this->assertTrue(DBA::exists('config', []));
38                 $this->assertFalse(DBA::exists('notable', []));
39
40                 $this->assertTrue(DBA::exists('config', null));
41                 $this->assertFalse(DBA::exists('notable', null));
42
43                 $this->assertTrue(DBA::exists('config', ['k' => 'hostname']));
44                 $this->assertFalse(DBA::exists('config', ['k' => 'nonsense']));
45         }
46 }