]> git.mxchange.org Git - friendica.git/blobdiff - tests/include/ApiTest.php
Remove legacy function
[friendica.git] / tests / include / ApiTest.php
index d00aeeb73d0b8d9894848b293a06c9303ac32ff0..3d6bdc0c16816c8adb8fd862441e3bb36678e385 100644 (file)
@@ -13,6 +13,7 @@ use Friendica\Core\Config\PConfiguration;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\Database;
+use Friendica\Model\Contact;
 use Friendica\Network\HTTPException;
 use Friendica\Test\Util\Database\StaticDatabase;
 use Monolog\Handler\TestHandler;
@@ -57,17 +58,32 @@ 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]);
                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;
@@ -106,20 +122,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 +452,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],
@@ -2921,8 +2923,8 @@ class ApiTest extends DatabaseTest
         */
        public function testApiFfIds()
        {
-               $result = api_ff_ids('json');
-               $this->assertNull($result);
+               $result = api_ff_ids('json', Contact::FOLLOWER);
+               $this->assertEquals(['id' => []], $result);
        }
 
        /**
@@ -2944,7 +2946,7 @@ class ApiTest extends DatabaseTest
        public function testApiFfIdsWithoutAuthenticatedUser()
        {
                $_SESSION['authenticated'] = false;
-               api_ff_ids('json');
+               api_ff_ids('json', Contact::FOLLOWER);
        }
 
        /**
@@ -2955,7 +2957,7 @@ class ApiTest extends DatabaseTest
        public function testApiFriendsIds()
        {
                $result = api_friends_ids('json');
-               $this->assertNull($result);
+               $this->assertEquals(['id' => []], $result);
        }
 
        /**
@@ -2966,7 +2968,7 @@ class ApiTest extends DatabaseTest
        public function testApiFollowersIds()
        {
                $result = api_followers_ids('json');
-               $this->assertNull($result);
+               $this->assertEquals(['id' => []], $result);
        }
 
        /**
@@ -3715,28 +3717,6 @@ class ApiTest extends DatabaseTest
                $this->markTestIncomplete();
        }
 
-       /**
-        * Test the api_get_nick() function.
-        *
-        * @return void
-        */
-       public function testApiGetNick()
-       {
-               $result = api_get_nick($this->otherUser['nurl']);
-               $this->assertEquals('othercontact', $result);
-       }
-
-       /**
-        * Test the api_get_nick() function with a wrong URL.
-        *
-        * @return void
-        */
-       public function testApiGetNickWithWrongUrl()
-       {
-               $result = api_get_nick('wrong_url');
-               $this->assertFalse($result);
-       }
-
        /**
         * Test the api_in_reply_to() function.
         *
@@ -3774,16 +3754,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.
         *