]> git.mxchange.org Git - friendica.git/blob - tests/FixtureTest.php
Fix Fatal error: Uncaught TypeError: Argument 1 passed to Friendica\Model\Contact...
[friendica.git] / tests / FixtureTest.php
1 <?php
2 /**
3  * FixtureTest class.
4  */
5
6 namespace Friendica\Test;
7
8 use Dice\Dice;
9 use Friendica\Core\Config\Cache;
10 use Friendica\Core\Config\IConfig;
11 use Friendica\Core\Session;
12 use Friendica\Core\Session\ISession;
13 use Friendica\Database\Database;
14 use Friendica\Database\DBStructure;
15 use Friendica\DI;
16 use Friendica\Test\Util\Database\StaticDatabase;
17
18 /**
19  * Parent class for test cases requiring fixtures
20  */
21 abstract class FixtureTest extends DatabaseTest
22 {
23         /** @var Dice */
24         protected $dice;
25
26         /**
27          * Create variables used by tests.
28          */
29         protected function setUp()
30         {
31                 parent::setUp();
32
33                 $this->dice = (new Dice())
34                         ->addRules(include __DIR__ . '/../static/dependencies.config.php')
35                         ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
36                         ->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]);
37                 DI::init($this->dice);
38
39                 /** @var IConfig $config */
40                 $configCache = $this->dice->create(Cache::class);
41                 $configCache->set('database', 'disable_pdo', true);
42
43                 /** @var Database $dba */
44                 $dba = $this->dice->create(Database::class);
45
46                 $dba->setTestmode(true);
47
48                 DBStructure::checkInitialValues();
49
50                 // Load the API dataset for the whole API
51                 $this->loadFixture(__DIR__ . '/datasets/api.fixture.php', $dba);
52         }
53 }