]> git.mxchange.org Git - friendica.git/blobdiff - tests/functional/DependencyCheckTest.php
Added documentation
[friendica.git] / tests / functional / DependencyCheckTest.php
index 9fe469d5e88f29140a5a8342eb0724f30270fec2..a99e25cda1dc1847c33e86f0b7d8aadd720b7d95 100644 (file)
@@ -1,11 +1,33 @@
 <?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace functional;
 
 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;
@@ -29,8 +51,8 @@ class dependencyCheck extends TestCase
 
                $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');
        }
 
        /**
@@ -56,7 +78,7 @@ class dependencyCheck extends TestCase
 
                $this->assertInstanceOf(ConfigFileLoader::class, $configFileLoader);
 
-               $configCache = new ConfigCache();
+               $configCache = new Cache();
                $configFileLoader->setupCache($configCache);
 
                $this->assertNotEmpty($configCache->getAll());
@@ -74,7 +96,7 @@ class dependencyCheck extends TestCase
 
                $this->assertInstanceOf(Profiler::class, $profiler);
 
-               $configCache = new ConfigCache([
+               $configCache = new Cache([
                        'system' => [
                                'profiler' => true,
                        ],
@@ -84,7 +106,7 @@ class dependencyCheck extends TestCase
                ]);
 
                // create new DI-library because of shared instance rule (so the Profiler wouldn't get created twice)
-               $this->dice = new Dice(include __DIR__ . '/../../static/dependencies.config.php');
+               $this->dice = new Dice();
                $profiler = $this->dice->create(Profiler::class, [$configCache]);
 
                $this->assertInstanceOf(Profiler::class, $profiler);
@@ -112,10 +134,10 @@ class dependencyCheck extends TestCase
 
        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'));
        }
@@ -130,9 +152,38 @@ class dependencyCheck extends TestCase
 
        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);
        }
 }