7 use Friendica\Core\Config\Cache\ConfigCache;
8 use Friendica\Core\Config\Configuration;
9 use Friendica\Database\Database;
10 use Friendica\Test\Util\VFSTrait;
11 use Friendica\Util\BasePath;
12 use Friendica\Util\ConfigFileLoader;
13 use Friendica\Util\Profiler;
14 use PHPUnit\Framework\TestCase;
15 use Psr\Log\LoggerInterface;
17 class dependencyCheck extends TestCase
26 protected function setUp()
32 $this->dice = new Dice();
33 $this->dice = $this->dice->addRules(include __DIR__ . '/../../static/dependencies.config.php');
37 * Test the creation of the BasePath
39 public function testBasePath()
41 /** @var BasePath $basePath */
42 $basePath = $this->dice->create(BasePath::class, [$this->root->url()]);
44 $this->assertInstanceOf(BasePath::class, $basePath);
45 $this->assertEquals($this->root->url(), $basePath->getPath());
49 * Test the initial config cache
50 * Should not need any other files
52 public function testConfigFileLoader()
54 /** @var ConfigFileLoader $configFileLoader */
55 $configFileLoader = $this->dice->create(ConfigFileLoader::class);
57 $this->assertInstanceOf(ConfigFileLoader::class, $configFileLoader);
59 $configCache = new ConfigCache();
60 $configFileLoader->setupCache($configCache);
62 $this->assertNotEmpty($configCache->getAll());
63 $this->assertArrayHasKey('database', $configCache->getAll());
64 $this->assertArrayHasKey('system', $configCache->getAll());
68 * Test the construction of a profiler class with DI
70 public function testProfiler()
72 /** @var Profiler $profiler */
73 $profiler = $this->dice->create(Profiler::class);
75 $this->assertInstanceOf(Profiler::class, $profiler);
77 $configCache = new ConfigCache([
86 // create new DI-library because of shared instance rule (so the Profiler wouldn't get created twice)
87 $this->dice = new Dice(include __DIR__ . '/../../static/dependencies.config.php');
88 $profiler = $this->dice->create(Profiler::class, [$configCache]);
90 $this->assertInstanceOf(Profiler::class, $profiler);
91 $this->assertTrue($profiler->isRendertime());
94 public function testDatabase()
96 /** @var Database $database */
97 $database = $this->dice->create(Database::class);
99 $this->assertInstanceOf(Database::class, $database);
100 $this->assertTrue($database->connected());
103 public function testAppMode()
105 /** @var App\Mode $mode */
106 $mode = $this->dice->create(App\Mode::class);
108 $this->assertInstanceOf(App\Mode::class, $mode);
110 $this->assertTrue($mode->isNormal());
113 public function testConfiguration()
115 /** @var Configuration $config */
116 $config = $this->dice->create(Configuration::class);
118 $this->assertInstanceOf(Configuration::class, $config);
120 $this->assertNotEmpty($config->get('database', 'username'));
123 public function testLogger()
125 /** @var LoggerInterface $logger */
126 $logger = $this->dice->create(LoggerInterface::class, ['test']);
128 $this->assertInstanceOf(LoggerInterface::class, $logger);
131 public function testDevLogger()
133 /** @var LoggerInterface $logger */
134 $logger = $this->dice->create('$devLogger', ['dev']);
136 self::assertInstanceOf(LoggerInterface::class, $logger);