]> git.mxchange.org Git - friendica.git/blobdiff - tests/include/ApiTest.php
Merge pull request #7907 from nupplaphil/task/reduce_app_deps
[friendica.git] / tests / include / ApiTest.php
index d00aeeb73d0b8d9894848b293a06c9303ac32ff0..ef46a4d447c729c4aa17f4664c6d2fab9f63e227 100644 (file)
@@ -11,6 +11,8 @@ use Friendica\BaseObject;
 use Friendica\Core\Config\Configuration;
 use Friendica\Core\Config\PConfiguration;
 use Friendica\Core\Protocol;
+use Friendica\Core\Session;
+use Friendica\Core\Session\ISession;
 use Friendica\Core\System;
 use Friendica\Database\Database;
 use Friendica\Network\HTTPException;
@@ -57,17 +59,33 @@ class ApiTest extends DatabaseTest
        {
                parent::setUp();
 
-               $this->dice = new Dice();
-               $this->dice = $this->dice->addRules(include __DIR__ . '/../../static/dependencies.config.php');
-               $this->dice = $this->dice->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
+               $this->dice = (new Dice())
+                       ->addRules(include __DIR__ . '/../../static/dependencies.config.php')
+                       ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
+                       ->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]);
                BaseObject::setDependencyInjection($this->dice);
 
                /** @var Database $dba */
                $dba = $this->dice->create(Database::class);
 
+               /** @var Configuration $config */
+               $this->config = $this->dice->create(Configuration::class);
+
+               $this->config->set('system', 'url', 'http://localhost');
+               $this->config->set('system', 'hostname', 'localhost');
+               $this->config->set('system', 'worker_dont_fork', true);
+
+               // Default config
+               $this->config->set('config', 'hostname', 'localhost');
+               $this->config->set('system', 'throttle_limit_day', 100);
+               $this->config->set('system', 'throttle_limit_week', 100);
+               $this->config->set('system', 'throttle_limit_month', 100);
+               $this->config->set('system', 'theme', 'system_theme');
+
                // Load the API dataset for the whole API
                $this->loadFixture(__DIR__ . '/../datasets/api.fixture.php', $dba);
 
+               /** @var App app */
                $this->app = BaseObject::getApp();
 
                $this->app->argc = 1;
@@ -96,6 +114,10 @@ class ApiTest extends DatabaseTest
                // User ID that we know is not in the database
                $this->wrongUserId = 666;
 
+               /** @var ISession $session */
+               $session = BaseObject::getClass(ISession::class);
+               $session->start();
+
                // Most API require login so we force the session
                $_SESSION = [
                        'allow_api'     => true,
@@ -106,20 +128,6 @@ class ApiTest extends DatabaseTest
                $_POST   = [];
                $_GET    = [];
                $_SERVER = [];
-
-               /** @var Configuration $config */
-               $this->config = $this->dice->create(Configuration::class);
-
-               $this->config->set('system', 'url', 'http://localhost');
-               $this->config->set('system', 'hostname', 'localhost');
-               $this->config->set('system', 'worker_dont_fork', true);
-
-               // Default config
-               $this->config->set('config', 'hostname', 'localhost');
-               $this->config->set('system', 'throttle_limit_day', 100);
-               $this->config->set('system', 'throttle_limit_week', 100);
-               $this->config->set('system', 'throttle_limit_month', 100);
-               $this->config->set('system', 'theme', 'system_theme');
        }
 
        /**
@@ -450,8 +458,8 @@ class ApiTest extends DatabaseTest
                        }
                ];
                $_SERVER['REQUEST_METHOD'] = 'method';
-               $this->configset('system', 'profiler', true);
-               $this->configset('rendertime', 'callstack', true);
+               $this->config->set('system', 'profiler', true);
+               $this->config->set('rendertime', 'callstack', true);
                $this->app->callstack = [
                        'database'       => ['some_function' => 200],
                        'database_write' => ['some_function' => 200],
@@ -3774,16 +3782,6 @@ class ApiTest extends DatabaseTest
                $this->assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
        }
 
-       /**
-        * Test the api_clean_attachments() function.
-        *
-        * @return void
-        */
-       public function testApiCleanAttachments()
-       {
-               $this->markTestIncomplete();
-       }
-
        /**
         * Test the api_best_nickname() function.
         *