use Dice\Dice;
use Friendica\App;
-use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Cache\ICache;
+use Friendica\Core\Cache\IMemoryCache;
+use Friendica\Core\Config\Cache;
+use Friendica\Core\Config\IConfig;
+use Friendica\Core\Lock\ILock;
use Friendica\Database\Database;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\BasePath;
$this->setUpVfsDir();
- $this->dice = new Dice();
- $this->dice = $this->dice->addRules(include __DIR__ . '/../../static/dependencies.config.php');
+ $this->dice = (new Dice())
+ ->addRules(include __DIR__ . '/../../static/dependencies.config.php');
}
/**
$this->assertInstanceOf(ConfigFileLoader::class, $configFileLoader);
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
$this->assertNotEmpty($configCache->getAll());
$this->assertInstanceOf(Profiler::class, $profiler);
- $configCache = new ConfigCache([
+ $configCache = new Cache([
'system' => [
'profiler' => true,
],
]
]);
+ // create new DI-library because of shared instance rule (so the Profiler wouldn't get created twice)
+ $this->dice = new Dice();
$profiler = $this->dice->create(Profiler::class, [$configCache]);
$this->assertInstanceOf(Profiler::class, $profiler);
public function testConfiguration()
{
- /** @var Configuration $config */
- $config = $this->dice->create(Configuration::class);
+ /** @var IConfig $config */
+ $config = $this->dice->create(IConfig::class);
- $this->assertInstanceOf(Configuration::class, $config);
+ $this->assertInstanceOf(IConfig::class, $config);
$this->assertNotEmpty($config->get('database', 'username'));
}
public function testDevLogger()
{
+ /** @var IConfig $config */
+ $config = $this->dice->create(IConfig::class);
+ $config->set('system', 'dlogfile', $this->root->url() . '/friendica.log');
+
/** @var LoggerInterface $logger */
$logger = $this->dice->create('$devLogger', ['dev']);
- self::assertInstanceOf(LoggerInterface::class, $logger);
+ $this->assertInstanceOf(LoggerInterface::class, $logger);
+ }
+
+ public function testCache()
+ {
+ /** @var ICache $cache */
+ $cache = $this->dice->create(ICache::class);
+
+ $this->assertInstanceOf(ICache::class, $cache);
+ }
+
+ public function testMemoryCache()
+ {
+ /** @var IMemoryCache $cache */
+ $cache = $this->dice->create(IMemoryCache::class);
+
+ // We need to check "just" ICache, because the default Cache is DB-Cache, which isn't a memorycache
+ $this->assertInstanceOf(ICache::class, $cache);
+ }
+
+ public function testLock()
+ {
+ /** @var ILock $cache */
+ $lock = $this->dice->create(ILock::class);
+
+ $this->assertInstanceOf(ILock::class, $lock);
}
}