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 $profiler = $this->dice->create(Profiler::class, [$configCache]);
88 $this->assertInstanceOf(Profiler::class, $profiler);
89 $this->assertTrue($profiler->isRendertime());
92 public function testDatabase()
94 /** @var Database $database */
95 $database = $this->dice->create(Database::class);
97 $this->assertInstanceOf(Database::class, $database);
98 $this->assertTrue($database->connected());
101 public function testAppMode()
103 /** @var App\Mode $mode */
104 $mode = $this->dice->create(App\Mode::class);
106 $this->assertInstanceOf(App\Mode::class, $mode);
108 $this->assertTrue($mode->isNormal());
111 public function testConfiguration()
113 /** @var Configuration $config */
114 $config = $this->dice->create(Configuration::class);
116 $this->assertInstanceOf(Configuration::class, $config);
118 $this->assertNotEmpty($config->get('database', 'username'));
121 public function testLogger()
123 /** @var LoggerInterface $logger */
124 $logger = $this->dice->create(LoggerInterface::class, ['test']);
126 $this->assertInstanceOf(LoggerInterface::class, $logger);
129 public function testDevLogger()
131 /** @var LoggerInterface $logger */
132 $logger = $this->dice->create('$devLogger', ['dev']);
134 self::assertInstanceOf(LoggerInterface::class, $logger);