]> git.mxchange.org Git - friendica.git/blobdiff - tests/include/ApiTest.php
Merge pull request #7973 from tobiasd/2019.12-CHANGELOG
[friendica.git] / tests / include / ApiTest.php
index 2f8becc18cb8195b8beaf10808014e46b0c636d0..3d6bdc0c16816c8adb8fd862441e3bb36678e385 100644 (file)
@@ -5,15 +5,17 @@
 
 namespace Friendica\Test;
 
+use Dice\Dice;
 use Friendica\App;
-use Friendica\Core\Config;
-use Friendica\Core\Config\Cache;
-use Friendica\Core\PConfig;
+use Friendica\BaseObject;
+use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\PConfiguration;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
-use Friendica\Factory;
+use Friendica\Database\Database;
+use Friendica\Model\Contact;
 use Friendica\Network\HTTPException;
-use Friendica\Util\BasePath;
+use Friendica\Test\Util\Database\StaticDatabase;
 use Monolog\Handler\TestHandler;
 
 require_once __DIR__ . '/../../include/api.php';
@@ -31,38 +33,77 @@ class ApiTest extends DatabaseTest
         */
        protected $logOutput;
 
+       /** @var array */
+       protected $selfUser;
+       /** @var array */
+       protected $friendUser;
+       /** @var array */
+       protected $otherUser;
+
+       protected $wrongUserId;
+
+       /** @var App */
+       protected $app;
+
+       /** @var Configuration */
+       protected $config;
+
+       /** @var Dice */
+       protected $dice;
+
        /**
         * Create variables used by tests.
         */
-       public function setUp()
+       protected function setUp()
        {
-               $basePath = BasePath::create(dirname(__DIR__) . '/../');
-               $configLoader = new Cache\ConfigCacheLoader($basePath);
-               $configCache = Factory\ConfigFactory::createCache($configLoader);
-               $profiler = Factory\ProfilerFactory::create($configCache);
-               Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
-               $config = Factory\ConfigFactory::createConfig($configCache);
-               Factory\ConfigFactory::createPConfig($configCache);
-               $logger = Factory\LoggerFactory::create('test', $config);
-               $this->app = new App($basePath, $config, $logger, $profiler, false);
-
                parent::setUp();
 
+               $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;
+               $this->app->argv = ['home'];
+
                // User data that the test database is populated with
-               $this->selfUser = [
-                       'id' => 42,
+               $this->selfUser   = [
+                       'id'   => 42,
                        'name' => 'Self contact',
                        'nick' => 'selfcontact',
                        'nurl' => 'http://localhost/profile/selfcontact'
                ];
                $this->friendUser = [
-                       'id' => 44,
+                       'id'   => 44,
                        'name' => 'Friend contact',
                        'nick' => 'friendcontact',
                        'nurl' => 'http://localhost/profile/friendcontact'
                ];
-               $this->otherUser = [
-                       'id' => 43,
+               $this->otherUser  = [
+                       'id'   => 43,
                        'name' => 'othercontact',
                        'nick' => 'othercontact',
                        'nurl' => 'http://localhost/profile/othercontact'
@@ -73,37 +114,21 @@ class ApiTest extends DatabaseTest
 
                // Most API require login so we force the session
                $_SESSION = [
-                       'allow_api' => true,
+                       'allow_api'     => true,
                        'authenticated' => true,
-                       'uid' => $this->selfUser['id']
+                       'uid'           => $this->selfUser['id']
                ];
 
-               Config::set('system', 'url', 'http://localhost');
-               Config::set('system', 'hostname', 'localhost');
-               Config::set('system', 'worker_dont_fork', true);
-
-               // Default config
-               Config::set('config', 'hostname', 'localhost');
-               Config::set('system', 'throttle_limit_day', 100);
-               Config::set('system', 'throttle_limit_week', 100);
-               Config::set('system', 'throttle_limit_month', 100);
-               Config::set('system', 'theme', 'system_theme');
-       }
-
-       /**
-        * Cleanup variables used by tests.
-        */
-       protected function tearDown()
-       {
-               parent::tearDown();
-
-               $this->app->argc = 1;
-               $this->app->argv = ['home'];
+               $_POST   = [];
+               $_GET    = [];
+               $_SERVER = [];
        }
 
        /**
         * Assert that an user array contains expected keys.
+        *
         * @param array $user User array
+        *
         * @return void
         */
        private function assertSelfUser(array $user)
@@ -120,7 +145,9 @@ class ApiTest extends DatabaseTest
 
        /**
         * Assert that an user array contains expected keys.
+        *
         * @param array $user User array
+        *
         * @return void
         */
        private function assertOtherUser(array $user)
@@ -135,7 +162,9 @@ class ApiTest extends DatabaseTest
 
        /**
         * Assert that a status array contains expected keys.
+        *
         * @param array $status Status array
+        *
         * @return void
         */
        private function assertStatus(array $status)
@@ -147,7 +176,9 @@ class ApiTest extends DatabaseTest
 
        /**
         * Assert that a list array contains expected keys.
+        *
         * @param array $list List array
+        *
         * @return void
         */
        private function assertList(array $list)
@@ -161,19 +192,22 @@ class ApiTest extends DatabaseTest
 
        /**
         * Assert that the string is XML and contain the root element.
+        *
         * @param string $result       XML string
         * @param string $root_element Root element name
+        *
         * @return void
         */
        private function assertXml($result, $root_element)
        {
                $this->assertStringStartsWith('<?xml version="1.0"?>', $result);
-               $this->assertContains('<'.$root_element, $result);
+               $this->assertContains('<' . $root_element, $result);
                // We could probably do more checks here.
        }
 
        /**
         * Get the path to a temporary empty PNG image.
+        *
         * @return string Path
         */
        private function getTempImage()
@@ -182,7 +216,7 @@ class ApiTest extends DatabaseTest
                file_put_contents(
                        $tmpFile,
                        base64_decode(
-                               // Empty 1x1 px PNG image
+                       // Empty 1x1 px PNG image
                                'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
                        )
                );
@@ -192,6 +226,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_user() function.
+        *
         * @return void
         */
        public function testApiUser()
@@ -201,6 +236,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_user() function with an unallowed user.
+        *
         * @return void
         */
        public function testApiUserWithUnallowedUser()
@@ -211,6 +247,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_source() function.
+        *
         * @return void
         */
        public function testApiSource()
@@ -220,6 +257,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_source() function with a Twidere user agent.
+        *
         * @return void
         */
        public function testApiSourceWithTwidere()
@@ -230,6 +268,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_source() function with a GET parameter.
+        *
         * @return void
         */
        public function testApiSourceWithGet()
@@ -240,6 +279,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_date() function.
+        *
         * @return void
         */
        public function testApiDate()
@@ -249,6 +289,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_register_func() function.
+        *
         * @return void
         */
        public function testApiRegisterFunc()
@@ -270,6 +311,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_login() function without any login.
+        *
         * @return void
         * @runInSeparateProcess
         * @expectedException Friendica\Network\HTTPException\UnauthorizedException
@@ -281,6 +323,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_login() function with a bad login.
+        *
         * @return void
         * @runInSeparateProcess
         * @expectedException Friendica\Network\HTTPException\UnauthorizedException
@@ -293,6 +336,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_login() function with oAuth.
+        *
         * @return void
         */
        public function testApiLoginWithOauth()
@@ -302,6 +346,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_login() function with authentication provided by an addon.
+        *
         * @return void
         */
        public function testApiLoginWithAddonAuth()
@@ -311,18 +356,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_login() function with a correct login.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiLoginWithCorrectLogin()
        {
                $_SERVER['PHP_AUTH_USER'] = 'Test user';
-               $_SERVER['PHP_AUTH_PW'] = 'password';
+               $_SERVER['PHP_AUTH_PW']   = 'password';
                api_login($this->app);
        }
 
        /**
         * Test the api_login() function with a remote user.
+        *
         * @return void
         * @runInSeparateProcess
         * @expectedException Friendica\Network\HTTPException\UnauthorizedException
@@ -335,6 +382,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_check_method() function.
+        *
         * @return void
         */
        public function testApiCheckMethod()
@@ -344,6 +392,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_check_method() function with a correct method.
+        *
         * @return void
         */
        public function testApiCheckMethodWithCorrectMethod()
@@ -354,6 +403,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_check_method() function with a wildcard.
+        *
         * @return void
         */
        public function testApiCheckMethodWithWildcard()
@@ -363,20 +413,21 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_call() function.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiCall()
        {
                global $API;
-               $API['api_path'] = [
+               $API['api_path']           = [
                        'method' => 'method',
-                       'func' => function () {
+                       'func'   => function () {
                                return ['data' => ['some_data']];
                        }
                ];
                $_SERVER['REQUEST_METHOD'] = 'method';
-               $_GET['callback'] = 'callback_name';
+               $_GET['callback']          = 'callback_name';
 
                $this->app->query_string = 'api_path';
                $this->assertEquals(
@@ -387,27 +438,28 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_call() function with the profiled enabled.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiCallWithProfiler()
        {
                global $API;
-               $API['api_path'] = [
+               $API['api_path']           = [
                        'method' => 'method',
-                       'func' => function () {
+                       'func'   => function () {
                                return ['data' => ['some_data']];
                        }
                ];
                $_SERVER['REQUEST_METHOD'] = 'method';
-               Config::set('system', 'profiler', true);
-               Config::set('rendertime', 'callstack', true);
+               $this->config->set('system', 'profiler', true);
+               $this->config->set('rendertime', 'callstack', true);
                $this->app->callstack = [
-                       'database' => ['some_function' => 200],
+                       'database'       => ['some_function' => 200],
                        'database_write' => ['some_function' => 200],
-                       'cache' => ['some_function' => 200],
-                       'cache_write' => ['some_function' => 200],
-                       'network' => ['some_function' => 200]
+                       'cache'          => ['some_function' => 200],
+                       'cache_write'    => ['some_function' => 200],
+                       'network'        => ['some_function' => 200]
                ];
 
                $this->app->query_string = 'api_path';
@@ -419,15 +471,16 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_call() function without any result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiCallWithNoResult()
        {
                global $API;
-               $API['api_path'] = [
+               $API['api_path']           = [
                        'method' => 'method',
-                       'func' => function () {
+                       'func'   => function () {
                                return false;
                        }
                ];
@@ -442,6 +495,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_call() function with an unimplemented API.
+        *
         * @return void
         * @runInSeparateProcess
         */
@@ -455,15 +509,16 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_call() function with a JSON result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiCallWithJson()
        {
                global $API;
-               $API['api_path'] = [
+               $API['api_path']           = [
                        'method' => 'method',
-                       'func' => function () {
+                       'func'   => function () {
                                return ['data' => ['some_data']];
                        }
                ];
@@ -478,15 +533,16 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_call() function with an XML result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiCallWithXml()
        {
                global $API;
-               $API['api_path'] = [
+               $API['api_path']           = [
                        'method' => 'method',
-                       'func' => function () {
+                       'func'   => function () {
                                return 'some_data';
                        }
                ];
@@ -501,15 +557,16 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_call() function with an RSS result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiCallWithRss()
        {
                global $API;
-               $API['api_path'] = [
+               $API['api_path']           = [
                        'method' => 'method',
-                       'func' => function () {
+                       'func'   => function () {
                                return 'some_data';
                        }
                ];
@@ -517,23 +574,24 @@ class ApiTest extends DatabaseTest
 
                $this->app->query_string = 'api_path.rss';
                $this->assertEquals(
-                       '<?xml version="1.0" encoding="UTF-8"?>'."\n".
-                               'some_data',
+                       '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
+                       'some_data',
                        api_call($this->app)
                );
        }
 
        /**
         * Test the api_call() function with an Atom result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiCallWithAtom()
        {
                global $API;
-               $API['api_path'] = [
+               $API['api_path']           = [
                        'method' => 'method',
-                       'func' => function () {
+                       'func'   => function () {
                                return 'some_data';
                        }
                ];
@@ -541,14 +599,15 @@ class ApiTest extends DatabaseTest
 
                $this->app->query_string = 'api_path.atom';
                $this->assertEquals(
-                       '<?xml version="1.0" encoding="UTF-8"?>'."\n".
-                               'some_data',
+                       '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
+                       'some_data',
                        api_call($this->app)
                );
        }
 
        /**
         * Test the api_call() function with an unallowed method.
+        *
         * @return void
         * @runInSeparateProcess
         */
@@ -566,15 +625,16 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_call() function with an unauthorized user.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiCallWithWrongAuth()
        {
                global $API;
-               $API['api_path'] = [
+               $API['api_path']           = [
                        'method' => 'method',
-                       'auth' => true
+                       'auth'   => true
                ];
                $_SERVER['REQUEST_METHOD'] = 'method';
                $_SESSION['authenticated'] = false;
@@ -588,85 +648,90 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_error() function with a JSON result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiErrorWithJson()
        {
                $this->assertEquals(
-                       '{"status":{"error":"error_message","code":"200 Friendica\\\\Network\\\\HTTP","request":""}}',
-                       api_error('json', new HTTPException('error_message'))
+                       '{"status":{"error":"error_message","code":"200 OK","request":""}}',
+                       api_error('json', new HTTPException\OKException('error_message'))
                );
        }
 
        /**
         * Test the api_error() function with an XML result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiErrorWithXml()
        {
                $this->assertEquals(
-                       '<?xml version="1.0"?>'."\n".
-                       '<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" '.
-                               'xmlns:friendica="http://friendi.ca/schema/api/1/" '.
-                               'xmlns:georss="http://www.georss.org/georss">'."\n".
-                       '  <error>error_message</error>'."\n".
-                       '  <code>200 Friendica\Network\HTTP</code>'."\n".
-                       '  <request/>'."\n".
-                       '</status>'."\n",
-                       api_error('xml', new HTTPException('error_message'))
+                       '<?xml version="1.0"?>' . "\n" .
+                       '<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
+                       'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
+                       'xmlns:georss="http://www.georss.org/georss">' . "\n" .
+                       '  <error>error_message</error>' . "\n" .
+                       '  <code>200 OK</code>' . "\n" .
+                       '  <request/>' . "\n" .
+                       '</status>' . "\n",
+                       api_error('xml', new HTTPException\OKException('error_message'))
                );
        }
 
        /**
         * Test the api_error() function with an RSS result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiErrorWithRss()
        {
                $this->assertEquals(
-                       '<?xml version="1.0"?>'."\n".
-                       '<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" '.
-                               'xmlns:friendica="http://friendi.ca/schema/api/1/" '.
-                               'xmlns:georss="http://www.georss.org/georss">'."\n".
-                       '  <error>error_message</error>'."\n".
-                       '  <code>200 Friendica\Network\HTTP</code>'."\n".
-                       '  <request/>'."\n".
-                       '</status>'."\n",
-                       api_error('rss', new HTTPException('error_message'))
+                       '<?xml version="1.0"?>' . "\n" .
+                       '<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
+                       'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
+                       'xmlns:georss="http://www.georss.org/georss">' . "\n" .
+                       '  <error>error_message</error>' . "\n" .
+                       '  <code>200 OK</code>' . "\n" .
+                       '  <request/>' . "\n" .
+                       '</status>' . "\n",
+                       api_error('rss', new HTTPException\OKException('error_message'))
                );
        }
 
        /**
         * Test the api_error() function with an Atom result.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiErrorWithAtom()
        {
                $this->assertEquals(
-                       '<?xml version="1.0"?>'."\n".
-                       '<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" '.
-                               'xmlns:friendica="http://friendi.ca/schema/api/1/" '.
-                               'xmlns:georss="http://www.georss.org/georss">'."\n".
-                       '  <error>error_message</error>'."\n".
-                       '  <code>200 Friendica\Network\HTTP</code>'."\n".
-                       '  <request/>'."\n".
-                       '</status>'."\n",
-                       api_error('atom', new HTTPException('error_message'))
+                       '<?xml version="1.0"?>' . "\n" .
+                       '<status xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
+                       'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
+                       'xmlns:georss="http://www.georss.org/georss">' . "\n" .
+                       '  <error>error_message</error>' . "\n" .
+                       '  <code>200 OK</code>' . "\n" .
+                       '  <request/>' . "\n" .
+                       '</status>' . "\n",
+                       api_error('atom', new HTTPException\OKException('error_message'))
                );
        }
 
        /**
         * Test the api_rss_extra() function.
+        *
         * @return void
         */
        public function testApiRssExtra()
        {
                $user_info = ['url' => 'user_url', 'lang' => 'en'];
-               $result = api_rss_extra($this->app, [], $user_info);
+               $result    = api_rss_extra($this->app, [], $user_info);
                $this->assertEquals($user_info, $result['$user']);
                $this->assertEquals($user_info['url'], $result['$rss']['alternate']);
                $this->assertArrayHasKey('self', $result['$rss']);
@@ -679,8 +744,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_rss_extra() function without any user info.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiRssExtraWithoutUserInfo()
        {
@@ -697,6 +762,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_unique_id_to_nurl() function.
+        *
         * @return void
         */
        public function testApiUniqueIdToNurl()
@@ -706,6 +772,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_unique_id_to_nurl() function with a correct ID.
+        *
         * @return void
         */
        public function testApiUniqueIdToNurlWithCorrectId()
@@ -715,8 +782,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUser()
        {
@@ -729,12 +796,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with a Frio schema.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithFrioSchema()
        {
-               PConfig::set($this->selfUser['id'], 'frio', 'schema', 'red');
+               $pConfig = $this->dice->create(PConfiguration::class);
+               $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
                $user = api_get_user($this->app);
                $this->assertSelfUser($user);
                $this->assertEquals('708fa0', $user['profile_sidebar_fill_color']);
@@ -744,15 +812,16 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with a custom Frio schema.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithCustomFrioSchema()
        {
-               $ret1 = PConfig::set($this->selfUser['id'], 'frio', 'schema', '---');
-               $ret2 = PConfig::set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
-               $ret3 = PConfig::set($this->selfUser['id'], 'frio', 'link_color', '#123456');
-               $ret4 = PConfig::set($this->selfUser['id'], 'frio', 'background_color', '#123456');
+               $pConfig = $this->dice->create(PConfiguration::class);
+               $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
+               $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
+               $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
+               $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
                $user = api_get_user($this->app);
                $this->assertSelfUser($user);
                $this->assertEquals('123456', $user['profile_sidebar_fill_color']);
@@ -762,12 +831,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with an empty Frio schema.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithEmptyFrioSchema()
        {
-               PConfig::set($this->selfUser['id'], 'frio', 'schema', '---');
+               $pConfig = $this->dice->create(PConfiguration::class);
+               $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
                $user = api_get_user($this->app);
                $this->assertSelfUser($user);
                $this->assertEquals('708fa0', $user['profile_sidebar_fill_color']);
@@ -777,21 +847,22 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with an user that is not allowed to use the API.
+        *
         * @return void
         * @runInSeparateProcess
         */
        public function testApiGetUserWithoutApiUser()
        {
                $_SERVER['PHP_AUTH_USER'] = 'Test user';
-               $_SERVER['PHP_AUTH_PW'] = 'password';
-               $_SESSION['allow_api'] = false;
+               $_SERVER['PHP_AUTH_PW']   = 'password';
+               $_SESSION['allow_api']    = false;
                $this->assertFalse(api_get_user($this->app));
        }
 
        /**
         * Test the api_get_user() function with an user ID in a GET parameter.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithGetId()
        {
@@ -801,8 +872,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with a wrong user ID in a GET parameter.
+        *
         * @return void
-        * @runInSeparateProcess
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiGetUserWithWrongGetId()
@@ -813,8 +884,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with an user name in a GET parameter.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithGetName()
        {
@@ -824,8 +895,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with a profile URL in a GET parameter.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithGetUrl()
        {
@@ -835,21 +906,21 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with an user ID in the API path.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithNumericCalledApi()
        {
                global $called_api;
-               $called_api = ['api_path'];
-               $this->app->argv[1] = $this->otherUser['id'].'.json';
+               $called_api         = ['api_path'];
+               $this->app->argv[1] = $this->otherUser['id'] . '.json';
                $this->assertOtherUser(api_get_user($this->app));
        }
 
        /**
         * Test the api_get_user() function with the $called_api global variable.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithCalledApi()
        {
@@ -860,8 +931,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with a valid user.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithCorrectUser()
        {
@@ -870,8 +941,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with a wrong user ID.
+        *
         * @return void
-        * @runInSeparateProcess
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiGetUserWithWrongUser()
@@ -881,8 +952,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_user() function with a 0 user ID.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiGetUserWithZeroUser()
        {
@@ -891,8 +962,8 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_item_get_user() function.
+        *
         * @return void
-        * @runInSeparateProcess
         */
        public function testApiItemGetUser()
        {
@@ -902,6 +973,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_item_get_user() function with a different item parent.
+        *
         * @return void
         */
        public function testApiItemGetUserWithDifferentParent()
@@ -913,6 +985,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_walk_recursive() function.
+        *
         * @return void
         */
        public function testApiWalkRecursive()
@@ -932,6 +1005,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_walk_recursive() function with an array.
+        *
         * @return void
         */
        public function testApiWalkRecursiveWithArray()
@@ -951,74 +1025,80 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_reformat_xml() function.
+        *
         * @return void
         */
        public function testApiReformatXml()
        {
                $item = true;
-               $key = '';
+               $key  = '';
                $this->assertTrue(api_reformat_xml($item, $key));
                $this->assertEquals('true', $item);
        }
 
        /**
         * Test the api_reformat_xml() function with a statusnet_api key.
+        *
         * @return void
         */
        public function testApiReformatXmlWithStatusnetKey()
        {
                $item = '';
-               $key = 'statusnet_api';
+               $key  = 'statusnet_api';
                $this->assertTrue(api_reformat_xml($item, $key));
                $this->assertEquals('statusnet:api', $key);
        }
 
        /**
         * Test the api_reformat_xml() function with a friendica_api key.
+        *
         * @return void
         */
        public function testApiReformatXmlWithFriendicaKey()
        {
                $item = '';
-               $key = 'friendica_api';
+               $key  = 'friendica_api';
                $this->assertTrue(api_reformat_xml($item, $key));
                $this->assertEquals('friendica:api', $key);
        }
 
        /**
         * Test the api_create_xml() function.
+        *
         * @return void
         */
        public function testApiCreateXml()
        {
                $this->assertEquals(
-                       '<?xml version="1.0"?>'."\n".
-                       '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" '.
-                               'xmlns:friendica="http://friendi.ca/schema/api/1/" '.
-                               'xmlns:georss="http://www.georss.org/georss">'."\n".
-                               '  <data>some_data</data>'."\n".
-                       '</root_element>'."\n",
+                       '<?xml version="1.0"?>' . "\n" .
+                       '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
+                       'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
+                       'xmlns:georss="http://www.georss.org/georss">' . "\n" .
+                       '  <data>some_data</data>' . "\n" .
+                       '</root_element>' . "\n",
                        api_create_xml(['data' => ['some_data']], 'root_element')
                );
        }
 
        /**
         * Test the api_create_xml() function without any XML namespace.
+        *
         * @return void
         */
        public function testApiCreateXmlWithoutNamespaces()
        {
                $this->assertEquals(
-                       '<?xml version="1.0"?>'."\n".
-                       '<ok>'."\n".
-                               '  <data>some_data</data>'."\n".
-                       '</ok>'."\n",
+                       '<?xml version="1.0"?>' . "\n" .
+                       '<ok>' . "\n" .
+                       '  <data>some_data</data>' . "\n" .
+                       '</ok>' . "\n",
                        api_create_xml(['data' => ['some_data']], 'ok')
                );
        }
 
        /**
         * Test the api_format_data() function.
+        *
         * @return void
         */
        public function testApiFormatData()
@@ -1029,23 +1109,25 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_data() function with an XML result.
+        *
         * @return void
         */
        public function testApiFormatDataWithXml()
        {
                $this->assertEquals(
-                       '<?xml version="1.0"?>'."\n".
-                       '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" '.
-                               'xmlns:friendica="http://friendi.ca/schema/api/1/" '.
-                               'xmlns:georss="http://www.georss.org/georss">'."\n".
-                               '  <data>some_data</data>'."\n".
-                       '</root_element>'."\n",
+                       '<?xml version="1.0"?>' . "\n" .
+                       '<root_element xmlns="http://api.twitter.com" xmlns:statusnet="http://status.net/schema/api/1/" ' .
+                       'xmlns:friendica="http://friendi.ca/schema/api/1/" ' .
+                       'xmlns:georss="http://www.georss.org/georss">' . "\n" .
+                       '  <data>some_data</data>' . "\n" .
+                       '</root_element>' . "\n",
                        api_format_data('root_element', 'xml', ['data' => ['some_data']])
                );
        }
 
        /**
         * Test the api_account_verify_credentials() function.
+        *
         * @return void
         */
        public function testApiAccountVerifyCredentials()
@@ -1055,6 +1137,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_account_verify_credentials() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -1066,6 +1149,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the requestdata() function.
+        *
         * @return void
         */
        public function testRequestdata()
@@ -1075,6 +1159,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the requestdata() function with a POST parameter.
+        *
         * @return void
         */
        public function testRequestdataWithPost()
@@ -1085,6 +1170,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the requestdata() function with a GET parameter.
+        *
         * @return void
         */
        public function testRequestdataWithGet()
@@ -1095,21 +1181,22 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_mediap() function.
+        *
         * @return void
         */
        public function testApiStatusesMediap()
        {
                $this->app->argc = 2;
 
-               $_FILES = [
+               $_FILES         = [
                        'media' => [
-                               'id' => 666,
-                               'size' => 666,
-                               'width' => 666,
-                               'height' => 666,
+                               'id'       => 666,
+                               'size'     => 666,
+                               'width'    => 666,
+                               'height'   => 666,
                                'tmp_name' => $this->getTempImage(),
-                               'name' => 'spacer.png',
-                               'type' => 'image/png'
+                               'name'     => 'spacer.png',
+                               'type'     => 'image/png'
                        ]
                ];
                $_GET['status'] = '<b>Status content</b>';
@@ -1120,6 +1207,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_mediap() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -1131,23 +1219,24 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_update() function.
+        *
         * @return void
         */
        public function testApiStatusesUpdate()
        {
-               $_GET['status'] = 'Status content #friendica';
+               $_GET['status']                = 'Status content #friendica';
                $_GET['in_reply_to_status_id'] = -1;
-               $_GET['lat'] = 48;
-               $_GET['long'] = 7;
-               $_FILES = [
+               $_GET['lat']                   = 48;
+               $_GET['long']                  = 7;
+               $_FILES                        = [
                        'media' => [
-                               'id' => 666,
-                               'size' => 666,
-                               'width' => 666,
-                               'height' => 666,
+                               'id'       => 666,
+                               'size'     => 666,
+                               'width'    => 666,
+                               'height'   => 666,
                                'tmp_name' => $this->getTempImage(),
-                               'name' => 'spacer.png',
-                               'type' => 'image/png'
+                               'name'     => 'spacer.png',
+                               'type'     => 'image/png'
                        ]
                ];
 
@@ -1157,6 +1246,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_update() function with an HTML status.
+        *
         * @return void
         */
        public function testApiStatusesUpdateWithHtml()
@@ -1169,6 +1259,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_update() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -1180,6 +1271,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_update() function with a parent status.
+        *
         * @return void
         */
        public function testApiStatusesUpdateWithParent()
@@ -1189,6 +1281,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_update() function with a media_ids parameter.
+        *
         * @return void
         */
        public function testApiStatusesUpdateWithMediaIds()
@@ -1198,6 +1291,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_update() function with the throttle limit reached.
+        *
         * @return void
         */
        public function testApiStatusesUpdateWithDayThrottleReached()
@@ -1207,6 +1301,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_media_upload() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1217,6 +1312,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_media_upload() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -1228,6 +1324,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_media_upload() function with an invalid uploaded media.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\InternalServerErrorException
         */
@@ -1235,7 +1332,7 @@ class ApiTest extends DatabaseTest
        {
                $_FILES = [
                        'media' => [
-                               'id' => 666,
+                               'id'       => 666,
                                'tmp_name' => 'tmp_name'
                        ]
                ];
@@ -1244,22 +1341,23 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_media_upload() function with an valid uploaded media.
+        *
         * @return void
         */
        public function testApiMediaUploadWithValidMedia()
        {
-               $_FILES = [
+               $_FILES    = [
                        'media' => [
-                               'id' => 666,
-                               'size' => 666,
-                               'width' => 666,
-                               'height' => 666,
+                               'id'       => 666,
+                               'size'     => 666,
+                               'width'    => 666,
+                               'height'   => 666,
                                'tmp_name' => $this->getTempImage(),
-                               'name' => 'spacer.png',
-                               'type' => 'image/png'
+                               'name'     => 'spacer.png',
+                               'type'     => 'image/png'
                        ]
                ];
-               $app = \get_app();
+               $app       = \get_app();
                $app->argc = 2;
 
                $result = api_media_upload();
@@ -1271,35 +1369,35 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_status_show() function.
-        * @return void
         */
-       public function testApiStatusShow()
+       public function testApiStatusShowWithJson()
        {
-               $result = api_status_show('json');
+               $result = api_status_show('json', 1);
                $this->assertStatus($result['status']);
        }
 
        /**
         * Test the api_status_show() function with an XML result.
-        * @return void
         */
        public function testApiStatusShowWithXml()
        {
-               $result = api_status_show('xml');
+               $result = api_status_show('xml', 1);
                $this->assertXml($result, 'statuses');
        }
 
        /**
-        * Test the api_status_show() function with a raw result.
-        * @return void
+        * Test the api_get_last_status() function
         */
-       public function testApiStatusShowWithRaw()
+       public function testApiGetLastStatus()
        {
-               $this->assertStatus(api_status_show('raw'));
+               $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
+
+               $this->assertNotNull($item);
        }
 
        /**
         * Test the api_users_show() function.
+        *
         * @return void
         */
        public function testApiUsersShow()
@@ -1316,6 +1414,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_users_show() function with an XML result.
+        *
         * @return void
         */
        public function testApiUsersShowWithXml()
@@ -1326,28 +1425,31 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_users_search() function.
+        *
         * @return void
         */
        public function testApiUsersSearch()
        {
                $_GET['q'] = 'othercontact';
-               $result = api_users_search('json');
+               $result    = api_users_search('json');
                $this->assertOtherUser($result['users'][0]);
        }
 
        /**
         * Test the api_users_search() function with an XML result.
+        *
         * @return void
         */
        public function testApiUsersSearchWithXml()
        {
                $_GET['q'] = 'othercontact';
-               $result = api_users_search('xml');
+               $result    = api_users_search('xml');
                $this->assertXml($result, 'users');
        }
 
        /**
         * Test the api_users_search() function without a GET q parameter.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1358,6 +1460,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_users_lookup() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\NotFoundException
         */
@@ -1368,24 +1471,26 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_users_lookup() function with an user ID.
+        *
         * @return void
         */
        public function testApiUsersLookupWithUserId()
        {
                $_REQUEST['user_id'] = $this->otherUser['id'];
-               $result = api_users_lookup('json');
+               $result              = api_users_lookup('json');
                $this->assertOtherUser($result['users'][0]);
        }
 
        /**
         * Test the api_search() function.
+        *
         * @return void
         */
        public function testApiSearch()
        {
-               $_REQUEST['q'] = 'reply';
+               $_REQUEST['q']      = 'reply';
                $_REQUEST['max_id'] = 10;
-               $result = api_search('json');
+               $result             = api_search('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
                        $this->assertContains('reply', $status['text'], null, true);
@@ -1394,13 +1499,14 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_search() function a count parameter.
+        *
         * @return void
         */
        public function testApiSearchWithCount()
        {
-               $_REQUEST['q'] = 'reply';
+               $_REQUEST['q']     = 'reply';
                $_REQUEST['count'] = 20;
-               $result = api_search('json');
+               $result            = api_search('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
                        $this->assertContains('reply', $status['text'], null, true);
@@ -1409,13 +1515,14 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_search() function with an rpp parameter.
+        *
         * @return void
         */
        public function testApiSearchWithRpp()
        {
-               $_REQUEST['q'] = 'reply';
+               $_REQUEST['q']   = 'reply';
                $_REQUEST['rpp'] = 20;
-               $result = api_search('json');
+               $result          = api_search('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
                        $this->assertContains('reply', $status['text'], null, true);
@@ -1424,12 +1531,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_search() function with an q parameter contains hashtag.
+        *
         * @return void
         */
        public function testApiSearchWithHashtag()
        {
                $_REQUEST['q'] = '%23friendica';
-               $result = api_search('json');
+               $result        = api_search('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
                        $this->assertContains('#friendica', $status['text'], null, true);
@@ -1438,14 +1546,15 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_search() function with an exclude_replies parameter.
+        *
         * @return void
         */
        public function testApiSearchWithExcludeReplies()
        {
-               $_REQUEST['max_id'] = 10;
+               $_REQUEST['max_id']          = 10;
                $_REQUEST['exclude_replies'] = true;
-               $_REQUEST['q'] = 'friendica';
-               $result = api_search('json');
+               $_REQUEST['q']               = 'friendica';
+               $result                      = api_search('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
                }
@@ -1453,18 +1562,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_search() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiSearchWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_search('json');
        }
 
        /**
         * Test the api_search() function without any GET query parameter.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1475,14 +1586,15 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_home_timeline() function.
+        *
         * @return void
         */
        public function testApiStatusesHomeTimeline()
        {
-               $_REQUEST['max_id'] = 10;
+               $_REQUEST['max_id']          = 10;
                $_REQUEST['exclude_replies'] = true;
                $_REQUEST['conversation_id'] = 1;
-               $result = api_statuses_home_timeline('json');
+               $result                      = api_statuses_home_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1491,12 +1603,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_home_timeline() function with a negative page parameter.
+        *
         * @return void
         */
        public function testApiStatusesHomeTimelineWithNegativePage()
        {
                $_REQUEST['page'] = -2;
-               $result = api_statuses_home_timeline('json');
+               $result           = api_statuses_home_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1505,18 +1618,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_home_timeline() with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesHomeTimelineWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_home_timeline('json');
        }
 
        /**
         * Test the api_statuses_home_timeline() function with an RSS result.
+        *
         * @return void
         */
        public function testApiStatusesHomeTimelineWithRss()
@@ -1527,13 +1642,14 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_public_timeline() function.
+        *
         * @return void
         */
        public function testApiStatusesPublicTimeline()
        {
-               $_REQUEST['max_id'] = 10;
+               $_REQUEST['max_id']          = 10;
                $_REQUEST['conversation_id'] = 1;
-               $result = api_statuses_public_timeline('json');
+               $result                      = api_statuses_public_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1542,13 +1658,14 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_public_timeline() function with the exclude_replies parameter.
+        *
         * @return void
         */
        public function testApiStatusesPublicTimelineWithExcludeReplies()
        {
-               $_REQUEST['max_id'] = 10;
+               $_REQUEST['max_id']          = 10;
                $_REQUEST['exclude_replies'] = true;
-               $result = api_statuses_public_timeline('json');
+               $result                      = api_statuses_public_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1557,12 +1674,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_public_timeline() function with a negative page parameter.
+        *
         * @return void
         */
        public function testApiStatusesPublicTimelineWithNegativePage()
        {
                $_REQUEST['page'] = -2;
-               $result = api_statuses_public_timeline('json');
+               $result           = api_statuses_public_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1571,18 +1689,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_public_timeline() function with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesPublicTimelineWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_public_timeline('json');
        }
 
        /**
         * Test the api_statuses_public_timeline() function with an RSS result.
+        *
         * @return void
         */
        public function testApiStatusesPublicTimelineWithRss()
@@ -1593,12 +1713,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_networkpublic_timeline() function.
+        *
         * @return void
         */
        public function testApiStatusesNetworkpublicTimeline()
        {
                $_REQUEST['max_id'] = 10;
-               $result = api_statuses_networkpublic_timeline('json');
+               $result             = api_statuses_networkpublic_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1607,12 +1728,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
+        *
         * @return void
         */
        public function testApiStatusesNetworkpublicTimelineWithNegativePage()
        {
                $_REQUEST['page'] = -2;
-               $result = api_statuses_networkpublic_timeline('json');
+               $result           = api_statuses_networkpublic_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1621,18 +1743,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_networkpublic_timeline('json');
        }
 
        /**
         * Test the api_statuses_networkpublic_timeline() function with an RSS result.
+        *
         * @return void
         */
        public function testApiStatusesNetworkpublicTimelineWithRss()
@@ -1643,6 +1767,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_show() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1653,24 +1778,26 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_show() function with an ID.
+        *
         * @return void
         */
        public function testApiStatusesShowWithId()
        {
                $this->app->argv[3] = 1;
-               $result = api_statuses_show('json');
+               $result             = api_statuses_show('json');
                $this->assertStatus($result['status']);
        }
 
        /**
         * Test the api_statuses_show() function with the conversation parameter.
+        *
         * @return void
         */
        public function testApiStatusesShowWithConversation()
        {
-               $this->app->argv[3] = 1;
+               $this->app->argv[3]       = 1;
                $_REQUEST['conversation'] = 1;
-               $result = api_statuses_show('json');
+               $result                   = api_statuses_show('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1679,18 +1806,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_show() function with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesShowWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_show('json');
        }
 
        /**
         * Test the api_conversation_show() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1701,14 +1830,15 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_conversation_show() function with an ID.
+        *
         * @return void
         */
        public function testApiConversationShowWithId()
        {
                $this->app->argv[3] = 1;
                $_REQUEST['max_id'] = 10;
-               $_REQUEST['page'] = -2;
-               $result = api_conversation_show('json');
+               $_REQUEST['page']   = -2;
+               $result             = api_conversation_show('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1717,18 +1847,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_conversation_show() function with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiConversationShowWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_conversation_show('json');
        }
 
        /**
         * Test the api_statuses_repeat() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -1739,6 +1871,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_repeat() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -1750,22 +1883,24 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_repeat() function with an ID.
+        *
         * @return void
         */
        public function testApiStatusesRepeatWithId()
        {
                $this->app->argv[3] = 1;
-               $result = api_statuses_repeat('json');
+               $result             = api_statuses_repeat('json');
                $this->assertStatus($result['status']);
 
                // Also test with a shared status
                $this->app->argv[3] = 5;
-               $result = api_statuses_repeat('json');
+               $result             = api_statuses_repeat('json');
                $this->assertStatus($result['status']);
        }
 
        /**
         * Test the api_statuses_destroy() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1776,6 +1911,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_destroy() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -1787,53 +1923,58 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_destroy() function with an ID.
+        *
         * @return void
         */
        public function testApiStatusesDestroyWithId()
        {
                $this->app->argv[3] = 1;
-               $result = api_statuses_destroy('json');
+               $result             = api_statuses_destroy('json');
                $this->assertStatus($result['status']);
        }
 
        /**
         * Test the api_statuses_mentions() function.
+        *
         * @return void
         */
        public function testApiStatusesMentions()
        {
-               $this->app->user = ['nickname' => $this->selfUser['nick']];
+               $this->app->user    = ['nickname' => $this->selfUser['nick']];
                $_REQUEST['max_id'] = 10;
-               $result = api_statuses_mentions('json');
+               $result             = api_statuses_mentions('json');
                $this->assertEmpty($result['status']);
                // We should test with mentions in the database.
        }
 
        /**
         * Test the api_statuses_mentions() function with a negative page parameter.
+        *
         * @return void
         */
        public function testApiStatusesMentionsWithNegativePage()
        {
                $_REQUEST['page'] = -2;
-               $result = api_statuses_mentions('json');
+               $result           = api_statuses_mentions('json');
                $this->assertEmpty($result['status']);
        }
 
        /**
         * Test the api_statuses_mentions() function with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesMentionsWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_mentions('json');
        }
 
        /**
         * Test the api_statuses_mentions() function with an RSS result.
+        *
         * @return void
         */
        public function testApiStatusesMentionsWithRss()
@@ -1844,14 +1985,15 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_user_timeline() function.
+        *
         * @return void
         */
        public function testApiStatusesUserTimeline()
        {
-               $_REQUEST['max_id'] = 10;
+               $_REQUEST['max_id']          = 10;
                $_REQUEST['exclude_replies'] = true;
                $_REQUEST['conversation_id'] = 1;
-               $result = api_statuses_user_timeline('json');
+               $result                      = api_statuses_user_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1860,12 +2002,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_user_timeline() function with a negative page parameter.
+        *
         * @return void
         */
        public function testApiStatusesUserTimelineWithNegativePage()
        {
                $_REQUEST['page'] = -2;
-               $result = api_statuses_user_timeline('json');
+               $result           = api_statuses_user_timeline('json');
                $this->assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
@@ -1874,6 +2017,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_user_timeline() function with an RSS result.
+        *
         * @return void
         */
        public function testApiStatusesUserTimelineWithRss()
@@ -1884,18 +2028,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_user_timeline() function with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesUserTimelineWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_user_timeline('json');
        }
 
        /**
         * Test the api_favorites_create_destroy() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1908,6 +2054,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_favorites_create_destroy() function with an invalid ID.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1920,6 +2067,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_favorites_create_destroy() function with an invalid action.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -1927,71 +2075,76 @@ class ApiTest extends DatabaseTest
        {
                $this->app->argv = ['api', '1.1', 'favorites', 'change.json'];
                $this->app->argc = count($this->app->argv);
-               $_REQUEST['id'] = 1;
+               $_REQUEST['id']  = 1;
                api_favorites_create_destroy('json');
        }
 
        /**
         * Test the api_favorites_create_destroy() function with the create action.
+        *
         * @return void
         */
        public function testApiFavoritesCreateDestroyWithCreateAction()
        {
                $this->app->argv = ['api', '1.1', 'favorites', 'create.json'];
                $this->app->argc = count($this->app->argv);
-               $_REQUEST['id'] = 3;
-               $result = api_favorites_create_destroy('json');
+               $_REQUEST['id']  = 3;
+               $result          = api_favorites_create_destroy('json');
                $this->assertStatus($result['status']);
        }
 
        /**
         * Test the api_favorites_create_destroy() function with the create action and an RSS result.
+        *
         * @return void
         */
        public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
        {
                $this->app->argv = ['api', '1.1', 'favorites', 'create.rss'];
                $this->app->argc = count($this->app->argv);
-               $_REQUEST['id'] = 3;
-               $result = api_favorites_create_destroy('rss');
+               $_REQUEST['id']  = 3;
+               $result          = api_favorites_create_destroy('rss');
                $this->assertXml($result, 'status');
        }
 
        /**
         * Test the api_favorites_create_destroy() function with the destroy action.
+        *
         * @return void
         */
        public function testApiFavoritesCreateDestroyWithDestroyAction()
        {
                $this->app->argv = ['api', '1.1', 'favorites', 'destroy.json'];
                $this->app->argc = count($this->app->argv);
-               $_REQUEST['id'] = 3;
-               $result = api_favorites_create_destroy('json');
+               $_REQUEST['id']  = 3;
+               $result          = api_favorites_create_destroy('json');
                $this->assertStatus($result['status']);
        }
 
        /**
         * Test the api_favorites_create_destroy() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
        {
-               $this->app->argv = ['api', '1.1', 'favorites', 'create.json'];
-               $this->app->argc = count($this->app->argv);
+               $this->app->argv           = ['api', '1.1', 'favorites', 'create.json'];
+               $this->app->argc           = count($this->app->argv);
                $_SESSION['authenticated'] = false;
                api_favorites_create_destroy('json');
        }
 
        /**
         * Test the api_favorites() function.
+        *
         * @return void
         */
        public function testApiFavorites()
        {
-               $_REQUEST['page'] = -1;
+               $_REQUEST['page']   = -1;
                $_REQUEST['max_id'] = 10;
-               $result = api_favorites('json');
+               $result             = api_favorites('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
                }
@@ -1999,6 +2152,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_favorites() function with an RSS result.
+        *
         * @return void
         */
        public function testApiFavoritesWithRss()
@@ -2009,18 +2163,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_favorites() function with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFavoritesWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_favorites('json');
        }
 
        /**
         * Test the api_format_messages() function.
+        *
         * @return void
         */
        public function testApiFormatMessages()
@@ -2030,7 +2186,7 @@ class ApiTest extends DatabaseTest
                        ['id' => 2, 'screen_name' => 'recipient_name'],
                        ['id' => 3, 'screen_name' => 'sender_name']
                );
-               $this->assertEquals('item_title'."\n".'item_body', $result['text']);
+               $this->assertEquals('item_title' . "\n" . 'item_body', $result['text']);
                $this->assertEquals(1, $result['id']);
                $this->assertEquals(2, $result['recipient_id']);
                $this->assertEquals(3, $result['sender_id']);
@@ -2040,12 +2196,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_messages() function with HTML.
+        *
         * @return void
         */
        public function testApiFormatMessagesWithHtmlText()
        {
                $_GET['getText'] = 'html';
-               $result = api_format_messages(
+               $result          = api_format_messages(
                        ['id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
                        ['id' => 2, 'screen_name' => 'recipient_name'],
                        ['id' => 3, 'screen_name' => 'sender_name']
@@ -2056,12 +2213,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_messages() function with plain text.
+        *
         * @return void
         */
        public function testApiFormatMessagesWithPlainText()
        {
                $_GET['getText'] = 'plain';
-               $result = api_format_messages(
+               $result          = api_format_messages(
                        ['id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
                        ['id' => 2, 'screen_name' => 'recipient_name'],
                        ['id' => 3, 'screen_name' => 'sender_name']
@@ -2072,12 +2230,13 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_messages() function with the getUserObjects GET parameter set to false.
+        *
         * @return void
         */
        public function testApiFormatMessagesWithoutUserObjects()
        {
                $_GET['getUserObjects'] = 'false';
-               $result = api_format_messages(
+               $result                 = api_format_messages(
                        ['id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
                        ['id' => 2, 'screen_name' => 'recipient_name'],
                        ['id' => 3, 'screen_name' => 'sender_name']
@@ -2088,6 +2247,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_convert_item() function.
+        *
         * @return void
         */
        public function testApiConvertItem()
@@ -2095,32 +2255,32 @@ class ApiTest extends DatabaseTest
                $result = api_convert_item(
                        [
                                'network' => 'feed',
-                               'title' => 'item_title',
+                               'title'   => 'item_title',
                                // We need a long string to test that it is correctly cut
-                               'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui '.
-                               'reiciendis dolorum aut ducimus sunt consequatur inventore dolor '.
-                               'officiis pariatur doloremque nemo culpa aut quidem qui dolore '.
-                               'laudantium atque commodi alias voluptatem non possimus aperiam '.
-                               'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium '.
-                               'repellendus quibusdam et et inventore mollitia rerum sit autem '.
-                               'pariatur maiores ipsum accusantium perferendis vel sit possimus '.
-                               'veritatis nihil distinctio qui eum repellat officia illum quos '.
-                               'impedit quam iste esse unde qui suscipit aut facilis ut inventore '.
-                               'omnis exercitationem quo magnam consequatur maxime aut illum '.
-                               'soluta quaerat natus unde aspernatur et sed beatae nihil ullam '.
-                               'temporibus corporis ratione blanditiis perspiciatis impedit '.
-                               'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus '.
-                               'sunt consequatur inventore dolor officiis pariatur doloremque '.
-                               'nemo culpa aut quidem qui dolore laudantium atque commodi alias '.
-                               'voluptatem non possimus aperiam ipsum rerum consequuntur aut '.
-                               'amet fugit quia aliquid praesentium repellendus quibusdam et et '.
-                               'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium '.
-                               'perferendis vel sit possimus veritatis nihil distinctio qui eum '.
-                               'repellat officia illum quos impedit quam iste esse unde qui '.
-                               'suscipit aut facilis ut inventore omnis exercitationem quo magnam '.
-                               'consequatur maxime aut illum soluta quaerat natus unde aspernatur '.
-                               'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
-                               'plink' => 'item_plink'
+                               'body'    => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
+                                            'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
+                                            'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
+                                            'laudantium atque commodi alias voluptatem non possimus aperiam ' .
+                                            'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
+                                            'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
+                                            'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
+                                            'veritatis nihil distinctio qui eum repellat officia illum quos ' .
+                                            'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
+                                            'omnis exercitationem quo magnam consequatur maxime aut illum ' .
+                                            'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
+                                            'temporibus corporis ratione blanditiis perspiciatis impedit ' .
+                                            'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
+                                            'sunt consequatur inventore dolor officiis pariatur doloremque ' .
+                                            'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
+                                            'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
+                                            'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
+                                            'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
+                                            'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
+                                            'repellat officia illum quos impedit quam iste esse unde qui ' .
+                                            'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
+                                            'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
+                                            'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
+                               'plink'   => 'item_plink'
                        ]
                );
                $this->assertStringStartsWith('item_title', $result['text']);
@@ -2129,6 +2289,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_convert_item() function with an empty item body.
+        *
         * @return void
         */
        public function testApiConvertItemWithoutBody()
@@ -2136,9 +2297,9 @@ class ApiTest extends DatabaseTest
                $result = api_convert_item(
                        [
                                'network' => 'feed',
-                               'title' => 'item_title',
-                               'body' => '',
-                               'plink' => 'item_plink'
+                               'title'   => 'item_title',
+                               'body'    => '',
+                               'plink'   => 'item_plink'
                        ]
                );
                $this->assertEquals('item_title', $result['text']);
@@ -2147,6 +2308,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_convert_item() function with the title in the body.
+        *
         * @return void
         */
        public function testApiConvertItemWithTitleInBody()
@@ -2154,7 +2316,7 @@ class ApiTest extends DatabaseTest
                $result = api_convert_item(
                        [
                                'title' => 'item_title',
-                               'body' => 'item_title item_body'
+                               'body'  => 'item_title item_body'
                        ]
                );
                $this->assertEquals('item_title item_body', $result['text']);
@@ -2163,6 +2325,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_attachments() function.
+        *
         * @return void
         */
        public function testApiGetAttachments()
@@ -2173,6 +2336,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_attachments() function with an img tag.
+        *
         * @return void
         */
        public function testApiGetAttachmentsWithImage()
@@ -2183,17 +2347,19 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_attachments() function with an img tag and an AndStatus user agent.
+        *
         * @return void
         */
        public function testApiGetAttachmentsWithImageAndAndStatus()
        {
                $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
-               $body = '[img]http://via.placeholder.com/1x1.png[/img]';
+               $body                       = '[img]http://via.placeholder.com/1x1.png[/img]';
                $this->assertInternalType('array', api_get_attachments($body));
        }
 
        /**
         * Test the api_get_entitities() function.
+        *
         * @return void
         */
        public function testApiGetEntitities()
@@ -2204,13 +2370,14 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_get_entitities() function with the include_entities parameter.
+        *
         * @return void
         */
        public function testApiGetEntititiesWithIncludeEntities()
        {
                $_REQUEST['include_entities'] = 'true';
-               $text = 'text';
-               $result = api_get_entitities($text, 'bbcode');
+               $text                         = 'text';
+               $result                       = api_get_entitities($text, 'bbcode');
                $this->assertInternalType('array', $result['hashtags']);
                $this->assertInternalType('array', $result['symbols']);
                $this->assertInternalType('array', $result['urls']);
@@ -2219,6 +2386,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_items_embeded_images() function.
+        *
         * @return void
         */
        public function testApiFormatItemsEmbededImages()
@@ -2231,6 +2399,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_contactlink_to_array() function.
+        *
         * @return void
         */
        public function testApiContactlinkToArray()
@@ -2238,7 +2407,7 @@ class ApiTest extends DatabaseTest
                $this->assertEquals(
                        [
                                'name' => 'text',
-                               'url' => '',
+                               'url'  => '',
                        ],
                        api_contactlink_to_array('text')
                );
@@ -2246,6 +2415,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_contactlink_to_array() function with an URL.
+        *
         * @return void
         */
        public function testApiContactlinkToArrayWithUrl()
@@ -2253,7 +2423,7 @@ class ApiTest extends DatabaseTest
                $this->assertEquals(
                        [
                                'name' => ['link_text'],
-                               'url' => ['url'],
+                               'url'  => ['url'],
                        ],
                        api_contactlink_to_array('text <a href="url">link_text</a>')
                );
@@ -2261,11 +2431,12 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_items_activities() function.
+        *
         * @return void
         */
        public function testApiFormatItemsActivities()
        {
-               $item = ['uid' => 0, 'uri' => ''];
+               $item   = ['uid' => 0, 'uri' => ''];
                $result = api_format_items_activities($item);
                $this->assertArrayHasKey('like', $result);
                $this->assertArrayHasKey('dislike', $result);
@@ -2276,11 +2447,12 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_items_activities() function with an XML result.
+        *
         * @return void
         */
        public function testApiFormatItemsActivitiesWithXml()
        {
-               $item = ['uid' => 0, 'uri' => ''];
+               $item   = ['uid' => 0, 'uri' => ''];
                $result = api_format_items_activities($item, 'xml');
                $this->assertArrayHasKey('friendica:like', $result);
                $this->assertArrayHasKey('friendica:dislike', $result);
@@ -2291,94 +2463,95 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_items_profiles() function.
+        *
         * @return void
         */
        public function testApiFormatItemsProfiles()
        {
                $profile_row = [
-                       'id' => 'profile_id',
+                       'id'           => 'profile_id',
                        'profile-name' => 'profile_name',
-                       'is-default' => true,
+                       'is-default'   => true,
                        'hide-friends' => true,
-                       'photo' => 'profile_photo',
-                       'thumb' => 'profile_thumb',
-                       'publish' => true,
-                       'net-publish' => true,
-                       'pdesc' => 'description',
-                       'dob' => 'date_of_birth',
-                       'address' => 'address',
-                       'locality' => 'city',
-                       'region' => 'region',
-                       'postal-code' => 'postal_code',
+                       'photo'        => 'profile_photo',
+                       'thumb'        => 'profile_thumb',
+                       'publish'      => true,
+                       'net-publish'  => true,
+                       'pdesc'        => 'description',
+                       'dob'          => 'date_of_birth',
+                       'address'      => 'address',
+                       'locality'     => 'city',
+                       'region'       => 'region',
+                       'postal-code'  => 'postal_code',
                        'country-name' => 'country',
-                       'hometown' => 'hometown',
-                       'gender' => 'gender',
-                       'marital' => 'marital',
-                       'with' => 'marital_with',
-                       'howlong' => 'marital_since',
-                       'sexual' => 'sexual',
-                       'politic' => 'politic',
-                       'religion' => 'religion',
+                       'hometown'     => 'hometown',
+                       'gender'       => 'gender',
+                       'marital'      => 'marital',
+                       'with'         => 'marital_with',
+                       'howlong'      => 'marital_since',
+                       'sexual'       => 'sexual',
+                       'politic'      => 'politic',
+                       'religion'     => 'religion',
                        'pub_keywords' => 'public_keywords',
                        'prv_keywords' => 'private_keywords',
 
-                       'likes' => 'likes',
-                       'dislikes' => 'dislikes',
-                       'about' => 'about',
-                       'music' => 'music',
-                       'book' => 'book',
-                       'tv' => 'tv',
-                       'film' => 'film',
-                       'interest' => 'interest',
-                       'romance' => 'romance',
-                       'work' => 'work',
+                       'likes'     => 'likes',
+                       'dislikes'  => 'dislikes',
+                       'about'     => 'about',
+                       'music'     => 'music',
+                       'book'      => 'book',
+                       'tv'        => 'tv',
+                       'film'      => 'film',
+                       'interest'  => 'interest',
+                       'romance'   => 'romance',
+                       'work'      => 'work',
                        'education' => 'education',
-                       'contact' => 'social_networks',
-                       'homepage' => 'homepage'
+                       'contact'   => 'social_networks',
+                       'homepage'  => 'homepage'
                ];
-               $result = api_format_items_profiles($profile_row);
+               $result      = api_format_items_profiles($profile_row);
                $this->assertEquals(
                        [
-                               'profile_id' => 'profile_id',
-                               'profile_name' => 'profile_name',
-                               'is_default' => true,
-                               'hide_friends' => true,
-                               'profile_photo' => 'profile_photo',
-                               'profile_thumb' => 'profile_thumb',
-                               'publish' => true,
-                               'net_publish' => true,
-                               'description' => 'description',
-                               'date_of_birth' => 'date_of_birth',
-                               'address' => 'address',
-                               'city' => 'city',
-                               'region' => 'region',
-                               'postal_code' => 'postal_code',
-                               'country' => 'country',
-                               'hometown' => 'hometown',
-                               'gender' => 'gender',
-                               'marital' => 'marital',
-                               'marital_with' => 'marital_with',
-                               'marital_since' => 'marital_since',
-                               'sexual' => 'sexual',
-                               'politic' => 'politic',
-                               'religion' => 'religion',
-                               'public_keywords' => 'public_keywords',
+                               'profile_id'       => 'profile_id',
+                               'profile_name'     => 'profile_name',
+                               'is_default'       => true,
+                               'hide_friends'     => true,
+                               'profile_photo'    => 'profile_photo',
+                               'profile_thumb'    => 'profile_thumb',
+                               'publish'          => true,
+                               'net_publish'      => true,
+                               'description'      => 'description',
+                               'date_of_birth'    => 'date_of_birth',
+                               'address'          => 'address',
+                               'city'             => 'city',
+                               'region'           => 'region',
+                               'postal_code'      => 'postal_code',
+                               'country'          => 'country',
+                               'hometown'         => 'hometown',
+                               'gender'           => 'gender',
+                               'marital'          => 'marital',
+                               'marital_with'     => 'marital_with',
+                               'marital_since'    => 'marital_since',
+                               'sexual'           => 'sexual',
+                               'politic'          => 'politic',
+                               'religion'         => 'religion',
+                               'public_keywords'  => 'public_keywords',
                                'private_keywords' => 'private_keywords',
 
-                               'likes' => 'likes',
-                               'dislikes' => 'dislikes',
-                               'about' => 'about',
-                               'music' => 'music',
-                               'book' => 'book',
-                               'tv' => 'tv',
-                               'film' => 'film',
-                               'interest' => 'interest',
-                               'romance' => 'romance',
-                               'work' => 'work',
-                               'education' => 'education',
+                               'likes'           => 'likes',
+                               'dislikes'        => 'dislikes',
+                               'about'           => 'about',
+                               'music'           => 'music',
+                               'book'            => 'book',
+                               'tv'              => 'tv',
+                               'film'            => 'film',
+                               'interest'        => 'interest',
+                               'romance'         => 'romance',
+                               'work'            => 'work',
+                               'education'       => 'education',
                                'social_networks' => 'social_networks',
-                               'homepage' => 'homepage',
-                               'users' => null
+                               'homepage'        => 'homepage',
+                               'users'           => null
                        ],
                        $result
                );
@@ -2386,21 +2559,22 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_items() function.
+        *
         * @return void
         */
        public function testApiFormatItems()
        {
-               $items = [
+               $items  = [
                        [
-                               'item_network' => 'item_network',
-                               'source' => 'web',
-                               'coord' => '5 7',
-                               'body' => '',
-                               'verb' => '',
-                               'author-id' => 43,
+                               'item_network'   => 'item_network',
+                               'source'         => 'web',
+                               'coord'          => '5 7',
+                               'body'           => '',
+                               'verb'           => '',
+                               'author-id'      => 43,
                                'author-network' => Protocol::DFRN,
-                               'author-link' => 'http://localhost/profile/othercontact',
-                               'plink' => '',
+                               'author-link'    => 'http://localhost/profile/othercontact',
+                               'plink'          => '',
                        ]
                ];
                $result = api_format_items($items, ['id' => 0], true);
@@ -2411,19 +2585,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_items() function with an XML result.
+        *
         * @return void
         */
        public function testApiFormatItemsWithXml()
        {
-               $items = [
+               $items  = [
                        [
-                               'coord' => '5 7',
-                               'body' => '',
-                               'verb' => '',
-                               'author-id' => 43,
+                               'coord'          => '5 7',
+                               'body'           => '',
+                               'verb'           => '',
+                               'author-id'      => 43,
                                'author-network' => Protocol::DFRN,
-                               'author-link' => 'http://localhost/profile/othercontact',
-                               'plink' => '',
+                               'author-link'    => 'http://localhost/profile/othercontact',
+                               'plink'          => '',
                        ]
                ];
                $result = api_format_items($items, ['id' => 0], true, 'xml');
@@ -2434,6 +2609,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_items() function.
+        *
         * @return void
         */
        public function testApiAccountRateLimitStatus()
@@ -2446,6 +2622,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_format_items() function with an XML result.
+        *
         * @return void
         */
        public function testApiAccountRateLimitStatusWithXml()
@@ -2456,6 +2633,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_help_test() function.
+        *
         * @return void
         */
        public function testApiHelpTest()
@@ -2466,6 +2644,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_help_test() function with an XML result.
+        *
         * @return void
         */
        public function testApiHelpTestWithXml()
@@ -2476,6 +2655,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_list() function.
+        *
         * @return void
         */
        public function testApiListsList()
@@ -2486,6 +2666,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_ownerships() function.
+        *
         * @return void
         */
        public function testApiListsOwnerships()
@@ -2498,6 +2679,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_ownerships() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -2509,6 +2691,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_statuses() function.
+        *
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         * @return void
         */
@@ -2519,14 +2702,15 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_statuses() function with a list ID.
+        *
         * @return void
         */
        public function testApiListsStatusesWithListId()
        {
                $_REQUEST['list_id'] = 1;
-               $_REQUEST['page'] = -1;
-               $_REQUEST['max_id'] = 10;
-               $result = api_lists_statuses('json');
+               $_REQUEST['page']    = -1;
+               $_REQUEST['max_id']  = 10;
+               $result              = api_lists_statuses('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
                }
@@ -2534,40 +2718,44 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_statuses() function with a list ID and a RSS result.
+        *
         * @return void
         */
        public function testApiListsStatusesWithListIdAndRss()
        {
                $_REQUEST['list_id'] = 1;
-               $result = api_lists_statuses('rss');
+               $result              = api_lists_statuses('rss');
                $this->assertXml($result, 'statuses');
        }
 
        /**
         * Test the api_lists_statuses() function with an unallowed user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiListsStatusesWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_lists_statuses('json');
        }
 
        /**
         * Test the api_statuses_f() function.
+        *
         * @return void
         */
        public function testApiStatusesFWithFriends()
        {
                $_GET['page'] = -1;
-               $result = api_statuses_f('friends');
+               $result       = api_statuses_f('friends');
                $this->assertArrayHasKey('user', $result);
        }
 
        /**
         * Test the api_statuses_f() function.
+        *
         * @return void
         */
        public function testApiStatusesFWithFollowers()
@@ -2578,6 +2766,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_f() function.
+        *
         * @return void
         */
        public function testApiStatusesFWithBlocks()
@@ -2588,6 +2777,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_f() function.
+        *
         * @return void
         */
        public function testApiStatusesFWithIncoming()
@@ -2598,6 +2788,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_f() function an undefined cursor GET variable.
+        *
         * @return void
         */
        public function testApiStatusesFWithUndefinedCursor()
@@ -2608,6 +2799,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_friends() function.
+        *
         * @return void
         */
        public function testApiStatusesFriends()
@@ -2618,6 +2810,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_friends() function an undefined cursor GET variable.
+        *
         * @return void
         */
        public function testApiStatusesFriendsWithUndefinedCursor()
@@ -2628,6 +2821,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_followers() function.
+        *
         * @return void
         */
        public function testApiStatusesFollowers()
@@ -2638,6 +2832,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statuses_followers() function an undefined cursor GET variable.
+        *
         * @return void
         */
        public function testApiStatusesFollowersWithUndefinedCursor()
@@ -2648,6 +2843,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_blocks_list() function.
+        *
         * @return void
         */
        public function testApiBlocksList()
@@ -2658,6 +2854,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_blocks_list() function an undefined cursor GET variable.
+        *
         * @return void
         */
        public function testApiBlocksListWithUndefinedCursor()
@@ -2668,6 +2865,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendships_incoming() function.
+        *
         * @return void
         */
        public function testApiFriendshipsIncoming()
@@ -2678,6 +2876,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendships_incoming() function an undefined cursor GET variable.
+        *
         * @return void
         */
        public function testApiFriendshipsIncomingWithUndefinedCursor()
@@ -2688,6 +2887,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statusnet_config() function.
+        *
         * @return void
         */
        public function testApiStatusnetConfig()
@@ -2707,6 +2907,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_statusnet_version() function.
+        *
         * @return void
         */
        public function testApiStatusnetVersion()
@@ -2717,16 +2918,18 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_ff_ids() function.
+        *
         * @return void
         */
        public function testApiFfIds()
        {
-               $result = api_ff_ids('json');
-               $this->assertNull($result);
+               $result = api_ff_ids('json', Contact::FOLLOWER);
+               $this->assertEquals(['id' => []], $result);
        }
 
        /**
         * Test the api_ff_ids() function with a result.
+        *
         * @return void
         */
        public function testApiFfIdsWithResult()
@@ -2736,37 +2939,41 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_ff_ids() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFfIdsWithoutAuthenticatedUser()
        {
                $_SESSION['authenticated'] = false;
-               api_ff_ids('json');
+               api_ff_ids('json', Contact::FOLLOWER);
        }
 
        /**
         * Test the api_friends_ids() function.
+        *
         * @return void
         */
        public function testApiFriendsIds()
        {
                $result = api_friends_ids('json');
-               $this->assertNull($result);
+               $this->assertEquals(['id' => []], $result);
        }
 
        /**
         * Test the api_followers_ids() function.
+        *
         * @return void
         */
        public function testApiFollowersIds()
        {
                $result = api_followers_ids('json');
-               $this->assertNull($result);
+               $this->assertEquals(['id' => []], $result);
        }
 
        /**
         * Test the api_direct_messages_new() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesNew()
@@ -2777,6 +2984,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_new() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -2788,26 +2996,27 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_new() function with an user ID.
+        *
         * @return void
         */
        public function testApiDirectMessagesNewWithUserId()
        {
-               $_POST['text'] = 'message_text';
+               $_POST['text']    = 'message_text';
                $_POST['user_id'] = $this->otherUser['id'];
-               $result = api_direct_messages_new('json');
+               $result           = api_direct_messages_new('json');
                $this->assertEquals(['direct_message' => ['error' => -1]], $result);
        }
 
        /**
         * Test the api_direct_messages_new() function with a screen name.
+        *
         * @return void
         */
        public function testApiDirectMessagesNewWithScreenName()
        {
-               $_POST['text'] = 'message_text';
+               $_POST['text']        = 'message_text';
                $_POST['screen_name'] = $this->friendUser['nick'];
-               $result = api_direct_messages_new('json');
-               $this->assertEquals(1, $result['direct_message']['id']);
+               $result               = api_direct_messages_new('json');
                $this->assertContains('message_text', $result['direct_message']['text']);
                $this->assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
                $this->assertEquals(1, $result['direct_message']['friendica_seen']);
@@ -2815,15 +3024,15 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_new() function with a title.
+        *
         * @return void
         */
        public function testApiDirectMessagesNewWithTitle()
        {
-               $_POST['text'] = 'message_text';
+               $_POST['text']        = 'message_text';
                $_POST['screen_name'] = $this->friendUser['nick'];
-               $_REQUEST['title'] = 'message_title';
-               $result = api_direct_messages_new('json');
-               $this->assertEquals(1, $result['direct_message']['id']);
+               $_REQUEST['title']    = 'message_title';
+               $result               = api_direct_messages_new('json');
                $this->assertContains('message_text', $result['direct_message']['text']);
                $this->assertContains('message_title', $result['direct_message']['text']);
                $this->assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
@@ -2832,18 +3041,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_new() function with an RSS result.
+        *
         * @return void
         */
        public function testApiDirectMessagesNewWithRss()
        {
-               $_POST['text'] = 'message_text';
+               $_POST['text']        = 'message_text';
                $_POST['screen_name'] = $this->friendUser['nick'];
-               $result = api_direct_messages_new('rss');
+               $result               = api_direct_messages_new('rss');
                $this->assertXml($result, 'direct-messages');
        }
 
        /**
         * Test the api_direct_messages_destroy() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -2854,16 +3065,17 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_destroy() function with the friendica_verbose GET param.
+        *
         * @return void
         */
        public function testApiDirectMessagesDestroyWithVerbose()
        {
                $_GET['friendica_verbose'] = 'true';
-               $result = api_direct_messages_destroy('json');
+               $result                    = api_direct_messages_destroy('json');
                $this->assertEquals(
                        [
                                '$result' => [
-                                       'result' => 'error',
+                                       'result'  => 'error',
                                        'message' => 'message id or parenturi not specified'
                                ]
                        ],
@@ -2873,6 +3085,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_destroy() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -2884,6 +3097,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_destroy() function with a non-zero ID.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -2895,18 +3109,19 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_destroy() with a non-zero ID and the friendica_verbose GET param.
+        *
         * @return void
         */
        public function testApiDirectMessagesDestroyWithIdAndVerbose()
        {
-               $_REQUEST['id'] = 1;
+               $_REQUEST['id']                  = 1;
                $_REQUEST['friendica_parenturi'] = 'parent_uri';
-               $_GET['friendica_verbose'] = 'true';
-               $result = api_direct_messages_destroy('json');
+               $_GET['friendica_verbose']       = 'true';
+               $result                          = api_direct_messages_destroy('json');
                $this->assertEquals(
                        [
                                '$result' => [
-                                       'result' => 'error',
+                                       'result'  => 'error',
                                        'message' => 'message id not in database'
                                ]
                        ],
@@ -2916,6 +3131,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_destroy() function with a non-zero ID.
+        *
         * @return void
         */
        public function testApiDirectMessagesDestroyWithCorrectId()
@@ -2925,18 +3141,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_box() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesBoxWithSentbox()
        {
-               $_REQUEST['page'] = -1;
+               $_REQUEST['page']   = -1;
                $_REQUEST['max_id'] = 10;
-               $result = api_direct_messages_box('json', 'sentbox', 'false');
+               $result             = api_direct_messages_box('json', 'sentbox', 'false');
                $this->assertArrayHasKey('direct_message', $result);
        }
 
        /**
         * Test the api_direct_messages_box() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesBoxWithConversation()
@@ -2947,6 +3165,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_box() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesBoxWithAll()
@@ -2957,6 +3176,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_box() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesBoxWithInbox()
@@ -2967,6 +3187,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_box() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesBoxWithVerbose()
@@ -2975,7 +3196,7 @@ class ApiTest extends DatabaseTest
                $this->assertEquals(
                        [
                                '$result' => [
-                                       'result' => 'error',
+                                       'result'  => 'error',
                                        'message' => 'no mails available'
                                ]
                        ],
@@ -2985,6 +3206,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_box() function with a RSS result.
+        *
         * @return void
         */
        public function testApiDirectMessagesBoxWithRss()
@@ -2995,18 +3217,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_box() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiDirectMessagesBoxWithUnallowedUser()
        {
                $_SESSION['allow_api'] = false;
-               $_GET['screen_name'] = $this->selfUser['nick'];
+               $_GET['screen_name']   = $this->selfUser['nick'];
                api_direct_messages_box('json', 'sentbox', 'false');
        }
 
        /**
         * Test the api_direct_messages_sentbox() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesSentbox()
@@ -3017,6 +3241,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_inbox() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesInbox()
@@ -3027,6 +3252,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_all() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesAll()
@@ -3037,6 +3263,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_direct_messages_conversation() function.
+        *
         * @return void
         */
        public function testApiDirectMessagesConversation()
@@ -3047,6 +3274,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_oauth_request_token() function.
+        *
         * @return void
         */
        public function testApiOauthRequestToken()
@@ -3056,6 +3284,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_oauth_access_token() function.
+        *
         * @return void
         */
        public function testApiOauthAccessToken()
@@ -3065,6 +3294,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photoalbum_delete() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3075,6 +3305,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photoalbum_delete() function with an album name.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3086,6 +3317,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photoalbum_delete() function with an album name.
+        *
         * @return void
         */
        public function testApiFrPhotoalbumDeleteWithValidAlbum()
@@ -3095,6 +3327,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photoalbum_delete() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3105,6 +3338,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photoalbum_delete() function with an album name.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3116,18 +3350,20 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photoalbum_delete() function with an album name.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoalbumUpdateWithAlbumAndNewAlbum()
        {
-               $_REQUEST['album'] = 'album_name';
+               $_REQUEST['album']     = 'album_name';
                $_REQUEST['album_new'] = 'album_name';
                api_fr_photoalbum_update('json');
        }
 
        /**
         * Test the api_fr_photoalbum_update() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -3139,6 +3375,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photoalbum_delete() function with an album name.
+        *
         * @return void
         */
        public function testApiFrPhotoalbumUpdateWithValidAlbum()
@@ -3148,6 +3385,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photos_list() function.
+        *
         * @return void
         */
        public function testApiFrPhotosList()
@@ -3158,6 +3396,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photos_list() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -3169,6 +3408,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_create_update() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3179,6 +3419,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_create_update() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -3190,6 +3431,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_create_update() function with an album name.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3201,6 +3443,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_create_update() function with the update mode.
+        *
         * @return void
         */
        public function testApiFrPhotoCreateUpdateWithUpdate()
@@ -3210,6 +3453,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_create_update() function with an uploaded file.
+        *
         * @return void
         */
        public function testApiFrPhotoCreateUpdateWithFile()
@@ -3219,6 +3463,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_delete() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3229,6 +3474,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_delete() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -3240,6 +3486,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_delete() function with a photo ID.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3251,6 +3498,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_delete() function with a correct photo ID.
+        *
         * @return void
         */
        public function testApiFrPhotoDeleteWithCorrectPhotoId()
@@ -3260,6 +3508,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_detail() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3270,6 +3519,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_detail() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -3281,6 +3531,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_detail() function with a photo ID.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\NotFoundException
         */
@@ -3292,6 +3543,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_fr_photo_detail() function with a correct photo ID.
+        *
         * @return void
         */
        public function testApiFrPhotoDetailCorrectPhotoId()
@@ -3301,6 +3553,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_account_update_profile_image() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3311,6 +3564,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_account_update_profile_image() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -3322,6 +3576,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_account_update_profile_image() function with an uploaded file.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3333,13 +3588,14 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_account_update_profile() function.
+        *
         * @return void
         */
        public function testApiAccountUpdateProfile()
        {
-               $_POST['name'] = 'new_name';
+               $_POST['name']        = 'new_name';
                $_POST['description'] = 'new_description';
-               $result = api_account_update_profile('json');
+               $result               = api_account_update_profile('json');
                // We can't use assertSelfUser() here because the user object is missing some properties.
                $this->assertEquals($this->selfUser['id'], $result['user']['cid']);
                $this->assertEquals('DFRN', $result['user']['location']);
@@ -3351,6 +3607,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the check_acl_input() function.
+        *
         * @return void
         */
        public function testCheckAclInput()
@@ -3362,6 +3619,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the check_acl_input() function with an empty ACL string.
+        *
         * @return void
         */
        public function testCheckAclInputWithEmptyAclString()
@@ -3372,6 +3630,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the save_media_to_database() function.
+        *
         * @return void
         */
        public function testSaveMediaToDatabase()
@@ -3381,6 +3640,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the post_photo_item() function.
+        *
         * @return void
         */
        public function testPostPhotoItem()
@@ -3390,6 +3650,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the prepare_photo_data() function.
+        *
         * @return void
         */
        public function testPreparePhotoData()
@@ -3399,6 +3660,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_remoteauth() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3409,41 +3671,45 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_remoteauth() function with an URL.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFriendicaRemoteauthWithUrl()
        {
-               $_GET['url'] = 'url';
+               $_GET['url']   = 'url';
                $_GET['c_url'] = 'url';
                api_friendica_remoteauth();
        }
 
        /**
         * Test the api_friendica_remoteauth() function with a correct URL.
+        *
         * @return void
         */
        public function testApiFriendicaRemoteauthWithCorrectUrl()
        {
                $this->markTestIncomplete("We can't use an assertion here because of App->redirect().");
-               $_GET['url'] = 'url';
+               $_GET['url']   = 'url';
                $_GET['c_url'] = $this->selfUser['nurl'];
                api_friendica_remoteauth();
        }
 
        /**
         * Test the api_share_as_retweet() function.
+        *
         * @return void
         */
        public function testApiShareAsRetweet()
        {
-               $item = ['body' => '', 'author-id' => 1, 'owner-id' => 1];
+               $item   = ['body' => '', 'author-id' => 1, 'owner-id' => 1];
                $result = api_share_as_retweet($item);
                $this->assertFalse($result);
        }
 
        /**
         * Test the api_share_as_retweet() function with a valid item.
+        *
         * @return void
         */
        public function testApiShareAsRetweetWithValidItem()
@@ -3451,28 +3717,9 @@ 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.
+        *
         * @return void
         */
        public function testApiInReplyTo()
@@ -3487,6 +3734,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_in_reply_to() function with a valid item.
+        *
         * @return void
         */
        public function testApiInReplyToWithValidItem()
@@ -3496,37 +3744,31 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_clean_plain_items() function.
+        *
         * @return void
         */
        public function testApiCleanPlainItems()
        {
                $_REQUEST['include_entities'] = 'true';
-               $result = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
+               $result                       = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
                $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.
+        *
         * @return void
         */
        public function testApiBestNickname()
        {
                $contacts = [];
-               $result = api_best_nickname($contacts);
+               $result   = api_best_nickname($contacts);
                $this->assertNull($result);
        }
 
        /**
         * Test the api_best_nickname() function with contacts.
+        *
         * @return void
         */
        public function testApiBestNicknameWithContacts()
@@ -3536,6 +3778,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_group_show() function.
+        *
         * @return void
         */
        public function testApiFriendicaGroupShow()
@@ -3545,6 +3788,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_group_delete() function.
+        *
         * @return void
         */
        public function testApiFriendicaGroupDelete()
@@ -3554,6 +3798,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_destroy() function.
+        *
         * @return void
         */
        public function testApiListsDestroy()
@@ -3563,6 +3808,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the group_create() function.
+        *
         * @return void
         */
        public function testGroupCreate()
@@ -3572,6 +3818,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_group_create() function.
+        *
         * @return void
         */
        public function testApiFriendicaGroupCreate()
@@ -3581,6 +3828,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_create() function.
+        *
         * @return void
         */
        public function testApiListsCreate()
@@ -3590,6 +3838,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_group_update() function.
+        *
         * @return void
         */
        public function testApiFriendicaGroupUpdate()
@@ -3599,6 +3848,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_lists_update() function.
+        *
         * @return void
         */
        public function testApiListsUpdate()
@@ -3608,6 +3858,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_activity() function.
+        *
         * @return void
         */
        public function testApiFriendicaActivity()
@@ -3617,6 +3868,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_notification() function.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3627,6 +3879,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_notification() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -3638,30 +3891,33 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_notification() function with an argument count.
+        *
         * @return void
         */
        public function testApiFriendicaNotificationWithArgumentCount()
        {
                $this->app->argv = ['api', 'friendica', 'notification'];
                $this->app->argc = count($this->app->argv);
-               $result = api_friendica_notification('json');
+               $result          = api_friendica_notification('json');
                $this->assertEquals(['note' => false], $result);
        }
 
        /**
         * Test the api_friendica_notification() function with an XML result.
+        *
         * @return void
         */
        public function testApiFriendicaNotificationWithXmlResult()
        {
                $this->app->argv = ['api', 'friendica', 'notification'];
                $this->app->argc = count($this->app->argv);
-               $result = api_friendica_notification('xml');
+               $result          = api_friendica_notification('xml');
                $this->assertXml($result, 'notes');
        }
 
        /**
         * Test the api_friendica_notification_seen() function.
+        *
         * @return void
         */
        public function testApiFriendicaNotificationSeen()
@@ -3671,6 +3927,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_direct_messages_setseen() function.
+        *
         * @return void
         */
        public function testApiFriendicaDirectMessagesSetseen()
@@ -3680,6 +3937,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_direct_messages_search() function.
+        *
         * @return void
         */
        public function testApiFriendicaDirectMessagesSearch()
@@ -3689,6 +3947,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_profile_show() function.
+        *
         * @return void
         */
        public function testApiFriendicaProfileShow()
@@ -3706,6 +3965,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_profile_show() function with a profile ID.
+        *
         * @return void
         */
        public function testApiFriendicaProfileShowWithProfileId()
@@ -3715,6 +3975,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_profile_show() function with a wrong profile ID.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
@@ -3726,6 +3987,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_friendica_profile_show() function without an authenticated user.
+        *
         * @return void
         * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
@@ -3737,6 +3999,7 @@ class ApiTest extends DatabaseTest
 
        /**
         * Test the api_saved_searches_list() function.
+        *
         * @return void
         */
        public function testApiSavedSearchesList()