]> git.mxchange.org Git - friendica.git/blob - tests/src/Database/DBATest.php
Fix test
[friendica.git] / tests / src / Database / DBATest.php
1 <?php
2 namespace Friendica\Test\src\Database;
3
4 use Dice\Dice;
5 use Friendica\Database\Database;
6 use Friendica\Database\DBA;
7 use Friendica\DI;
8 use Friendica\Test\DatabaseTest;
9 use Friendica\Test\Util\Database\StaticDatabase;
10
11 class DBATest extends DatabaseTest
12 {
13         protected function setUp(): void
14         {
15                 parent::setUp();
16
17                 $dice = (new Dice())
18                         ->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
19                         ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
20                 DI::init($dice);
21
22                 // Default config
23                 DI::config()->set('config', 'hostname', 'localhost');
24                 DI::config()->set('system', 'throttle_limit_day', 100);
25                 DI::config()->set('system', 'throttle_limit_week', 100);
26                 DI::config()->set('system', 'throttle_limit_month', 100);
27                 DI::config()->set('system', 'theme', 'system_theme');
28         }
29
30         /**
31          * @small
32          */
33         public function testExists() {
34
35                 self::assertTrue(DBA::exists('config', []));
36                 self::assertFalse(DBA::exists('notable', []));
37
38                 self::assertTrue(DBA::exists('config', null));
39                 self::assertFalse(DBA::exists('notable', null));
40
41                 self::assertTrue(DBA::exists('config', ['k' => 'hostname']));
42                 self::assertFalse(DBA::exists('config', ['k' => 'nonsense']));
43         }
44 }