]> git.mxchange.org Git - friendica.git/blobdiff - tests/legacy/ApiTest.php
Merge pull request #10586 from annando/app-user2
[friendica.git] / tests / legacy / ApiTest.php
index 1ff66efb6a92a0b9450cf47f91570f54dea0b404..eaf596fb6ab4b711ec7382f6dd24687cf09021dd 100644 (file)
@@ -22,6 +22,8 @@ require_once __DIR__ . '/../../include/api.php';
  *
  * Functions that use header() need to be tested in a separate process.
  * @see https://phpunit.de/manual/5.7/en/appendixes.annotations.html#appendixes.annotations.runTestsInSeparateProcesses
+ *
+ * @backupGlobals enabled
  */
 class ApiTest extends FixtureTest
 {
@@ -48,7 +50,7 @@ class ApiTest extends FixtureTest
        /**
         * Create variables used by tests.
         */
-       protected function setUp()
+       protected function setUp() : void
        {
                global $API, $called_api;
                $API = [];
@@ -74,8 +76,7 @@ class ApiTest extends FixtureTest
                /** @var App app */
                $this->app = DI::app();
 
-               $this->app->argc = 1;
-               $this->app->argv = [''];
+               DI::args()->setArgc(1);
 
                // User data that the test database is populated with
                $this->selfUser   = [
@@ -108,10 +109,6 @@ class ApiTest extends FixtureTest
                        'authenticated' => true,
                        'uid'           => $this->selfUser['id']
                ];
-
-               $_POST   = [];
-               $_GET    = [];
-               $_SERVER = [];
        }
 
        /**
@@ -123,14 +120,14 @@ class ApiTest extends FixtureTest
         */
        private function assertSelfUser(array $user)
        {
-               $this->assertEquals($this->selfUser['id'], $user['uid']);
-               $this->assertEquals($this->selfUser['id'], $user['cid']);
-               $this->assertEquals(1, $user['self']);
-               $this->assertEquals('DFRN', $user['location']);
-               $this->assertEquals($this->selfUser['name'], $user['name']);
-               $this->assertEquals($this->selfUser['nick'], $user['screen_name']);
-               $this->assertEquals('dfrn', $user['network']);
-               $this->assertTrue($user['verified']);
+               self::assertEquals($this->selfUser['id'], $user['uid']);
+               self::assertEquals($this->selfUser['id'], $user['cid']);
+               self::assertEquals(1, $user['self']);
+               self::assertEquals('DFRN', $user['location']);
+               self::assertEquals($this->selfUser['name'], $user['name']);
+               self::assertEquals($this->selfUser['nick'], $user['screen_name']);
+               self::assertEquals('dfrn', $user['network']);
+               self::assertTrue($user['verified']);
        }
 
        /**
@@ -140,14 +137,14 @@ class ApiTest extends FixtureTest
         *
         * @return void
         */
-       private function assertOtherUser(array $user)
+       private function assertOtherUser(array $user = [])
        {
-               $this->assertEquals($this->otherUser['id'], $user['id']);
-               $this->assertEquals($this->otherUser['id'], $user['id_str']);
-               $this->assertEquals(0, $user['self']);
-               $this->assertEquals($this->otherUser['name'], $user['name']);
-               $this->assertEquals($this->otherUser['nick'], $user['screen_name']);
-               $this->assertFalse($user['verified']);
+               self::assertEquals($this->otherUser['id'], $user['id']);
+               self::assertEquals($this->otherUser['id'], $user['id_str']);
+               self::assertEquals(0, $user['self']);
+               self::assertEquals($this->otherUser['name'], $user['name']);
+               self::assertEquals($this->otherUser['nick'], $user['screen_name']);
+               self::assertFalse($user['verified']);
        }
 
        /**
@@ -157,10 +154,10 @@ class ApiTest extends FixtureTest
         *
         * @return void
         */
-       private function assertStatus(array $status)
+       private function assertStatus(array $status = [])
        {
-               $this->assertInternalType('string', $status['text']);
-               $this->assertInternalType('int', $status['id']);
+               self::assertIsString($status['text'] ?? '');
+               self::assertIsInt($status['id'] ?? '');
                // We could probably do more checks here.
        }
 
@@ -171,12 +168,12 @@ class ApiTest extends FixtureTest
         *
         * @return void
         */
-       private function assertList(array $list)
+       private function assertList(array $list = [])
        {
-               $this->assertInternalType('string', $list['name']);
-               $this->assertInternalType('int', $list['id']);
-               $this->assertInternalType('string', $list['id_str']);
-               $this->assertContains($list['mode'], ['public', 'private']);
+               self::assertIsString($list['name']);
+               self::assertIsInt($list['id']);
+               self::assertIsString('string', $list['id_str']);
+               self::assertContains($list['mode'], ['public', 'private']);
                // We could probably do more checks here.
        }
 
@@ -188,10 +185,10 @@ class ApiTest extends FixtureTest
         *
         * @return void
         */
-       private function assertXml($result, $root_element)
+       private function assertXml($result = '', $root_element = '')
        {
-               $this->assertStringStartsWith('<?xml version="1.0"?>', $result);
-               $this->assertContains('<' . $root_element, $result);
+               self::assertStringStartsWith('<?xml version="1.0"?>', $result);
+               self::assertStringContainsString('<' . $root_element, $result);
                // We could probably do more checks here.
        }
 
@@ -221,7 +218,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiUser()
        {
-               $this->assertEquals($this->selfUser['id'], api_user());
+               self::assertEquals($this->selfUser['id'], api_user());
        }
 
        /**
@@ -232,7 +229,7 @@ class ApiTest extends FixtureTest
        public function testApiUserWithUnallowedUser()
        {
                $_SESSION = ['allow_api' => false];
-               $this->assertEquals(false, api_user());
+               self::assertEquals(false, api_user());
        }
 
        /**
@@ -242,7 +239,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiSource()
        {
-               $this->assertEquals('api', api_source());
+               self::assertEquals('api', api_source());
        }
 
        /**
@@ -253,7 +250,7 @@ class ApiTest extends FixtureTest
        public function testApiSourceWithTwidere()
        {
                $_SERVER['HTTP_USER_AGENT'] = 'Twidere';
-               $this->assertEquals('Twidere', api_source());
+               self::assertEquals('Twidere', api_source());
        }
 
        /**
@@ -264,7 +261,7 @@ class ApiTest extends FixtureTest
        public function testApiSourceWithGet()
        {
                $_GET['source'] = 'source_name';
-               $this->assertEquals('source_name', api_source());
+               self::assertEquals('source_name', api_source());
        }
 
        /**
@@ -274,7 +271,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiDate()
        {
-               $this->assertEquals('Wed Oct 10 00:00:00 +0000 1990', api_date('1990-10-10'));
+               self::assertEquals('Wed Oct 10 00:00:00 +0000 1990', api_date('1990-10-10'));
        }
 
        /**
@@ -285,7 +282,7 @@ class ApiTest extends FixtureTest
        public function testApiRegisterFunc()
        {
                global $API;
-               $this->assertNull(
+               self::assertNull(
                        api_register_func(
                                'api_path',
                                function () {
@@ -294,32 +291,34 @@ class ApiTest extends FixtureTest
                                'method'
                        )
                );
-               $this->assertTrue($API['api_path']['auth']);
-               $this->assertEquals('method', $API['api_path']['method']);
-               $this->assertTrue(is_callable($API['api_path']['func']));
+               self::assertTrue($API['api_path']['auth']);
+               self::assertEquals('method', $API['api_path']['method']);
+               self::assertTrue(is_callable($API['api_path']['func']));
        }
 
        /**
         * Test the api_login() function without any login.
         *
-        * @return void
         * @runInSeparateProcess
-        * @expectedException Friendica\Network\HTTPException\UnauthorizedException
+        * @preserveGlobalState disabled
+        * @preserveGlobalState disabled
         */
        public function testApiLoginWithoutLogin()
        {
+               $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
                api_login($this->app);
        }
 
        /**
         * Test the api_login() function with a bad login.
         *
-        * @return void
         * @runInSeparateProcess
-        * @expectedException Friendica\Network\HTTPException\UnauthorizedException
+        * @preserveGlobalState disabled
+        * @preserveGlobalState disabled
         */
        public function testApiLoginWithBadLogin()
        {
+               $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
                $_SERVER['PHP_AUTH_USER'] = 'user@server';
                api_login($this->app);
        }
@@ -347,8 +346,9 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_login() function with a correct login.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
+        * @doesNotPerformAssertions
         */
        public function testApiLoginWithCorrectLogin()
        {
@@ -360,12 +360,12 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_login() function with a remote user.
         *
-        * @return void
         * @runInSeparateProcess
-        * @expectedException Friendica\Network\HTTPException\UnauthorizedException
+        * @preserveGlobalState disabled
         */
        public function testApiLoginWithRemoteUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
                $_SERVER['REDIRECT_REMOTE_USER'] = '123456dXNlcjpwYXNzd29yZA==';
                api_login($this->app);
        }
@@ -377,7 +377,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiCheckMethod()
        {
-               $this->assertFalse(api_check_method('method'));
+               self::assertFalse(api_check_method('method'));
        }
 
        /**
@@ -388,7 +388,7 @@ class ApiTest extends FixtureTest
        public function testApiCheckMethodWithCorrectMethod()
        {
                $_SERVER['REQUEST_METHOD'] = 'method';
-               $this->assertTrue(api_check_method('method'));
+               self::assertTrue(api_check_method('method'));
        }
 
        /**
@@ -398,14 +398,14 @@ class ApiTest extends FixtureTest
         */
        public function testApiCheckMethodWithWildcard()
        {
-               $this->assertTrue(api_check_method('*'));
+               self::assertTrue(api_check_method('*'));
        }
 
        /**
         * Test the api_call() function.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCall()
        {
@@ -422,7 +422,7 @@ class ApiTest extends FixtureTest
 
                $args = DI::args()->determine($_SERVER, $_GET);
 
-               $this->assertEquals(
+               self::assertEquals(
                        'callback_name(["some_data"])',
                        api_call($this->app, $args)
                );
@@ -431,8 +431,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with the profiled enabled.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithProfiler()
        {
@@ -459,7 +459,7 @@ class ApiTest extends FixtureTest
                        'network'        => ['some_function' => 200]
                ];
 
-               $this->assertEquals(
+               self::assertEquals(
                        '["some_data"]',
                        api_call($this->app, $args)
                );
@@ -468,8 +468,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function without any result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithNoResult()
        {
@@ -485,7 +485,7 @@ class ApiTest extends FixtureTest
 
                $args = DI::args()->determine($_SERVER, $_GET);
 
-               $this->assertEquals(
+               self::assertEquals(
                        '{"status":{"error":"Internal Server Error","code":"500 Internal Server Error","request":"api_path"}}',
                        api_call($this->app, $args)
                );
@@ -494,13 +494,13 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an unimplemented API.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithUninplementedApi()
        {
-               $this->assertEquals(
-                       '{"status":{"error":"Not Implemented","code":"501 Not Implemented","request":""}}',
+               self::assertEquals(
+                       '{"status":{"error":"Not Found","code":"404 Not Found","request":""}}',
                        api_call($this->app)
                );
        }
@@ -508,8 +508,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with a JSON result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithJson()
        {
@@ -525,7 +525,7 @@ class ApiTest extends FixtureTest
 
                $args = DI::args()->determine($_SERVER, $_GET);
 
-               $this->assertEquals(
+               self::assertEquals(
                        '["some_data"]',
                        api_call($this->app, $args)
                );
@@ -534,8 +534,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an XML result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithXml()
        {
@@ -551,7 +551,7 @@ class ApiTest extends FixtureTest
 
                $args = DI::args()->determine($_SERVER, $_GET);
 
-               $this->assertEquals(
+               self::assertEquals(
                        'some_data',
                        api_call($this->app, $args)
                );
@@ -560,8 +560,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an RSS result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithRss()
        {
@@ -577,7 +577,7 @@ class ApiTest extends FixtureTest
 
                $args = DI::args()->determine($_SERVER, $_GET);
 
-               $this->assertEquals(
+               self::assertEquals(
                        '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
                        'some_data',
                        api_call($this->app, $args)
@@ -587,8 +587,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an Atom result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithAtom()
        {
@@ -604,7 +604,7 @@ class ApiTest extends FixtureTest
 
                $args = DI::args()->determine($_SERVER, $_GET);
 
-               $this->assertEquals(
+               self::assertEquals(
                        '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
                        'some_data',
                        api_call($this->app, $args)
@@ -614,8 +614,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an unallowed method.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithWrongMethod()
        {
@@ -626,7 +626,7 @@ class ApiTest extends FixtureTest
 
                $args = DI::args()->determine($_SERVER, $_GET);
 
-               $this->assertEquals(
+               self::assertEquals(
                        '{"status":{"error":"Method Not Allowed","code":"405 Method Not Allowed","request":"api_path"}}',
                        api_call($this->app, $args)
                );
@@ -635,8 +635,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an unauthorized user.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithWrongAuth()
        {
@@ -651,7 +651,7 @@ class ApiTest extends FixtureTest
 
                $args = DI::args()->determine($_SERVER, $_GET);
 
-               $this->assertEquals(
+               self::assertEquals(
                        '{"status":{"error":"This API requires login","code":"401 Unauthorized","request":"api_path"}}',
                        api_call($this->app, $args)
                );
@@ -660,12 +660,12 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with a JSON result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithJson()
        {
-               $this->assertEquals(
+               self::assertEquals(
                        '{"status":{"error":"error_message","code":"200 OK","request":""}}',
                        api_error('json', new HTTPException\OKException('error_message'), DI::args())
                );
@@ -674,12 +674,12 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an XML result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithXml()
        {
-               $this->assertEquals(
+               self::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/" ' .
@@ -695,12 +695,12 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an RSS result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithRss()
        {
-               $this->assertEquals(
+               self::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/" ' .
@@ -716,12 +716,12 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an Atom result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithAtom()
        {
-               $this->assertEquals(
+               self::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/" ' .
@@ -743,14 +743,14 @@ class ApiTest extends FixtureTest
        {
                $user_info = ['url' => 'user_url', 'lang' => 'en'];
                $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']);
-               $this->assertArrayHasKey('base', $result['$rss']);
-               $this->assertArrayHasKey('updated', $result['$rss']);
-               $this->assertArrayHasKey('atom_updated', $result['$rss']);
-               $this->assertArrayHasKey('language', $result['$rss']);
-               $this->assertArrayHasKey('logo', $result['$rss']);
+               self::assertEquals($user_info, $result['$user']);
+               self::assertEquals($user_info['url'], $result['$rss']['alternate']);
+               self::assertArrayHasKey('self', $result['$rss']);
+               self::assertArrayHasKey('base', $result['$rss']);
+               self::assertArrayHasKey('updated', $result['$rss']);
+               self::assertArrayHasKey('atom_updated', $result['$rss']);
+               self::assertArrayHasKey('language', $result['$rss']);
+               self::assertArrayHasKey('logo', $result['$rss']);
        }
 
        /**
@@ -761,14 +761,14 @@ class ApiTest extends FixtureTest
        public function testApiRssExtraWithoutUserInfo()
        {
                $result = api_rss_extra($this->app, [], null);
-               $this->assertInternalType('array', $result['$user']);
-               $this->assertArrayHasKey('alternate', $result['$rss']);
-               $this->assertArrayHasKey('self', $result['$rss']);
-               $this->assertArrayHasKey('base', $result['$rss']);
-               $this->assertArrayHasKey('updated', $result['$rss']);
-               $this->assertArrayHasKey('atom_updated', $result['$rss']);
-               $this->assertArrayHasKey('language', $result['$rss']);
-               $this->assertArrayHasKey('logo', $result['$rss']);
+               self::assertIsArray($result['$user']);
+               self::assertArrayHasKey('alternate', $result['$rss']);
+               self::assertArrayHasKey('self', $result['$rss']);
+               self::assertArrayHasKey('base', $result['$rss']);
+               self::assertArrayHasKey('updated', $result['$rss']);
+               self::assertArrayHasKey('atom_updated', $result['$rss']);
+               self::assertArrayHasKey('language', $result['$rss']);
+               self::assertArrayHasKey('logo', $result['$rss']);
        }
 
        /**
@@ -778,7 +778,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiUniqueIdToNurl()
        {
-               $this->assertFalse(api_unique_id_to_nurl($this->wrongUserId));
+               self::assertFalse(api_unique_id_to_nurl($this->wrongUserId));
        }
 
        /**
@@ -788,7 +788,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiUniqueIdToNurlWithCorrectId()
        {
-               $this->assertEquals($this->otherUser['nurl'], api_unique_id_to_nurl($this->otherUser['id']));
+               self::assertEquals($this->otherUser['nurl'], api_unique_id_to_nurl($this->otherUser['id']));
        }
 
        /**
@@ -799,10 +799,10 @@ class ApiTest extends FixtureTest
        public function testApiGetUser()
        {
                $user = api_get_user($this->app);
-               $this->assertSelfUser($user);
-               $this->assertEquals('708fa0', $user['profile_sidebar_fill_color']);
-               $this->assertEquals('6fdbe8', $user['profile_link_color']);
-               $this->assertEquals('ededed', $user['profile_background_color']);
+               self::assertSelfUser($user);
+               self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
+               self::assertEquals('6fdbe8', $user['profile_link_color']);
+               self::assertEquals('ededed', $user['profile_background_color']);
        }
 
        /**
@@ -815,10 +815,10 @@ class ApiTest extends FixtureTest
                $pConfig = $this->dice->create(IPConfig::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']);
-               $this->assertEquals('6fdbe8', $user['profile_link_color']);
-               $this->assertEquals('ededed', $user['profile_background_color']);
+               self::assertSelfUser($user);
+               self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
+               self::assertEquals('6fdbe8', $user['profile_link_color']);
+               self::assertEquals('ededed', $user['profile_background_color']);
        }
 
        /**
@@ -831,10 +831,10 @@ class ApiTest extends FixtureTest
                $pConfig = $this->dice->create(IPConfig::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']);
-               $this->assertEquals('6fdbe8', $user['profile_link_color']);
-               $this->assertEquals('ededed', $user['profile_background_color']);
+               self::assertSelfUser($user);
+               self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
+               self::assertEquals('6fdbe8', $user['profile_link_color']);
+               self::assertEquals('ededed', $user['profile_background_color']);
        }
 
        /**
@@ -850,24 +850,24 @@ class ApiTest extends FixtureTest
                $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']);
-               $this->assertEquals('123456', $user['profile_link_color']);
-               $this->assertEquals('123456', $user['profile_background_color']);
+               self::assertSelfUser($user);
+               self::assertEquals('123456', $user['profile_sidebar_fill_color']);
+               self::assertEquals('123456', $user['profile_link_color']);
+               self::assertEquals('123456', $user['profile_background_color']);
        }
 
        /**
         * Test the api_get_user() function with an user that is not allowed to use the API.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiGetUserWithoutApiUser()
        {
                $_SERVER['PHP_AUTH_USER'] = 'Test user';
                $_SERVER['PHP_AUTH_PW']   = 'password';
                $_SESSION['allow_api']    = false;
-               $this->assertFalse(api_get_user($this->app));
+               self::assertFalse(api_get_user($this->app));
        }
 
        /**
@@ -878,19 +878,19 @@ class ApiTest extends FixtureTest
        public function testApiGetUserWithGetId()
        {
                $_GET['user_id'] = $this->otherUser['id'];
-               $this->assertOtherUser(api_get_user($this->app));
+               self::assertOtherUser(api_get_user($this->app));
        }
 
        /**
         * Test the api_get_user() function with a wrong user ID in a GET parameter.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiGetUserWithWrongGetId()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $_GET['user_id'] = $this->wrongUserId;
-               $this->assertOtherUser(api_get_user($this->app));
+               self::assertOtherUser(api_get_user($this->app));
        }
 
        /**
@@ -901,7 +901,7 @@ class ApiTest extends FixtureTest
        public function testApiGetUserWithGetName()
        {
                $_GET['screen_name'] = $this->selfUser['nick'];
-               $this->assertSelfUser(api_get_user($this->app));
+               self::assertSelfUser(api_get_user($this->app));
        }
 
        /**
@@ -912,7 +912,7 @@ class ApiTest extends FixtureTest
        public function testApiGetUserWithGetUrl()
        {
                $_GET['profileurl'] = $this->selfUser['nurl'];
-               $this->assertSelfUser(api_get_user($this->app));
+               self::assertSelfUser(api_get_user($this->app));
        }
 
        /**
@@ -924,8 +924,8 @@ class ApiTest extends FixtureTest
        {
                global $called_api;
                $called_api         = ['api_path'];
-               $this->app->argv[1] = $this->otherUser['id'] . '.json';
-               $this->assertOtherUser(api_get_user($this->app));
+               DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
+               self::assertOtherUser(api_get_user($this->app));
        }
 
        /**
@@ -937,7 +937,7 @@ class ApiTest extends FixtureTest
        {
                global $called_api;
                $called_api = ['api', 'api_path'];
-               $this->assertSelfUser(api_get_user($this->app));
+               self::assertSelfUser(api_get_user($this->app));
        }
 
        /**
@@ -947,18 +947,18 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithCorrectUser()
        {
-               $this->assertOtherUser(api_get_user($this->app, $this->otherUser['id']));
+               self::assertOtherUser(api_get_user($this->app, $this->otherUser['id']));
        }
 
        /**
         * Test the api_get_user() function with a wrong user ID.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiGetUserWithWrongUser()
        {
-               $this->assertOtherUser(api_get_user($this->app, $this->wrongUserId));
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
+               self::assertOtherUser(api_get_user($this->app, $this->wrongUserId));
        }
 
        /**
@@ -968,7 +968,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithZeroUser()
        {
-               $this->assertSelfUser(api_get_user($this->app, 0));
+               self::assertSelfUser(api_get_user($this->app, 0));
        }
 
        /**
@@ -979,7 +979,7 @@ class ApiTest extends FixtureTest
        public function testApiItemGetUser()
        {
                $users = api_item_get_user($this->app, []);
-               $this->assertSelfUser($users[0]);
+               self::assertSelfUser($users[0]);
        }
 
        /**
@@ -990,8 +990,8 @@ class ApiTest extends FixtureTest
        public function testApiItemGetUserWithDifferentParent()
        {
                $users = api_item_get_user($this->app, ['thr-parent' => 'item_parent', 'uri' => 'item_uri']);
-               $this->assertSelfUser($users[0]);
-               $this->assertEquals($users[0], $users[1]);
+               self::assertSelfUser($users[0]);
+               self::assertEquals($users[0], $users[1]);
        }
 
        /**
@@ -1002,7 +1002,7 @@ class ApiTest extends FixtureTest
        public function testApiWalkRecursive()
        {
                $array = ['item1'];
-               $this->assertEquals(
+               self::assertEquals(
                        $array,
                        api_walk_recursive(
                                $array,
@@ -1022,7 +1022,7 @@ class ApiTest extends FixtureTest
        public function testApiWalkRecursiveWithArray()
        {
                $array = [['item1'], ['item2']];
-               $this->assertEquals(
+               self::assertEquals(
                        $array,
                        api_walk_recursive(
                                $array,
@@ -1043,8 +1043,8 @@ class ApiTest extends FixtureTest
        {
                $item = true;
                $key  = '';
-               $this->assertTrue(api_reformat_xml($item, $key));
-               $this->assertEquals('true', $item);
+               self::assertTrue(api_reformat_xml($item, $key));
+               self::assertEquals('true', $item);
        }
 
        /**
@@ -1056,8 +1056,8 @@ class ApiTest extends FixtureTest
        {
                $item = '';
                $key  = 'statusnet_api';
-               $this->assertTrue(api_reformat_xml($item, $key));
-               $this->assertEquals('statusnet:api', $key);
+               self::assertTrue(api_reformat_xml($item, $key));
+               self::assertEquals('statusnet:api', $key);
        }
 
        /**
@@ -1069,8 +1069,8 @@ class ApiTest extends FixtureTest
        {
                $item = '';
                $key  = 'friendica_api';
-               $this->assertTrue(api_reformat_xml($item, $key));
-               $this->assertEquals('friendica:api', $key);
+               self::assertTrue(api_reformat_xml($item, $key));
+               self::assertEquals('friendica:api', $key);
        }
 
        /**
@@ -1080,7 +1080,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiCreateXml()
        {
-               $this->assertEquals(
+               self::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/" ' .
@@ -1098,7 +1098,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiCreateXmlWithoutNamespaces()
        {
-               $this->assertEquals(
+               self::assertEquals(
                        '<?xml version="1.0"?>' . "\n" .
                        '<ok>' . "\n" .
                        '  <data>some_data</data>' . "\n" .
@@ -1115,7 +1115,7 @@ class ApiTest extends FixtureTest
        public function testApiFormatData()
        {
                $data = ['some_data'];
-               $this->assertEquals($data, api_format_data('root_element', 'json', $data));
+               self::assertEquals($data, api_format_data('root_element', 'json', $data));
        }
 
        /**
@@ -1125,7 +1125,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiFormatDataWithXml()
        {
-               $this->assertEquals(
+               self::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/" ' .
@@ -1143,17 +1143,17 @@ class ApiTest extends FixtureTest
         */
        public function testApiAccountVerifyCredentials()
        {
-               $this->assertArrayHasKey('user', api_account_verify_credentials('json'));
+               self::assertArrayHasKey('user', api_account_verify_credentials('json'));
        }
 
        /**
         * Test the api_account_verify_credentials() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_account_verify_credentials('json');
        }
@@ -1165,7 +1165,7 @@ class ApiTest extends FixtureTest
         */
        public function testRequestdata()
        {
-               $this->assertNull(requestdata('variable_name'));
+               self::assertNull(requestdata('variable_name'));
        }
 
        /**
@@ -1176,7 +1176,7 @@ class ApiTest extends FixtureTest
        public function testRequestdataWithPost()
        {
                $_POST['variable_name'] = 'variable_value';
-               $this->assertEquals('variable_value', requestdata('variable_name'));
+               self::assertEquals('variable_value', requestdata('variable_name'));
        }
 
        /**
@@ -1187,7 +1187,7 @@ class ApiTest extends FixtureTest
        public function testRequestdataWithGet()
        {
                $_GET['variable_name'] = 'variable_value';
-               $this->assertEquals('variable_value', requestdata('variable_name'));
+               self::assertEquals('variable_value', requestdata('variable_name'));
        }
 
        /**
@@ -1197,7 +1197,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesMediap()
        {
-               $this->app->argc = 2;
+               DI::args()->setArgc(2);
 
                $_FILES         = [
                        'media' => [
@@ -1213,17 +1213,17 @@ class ApiTest extends FixtureTest
                $_GET['status'] = '<b>Status content</b>';
 
                $result = api_statuses_mediap('json');
-               $this->assertStatus($result['status']);
+               self::assertStatus($result['status']);
        }
 
        /**
         * Test the api_statuses_mediap() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesMediapWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_statuses_mediap('json');
        }
@@ -1252,7 +1252,7 @@ class ApiTest extends FixtureTest
                ];
 
                $result = api_statuses_update('json');
-               $this->assertStatus($result['status']);
+               self::assertStatus($result['status']);
        }
 
        /**
@@ -1265,17 +1265,17 @@ class ApiTest extends FixtureTest
                $_GET['htmlstatus'] = '<b>Status content</b>';
 
                $result = api_statuses_update('json');
-               $this->assertStatus($result['status']);
+               self::assertStatus($result['status']);
        }
 
        /**
         * Test the api_statuses_update() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesUpdateWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_statuses_update('json');
        }
@@ -1312,12 +1312,12 @@ class ApiTest extends FixtureTest
 
        /**
         * Test the api_media_upload() function.
-        *
-        * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
+        * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiMediaUpload()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_media_upload();
        }
 
@@ -1325,10 +1325,10 @@ class ApiTest extends FixtureTest
         * Test the api_media_upload() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiMediaUploadWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_media_upload();
        }
@@ -1337,10 +1337,10 @@ class ApiTest extends FixtureTest
         * Test the api_media_upload() function with an invalid uploaded media.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\InternalServerErrorException
         */
        public function testApiMediaUploadWithMedia()
        {
+               $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class);
                $_FILES = [
                        'media' => [
                                'id'       => 666,
@@ -1369,13 +1369,13 @@ class ApiTest extends FixtureTest
                        ]
                ];
                $app       = DI::app();
-               $app->argc = 2;
+               DI::args()->setArgc(2);
 
                $result = api_media_upload();
-               $this->assertEquals('image/png', $result['media']['image']['image_type']);
-               $this->assertEquals(1, $result['media']['image']['w']);
-               $this->assertEquals(1, $result['media']['image']['h']);
-               $this->assertNotEmpty($result['media']['image']['friendica_preview_url']);
+               self::assertEquals('image/png', $result['media']['image']['image_type']);
+               self::assertEquals(1, $result['media']['image']['w']);
+               self::assertEquals(1, $result['media']['image']['h']);
+               self::assertNotEmpty($result['media']['image']['friendica_preview_url']);
        }
 
        /**
@@ -1384,7 +1384,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusShowWithJson()
        {
                $result = api_status_show('json', 1);
-               $this->assertStatus($result['status']);
+               self::assertStatus($result['status']);
        }
 
        /**
@@ -1393,7 +1393,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusShowWithXml()
        {
                $result = api_status_show('xml', 1);
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
@@ -1403,7 +1403,7 @@ class ApiTest extends FixtureTest
        {
                $item = api_get_last_status($this->selfUser['id'], $this->selfUser['id']);
 
-               $this->assertNotNull($item);
+               self::assertNotNull($item);
        }
 
        /**
@@ -1415,12 +1415,12 @@ class ApiTest extends FixtureTest
        {
                $result = api_users_show('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']);
-               $this->assertEquals($this->selfUser['name'], $result['user']['name']);
-               $this->assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
-               $this->assertEquals('dfrn', $result['user']['network']);
-               $this->assertTrue($result['user']['verified']);
+               self::assertEquals($this->selfUser['id'], $result['user']['cid']);
+               self::assertEquals('DFRN', $result['user']['location']);
+               self::assertEquals($this->selfUser['name'], $result['user']['name']);
+               self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
+               self::assertEquals('dfrn', $result['user']['network']);
+               self::assertTrue($result['user']['verified']);
        }
 
        /**
@@ -1431,7 +1431,7 @@ class ApiTest extends FixtureTest
        public function testApiUsersShowWithXml()
        {
                $result = api_users_show('xml');
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
@@ -1443,7 +1443,7 @@ class ApiTest extends FixtureTest
        {
                $_GET['q'] = 'othercontact';
                $result    = api_users_search('json');
-               $this->assertOtherUser($result['users'][0]);
+               self::assertOtherUser($result['users'][0]);
        }
 
        /**
@@ -1455,17 +1455,17 @@ class ApiTest extends FixtureTest
        {
                $_GET['q'] = 'othercontact';
                $result    = api_users_search('xml');
-               $this->assertXml($result, 'users');
+               self::assertXml($result, 'users');
        }
 
        /**
         * Test the api_users_search() function without a GET q parameter.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiUsersSearchWithoutQuery()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_users_search('json');
        }
 
@@ -1473,10 +1473,10 @@ class ApiTest extends FixtureTest
         * Test the api_users_lookup() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\NotFoundException
         */
        public function testApiUsersLookup()
        {
+               $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
                api_users_lookup('json');
        }
 
@@ -1489,7 +1489,7 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['user_id'] = $this->otherUser['id'];
                $result              = api_users_lookup('json');
-               $this->assertOtherUser($result['users'][0]);
+               self::assertOtherUser($result['users'][0]);
        }
 
        /**
@@ -1503,8 +1503,8 @@ class ApiTest extends FixtureTest
                $_REQUEST['max_id'] = 10;
                $result             = api_search('json');
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
-                       $this->assertContains('reply', $status['text'], null, true);
+                       self::assertStatus($status);
+                       self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
                }
        }
 
@@ -1519,8 +1519,8 @@ class ApiTest extends FixtureTest
                $_REQUEST['count'] = 20;
                $result            = api_search('json');
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
-                       $this->assertContains('reply', $status['text'], null, true);
+                       self::assertStatus($status);
+                       self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
                }
        }
 
@@ -1535,30 +1535,28 @@ class ApiTest extends FixtureTest
                $_REQUEST['rpp'] = 20;
                $result          = api_search('json');
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
-                       $this->assertContains('reply', $status['text'], null, true);
+                       self::assertStatus($status);
+                       self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
                }
        }
 
        /**
         * Test the api_search() function with an q parameter contains hashtag.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiSearchWithHashtag()
        {
                $_REQUEST['q'] = '%23friendica';
                $result        = api_search('json');
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
-                       $this->assertContains('#friendica', $status['text'], null, true);
+                       self::assertStatus($status);
+                       self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
                }
        }
 
        /**
         * Test the api_search() function with an exclude_replies parameter.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiSearchWithExcludeReplies()
        {
@@ -1567,7 +1565,7 @@ class ApiTest extends FixtureTest
                $_REQUEST['q']               = 'friendica';
                $result                      = api_search('json');
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1575,10 +1573,10 @@ class ApiTest extends FixtureTest
         * Test the api_search() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiSearchWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_search('json');
@@ -1588,10 +1586,10 @@ class ApiTest extends FixtureTest
         * Test the api_search() function without any GET query parameter.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiSearchWithoutQuery()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_search('json');
        }
 
@@ -1606,9 +1604,9 @@ class ApiTest extends FixtureTest
                $_REQUEST['exclude_replies'] = true;
                $_REQUEST['conversation_id'] = 1;
                $result                      = api_statuses_home_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1621,9 +1619,9 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['page'] = -2;
                $result           = api_statuses_home_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1631,10 +1629,10 @@ class ApiTest extends FixtureTest
         * Test the api_statuses_home_timeline() with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesHomeTimelineWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_home_timeline('json');
@@ -1648,7 +1646,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesHomeTimelineWithRss()
        {
                $result = api_statuses_home_timeline('rss');
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
@@ -1661,9 +1659,9 @@ class ApiTest extends FixtureTest
                $_REQUEST['max_id']          = 10;
                $_REQUEST['conversation_id'] = 1;
                $result                      = api_statuses_public_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1677,9 +1675,9 @@ class ApiTest extends FixtureTest
                $_REQUEST['max_id']          = 10;
                $_REQUEST['exclude_replies'] = true;
                $result                      = api_statuses_public_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1692,9 +1690,9 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['page'] = -2;
                $result           = api_statuses_public_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1702,10 +1700,10 @@ class ApiTest extends FixtureTest
         * Test the api_statuses_public_timeline() function with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesPublicTimelineWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_public_timeline('json');
@@ -1719,7 +1717,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesPublicTimelineWithRss()
        {
                $result = api_statuses_public_timeline('rss');
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
@@ -1731,9 +1729,9 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['max_id'] = 10;
                $result             = api_statuses_networkpublic_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1746,9 +1744,9 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['page'] = -2;
                $result           = api_statuses_networkpublic_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1756,10 +1754,10 @@ class ApiTest extends FixtureTest
         * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_networkpublic_timeline('json');
@@ -1773,17 +1771,17 @@ class ApiTest extends FixtureTest
        public function testApiStatusesNetworkpublicTimelineWithRss()
        {
                $result = api_statuses_networkpublic_timeline('rss');
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
         * Test the api_statuses_show() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiStatusesShow()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_statuses_show('json');
        }
 
@@ -1794,9 +1792,9 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesShowWithId()
        {
-               $this->app->argv[3] = 1;
-               $result             = api_statuses_show('json');
-               $this->assertStatus($result['status']);
+               DI::args()->setArgv(['', '', '', 1]);
+               $result = api_statuses_show('json');
+               self::assertStatus($result['status']);
        }
 
        /**
@@ -1806,12 +1804,12 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesShowWithConversation()
        {
-               $this->app->argv[3]       = 1;
+               DI::args()->setArgv(['', '', '', 1]);
                $_REQUEST['conversation'] = 1;
                $result                   = api_statuses_show('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1819,10 +1817,10 @@ class ApiTest extends FixtureTest
         * Test the api_statuses_show() function with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesShowWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_show('json');
@@ -1832,10 +1830,10 @@ class ApiTest extends FixtureTest
         * Test the api_conversation_show() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiConversationShow()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_conversation_show('json');
        }
 
@@ -1846,13 +1844,13 @@ class ApiTest extends FixtureTest
         */
        public function testApiConversationShowWithId()
        {
-               $this->app->argv[3] = 1;
+               DI::args()->setArgv(['', '', '', 1]);
                $_REQUEST['max_id'] = 10;
                $_REQUEST['page']   = -2;
                $result             = api_conversation_show('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -1860,10 +1858,10 @@ class ApiTest extends FixtureTest
         * Test the api_conversation_show() function with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiConversationShowWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_conversation_show('json');
@@ -1873,10 +1871,10 @@ class ApiTest extends FixtureTest
         * Test the api_statuses_repeat() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesRepeat()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                api_statuses_repeat('json');
        }
 
@@ -1884,10 +1882,10 @@ class ApiTest extends FixtureTest
         * Test the api_statuses_repeat() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesRepeatWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_statuses_repeat('json');
        }
@@ -1899,24 +1897,24 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesRepeatWithId()
        {
-               $this->app->argv[3] = 1;
-               $result             = api_statuses_repeat('json');
-               $this->assertStatus($result['status']);
+               DI::args()->setArgv(['', '', '', 1]);
+               $result = api_statuses_repeat('json');
+               self::assertStatus($result['status']);
 
                // Also test with a shared status
-               $this->app->argv[3] = 5;
-               $result             = api_statuses_repeat('json');
-               $this->assertStatus($result['status']);
+               DI::args()->setArgv(['', '', '', 5]);
+               $result = api_statuses_repeat('json');
+               self::assertStatus($result['status']);
        }
 
        /**
         * Test the api_statuses_destroy() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiStatusesDestroy()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_statuses_destroy('json');
        }
 
@@ -1924,10 +1922,10 @@ class ApiTest extends FixtureTest
         * Test the api_statuses_destroy() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesDestroyWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_statuses_destroy('json');
        }
@@ -1939,9 +1937,9 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesDestroyWithId()
        {
-               $this->app->argv[3] = 1;
-               $result             = api_statuses_destroy('json');
-               $this->assertStatus($result['status']);
+               DI::args()->setArgv(['', '', '', 1]);
+               $result = api_statuses_destroy('json');
+               self::assertStatus($result['status']);
        }
 
        /**
@@ -1951,10 +1949,10 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesMentions()
        {
-               $this->app->user    = ['nickname' => $this->selfUser['nick']];
+               $this->app->setLoggedInUserNickname($this->selfUser['nick']);
                $_REQUEST['max_id'] = 10;
                $result             = api_statuses_mentions('json');
-               $this->assertEmpty($result['status']);
+               self::assertEmpty($result['status']);
                // We should test with mentions in the database.
        }
 
@@ -1967,17 +1965,17 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['page'] = -2;
                $result           = api_statuses_mentions('json');
-               $this->assertEmpty($result['status']);
+               self::assertEmpty($result['status']);
        }
 
        /**
         * Test the api_statuses_mentions() function with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesMentionsWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_mentions('json');
@@ -1991,7 +1989,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesMentionsWithRss()
        {
                $result = api_statuses_mentions('rss');
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
@@ -2005,9 +2003,9 @@ class ApiTest extends FixtureTest
                $_REQUEST['exclude_replies'] = true;
                $_REQUEST['conversation_id'] = 1;
                $result                      = api_statuses_user_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -2020,9 +2018,9 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['page'] = -2;
                $result           = api_statuses_user_timeline('json');
-               $this->assertNotEmpty($result['status']);
+               self::assertNotEmpty($result['status']);
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -2034,17 +2032,17 @@ class ApiTest extends FixtureTest
        public function testApiStatusesUserTimelineWithRss()
        {
                $result = api_statuses_user_timeline('rss');
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
         * Test the api_statuses_user_timeline() function with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiStatusesUserTimelineWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_statuses_user_timeline('json');
@@ -2054,12 +2052,11 @@ class ApiTest extends FixtureTest
         * Test the api_favorites_create_destroy() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFavoritesCreateDestroy()
        {
-               $this->app->argv = ['api', '1.1', 'favorites', 'create'];
-               $this->app->argc = count($this->app->argv);
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
                api_favorites_create_destroy('json');
        }
 
@@ -2067,12 +2064,11 @@ class ApiTest extends FixtureTest
         * Test the api_favorites_create_destroy() function with an invalid ID.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFavoritesCreateDestroyWithInvalidId()
        {
-               $this->app->argv = ['api', '1.1', 'favorites', 'create', '12.json'];
-               $this->app->argc = count($this->app->argv);
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
                api_favorites_create_destroy('json');
        }
 
@@ -2080,13 +2076,12 @@ class ApiTest extends FixtureTest
         * Test the api_favorites_create_destroy() function with an invalid action.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFavoritesCreateDestroyWithInvalidAction()
        {
-               $this->app->argv = ['api', '1.1', 'favorites', 'change.json'];
-               $this->app->argc = count($this->app->argv);
-               $_REQUEST['id']  = 1;
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
+               $_REQUEST['id'] = 1;
                api_favorites_create_destroy('json');
        }
 
@@ -2097,11 +2092,10 @@ class ApiTest extends FixtureTest
         */
        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');
-               $this->assertStatus($result['status']);
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
+               $_REQUEST['id'] = 3;
+               $result         = api_favorites_create_destroy('json');
+               self::assertStatus($result['status']);
        }
 
        /**
@@ -2111,11 +2105,10 @@ class ApiTest extends FixtureTest
         */
        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');
-               $this->assertXml($result, 'status');
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
+               $_REQUEST['id'] = 3;
+               $result         = api_favorites_create_destroy('rss');
+               self::assertXml($result, 'status');
        }
 
        /**
@@ -2125,23 +2118,21 @@ class ApiTest extends FixtureTest
         */
        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');
-               $this->assertStatus($result['status']);
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
+               $_REQUEST['id'] = 3;
+               $result         = api_favorites_create_destroy('json');
+               self::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->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
                $_SESSION['authenticated'] = false;
                api_favorites_create_destroy('json');
        }
@@ -2157,7 +2148,7 @@ class ApiTest extends FixtureTest
                $_REQUEST['max_id'] = 10;
                $result             = api_favorites('json');
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -2169,17 +2160,17 @@ class ApiTest extends FixtureTest
        public function testApiFavoritesWithRss()
        {
                $result = api_favorites('rss');
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
         * Test the api_favorites() function with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFavoritesWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_favorites('json');
@@ -2193,16 +2184,16 @@ class ApiTest extends FixtureTest
        public function testApiFormatMessages()
        {
                $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']
+                       ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
+                       ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
+                       ['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
                );
-               $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']);
-               $this->assertEquals('recipient_name', $result['recipient_screen_name']);
-               $this->assertEquals('sender_name', $result['sender_screen_name']);
+               self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
+               self::assertEquals(1, $result['id']);
+               self::assertEquals(2, $result['recipient_id']);
+               self::assertEquals(3, $result['sender_id']);
+               self::assertEquals('recipient_name', $result['recipient_screen_name']);
+               self::assertEquals('sender_name', $result['sender_screen_name']);
        }
 
        /**
@@ -2214,12 +2205,12 @@ class ApiTest extends FixtureTest
        {
                $_GET['getText'] = 'html';
                $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']
+                       ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
+                       ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
+                       ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
                );
-               $this->assertEquals('item_title', $result['title']);
-               $this->assertEquals('<strong>item_body</strong>', $result['text']);
+               self::assertEquals('item_title', $result['title']);
+               self::assertEquals('<strong>item_body</strong>', $result['text']);
        }
 
        /**
@@ -2231,12 +2222,12 @@ class ApiTest extends FixtureTest
        {
                $_GET['getText'] = 'plain';
                $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']
+                       ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
+                       ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
+                       ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
                );
-               $this->assertEquals('item_title', $result['title']);
-               $this->assertEquals('item_body', $result['text']);
+               self::assertEquals('item_title', $result['title']);
+               self::assertEquals('item_body', $result['text']);
        }
 
        /**
@@ -2248,12 +2239,12 @@ class ApiTest extends FixtureTest
        {
                $_GET['getUserObjects'] = 'false';
                $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']
+                       ['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
+                       ['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
+                       ['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
                );
-               $this->assertTrue(!isset($result['sender']));
-               $this->assertTrue(!isset($result['recipient']));
+               self::assertTrue(!isset($result['sender']));
+               self::assertTrue(!isset($result['recipient']));
        }
 
        /**
@@ -2267,6 +2258,7 @@ class ApiTest extends FixtureTest
                        [
                                'network' => 'feed',
                                'title'   => 'item_title',
+                               'uri-id'  => 1,
                                // 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 ' .
@@ -2294,8 +2286,8 @@ class ApiTest extends FixtureTest
                                'plink'   => 'item_plink'
                        ]
                );
-               $this->assertStringStartsWith('item_title', $result['text']);
-               $this->assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
+               self::assertStringStartsWith('item_title', $result['text']);
+               self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
        }
 
        /**
@@ -2309,12 +2301,13 @@ class ApiTest extends FixtureTest
                        [
                                'network' => 'feed',
                                'title'   => 'item_title',
+                               'uri-id'  => -1,
                                'body'    => '',
                                'plink'   => 'item_plink'
                        ]
                );
-               $this->assertEquals('item_title', $result['text']);
-               $this->assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
+               self::assertEquals("item_title", $result['text']);
+               self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
        }
 
        /**
@@ -2326,12 +2319,13 @@ class ApiTest extends FixtureTest
        {
                $result = api_convert_item(
                        [
-                               'title' => 'item_title',
-                               'body'  => 'item_title item_body'
+                               'title'  => 'item_title',
+                               'body'   => 'item_title item_body',
+                               'uri-id' => 1,
                        ]
                );
-               $this->assertEquals('item_title item_body', $result['text']);
-               $this->assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
+               self::assertEquals('item_title item_body', $result['text']);
+               self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
        }
 
        /**
@@ -2342,7 +2336,7 @@ class ApiTest extends FixtureTest
        public function testApiGetAttachments()
        {
                $body = 'body';
-               $this->assertEmpty(api_get_attachments($body));
+               self::assertEmpty(api_get_attachments($body, 0));
        }
 
        /**
@@ -2353,7 +2347,7 @@ class ApiTest extends FixtureTest
        public function testApiGetAttachmentsWithImage()
        {
                $body = '[img]http://via.placeholder.com/1x1.png[/img]';
-               $this->assertInternalType('array', api_get_attachments($body));
+               self::assertIsArray(api_get_attachments($body, 0));
        }
 
        /**
@@ -2365,7 +2359,7 @@ class ApiTest extends FixtureTest
        {
                $_SERVER['HTTP_USER_AGENT'] = 'AndStatus';
                $body                       = '[img]http://via.placeholder.com/1x1.png[/img]';
-               $this->assertInternalType('array', api_get_attachments($body));
+               self::assertIsArray(api_get_attachments($body, 0));
        }
 
        /**
@@ -2376,7 +2370,7 @@ class ApiTest extends FixtureTest
        public function testApiGetEntitities()
        {
                $text = 'text';
-               $this->assertInternalType('array', api_get_entitities($text, 'bbcode'));
+               self::assertIsArray(api_get_entitities($text, 'bbcode', 0));
        }
 
        /**
@@ -2388,11 +2382,11 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['include_entities'] = 'true';
                $text                         = 'text';
-               $result                       = api_get_entitities($text, 'bbcode');
-               $this->assertInternalType('array', $result['hashtags']);
-               $this->assertInternalType('array', $result['symbols']);
-               $this->assertInternalType('array', $result['urls']);
-               $this->assertInternalType('array', $result['user_mentions']);
+               $result                       = api_get_entitities($text, 'bbcode', 0);
+               self::assertIsArray($result['hashtags']);
+               self::assertIsArray($result['symbols']);
+               self::assertIsArray($result['urls']);
+               self::assertIsArray($result['user_mentions']);
        }
 
        /**
@@ -2402,7 +2396,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiFormatItemsEmbededImages()
        {
-               $this->assertEquals(
+               self::assertEquals(
                        'text ' . DI::baseUrl() . '/display/item_guid',
                        api_format_items_embeded_images(['guid' => 'item_guid'], 'text data:image/foo')
                );
@@ -2415,7 +2409,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiContactlinkToArray()
        {
-               $this->assertEquals(
+               self::assertEquals(
                        [
                                'name' => 'text',
                                'url'  => '',
@@ -2431,7 +2425,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiContactlinkToArrayWithUrl()
        {
-               $this->assertEquals(
+               self::assertEquals(
                        [
                                'name' => ['link_text'],
                                'url'  => ['url'],
@@ -2449,11 +2443,11 @@ class ApiTest extends FixtureTest
        {
                $item   = ['uid' => 0, 'uri' => ''];
                $result = api_format_items_activities($item);
-               $this->assertArrayHasKey('like', $result);
-               $this->assertArrayHasKey('dislike', $result);
-               $this->assertArrayHasKey('attendyes', $result);
-               $this->assertArrayHasKey('attendno', $result);
-               $this->assertArrayHasKey('attendmaybe', $result);
+               self::assertArrayHasKey('like', $result);
+               self::assertArrayHasKey('dislike', $result);
+               self::assertArrayHasKey('attendyes', $result);
+               self::assertArrayHasKey('attendno', $result);
+               self::assertArrayHasKey('attendmaybe', $result);
        }
 
        /**
@@ -2465,17 +2459,16 @@ class ApiTest extends FixtureTest
        {
                $item   = ['uid' => 0, 'uri' => ''];
                $result = api_format_items_activities($item, 'xml');
-               $this->assertArrayHasKey('friendica:like', $result);
-               $this->assertArrayHasKey('friendica:dislike', $result);
-               $this->assertArrayHasKey('friendica:attendyes', $result);
-               $this->assertArrayHasKey('friendica:attendno', $result);
-               $this->assertArrayHasKey('friendica:attendmaybe', $result);
+               self::assertArrayHasKey('friendica:like', $result);
+               self::assertArrayHasKey('friendica:dislike', $result);
+               self::assertArrayHasKey('friendica:attendyes', $result);
+               self::assertArrayHasKey('friendica:attendno', $result);
+               self::assertArrayHasKey('friendica:attendmaybe', $result);
        }
 
        /**
         * Test the api_format_items() function.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiFormatItems()
        {
@@ -2494,14 +2487,13 @@ class ApiTest extends FixtureTest
                ];
                $result = api_format_items($items, ['id' => 0], true);
                foreach ($result as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
        /**
         * Test the api_format_items() function with an XML result.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiFormatItemsWithXml()
        {
@@ -2518,7 +2510,7 @@ class ApiTest extends FixtureTest
                ];
                $result = api_format_items($items, ['id' => 0], true, 'xml');
                foreach ($result as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -2530,9 +2522,9 @@ class ApiTest extends FixtureTest
        public function testApiAccountRateLimitStatus()
        {
                $result = api_account_rate_limit_status('json');
-               $this->assertEquals(150, $result['hash']['remaining_hits']);
-               $this->assertEquals(150, $result['hash']['hourly_limit']);
-               $this->assertInternalType('int', $result['hash']['reset_time_in_seconds']);
+               self::assertEquals(150, $result['hash']['remaining_hits']);
+               self::assertEquals(150, $result['hash']['hourly_limit']);
+               self::assertIsInt($result['hash']['reset_time_in_seconds']);
        }
 
        /**
@@ -2543,7 +2535,7 @@ class ApiTest extends FixtureTest
        public function testApiAccountRateLimitStatusWithXml()
        {
                $result = api_account_rate_limit_status('xml');
-               $this->assertXml($result, 'hash');
+               self::assertXml($result, 'hash');
        }
 
        /**
@@ -2554,7 +2546,7 @@ class ApiTest extends FixtureTest
        public function testApiHelpTest()
        {
                $result = api_help_test('json');
-               $this->assertEquals(['ok' => 'ok'], $result);
+               self::assertEquals(['ok' => 'ok'], $result);
        }
 
        /**
@@ -2565,7 +2557,7 @@ class ApiTest extends FixtureTest
        public function testApiHelpTestWithXml()
        {
                $result = api_help_test('xml');
-               $this->assertXml($result, 'ok');
+               self::assertXml($result, 'ok');
        }
 
        /**
@@ -2576,7 +2568,7 @@ class ApiTest extends FixtureTest
        public function testApiListsList()
        {
                $result = api_lists_list('json');
-               $this->assertEquals(['lists_list' => []], $result);
+               self::assertEquals(['lists_list' => []], $result);
        }
 
        /**
@@ -2588,7 +2580,7 @@ class ApiTest extends FixtureTest
        {
                $result = api_lists_ownerships('json');
                foreach ($result['lists']['lists'] as $list) {
-                       $this->assertList($list);
+                       self::assertList($list);
                }
        }
 
@@ -2596,10 +2588,10 @@ class ApiTest extends FixtureTest
         * Test the api_lists_ownerships() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiListsOwnershipsWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_lists_ownerships('json');
        }
@@ -2607,18 +2599,17 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_lists_statuses() function.
         *
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         * @return void
         */
        public function testApiListsStatuses()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_lists_statuses('json');
        }
 
        /**
         * Test the api_lists_statuses() function with a list ID.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiListsStatusesWithListId()
        {
@@ -2627,7 +2618,7 @@ class ApiTest extends FixtureTest
                $_REQUEST['max_id']  = 10;
                $result              = api_lists_statuses('json');
                foreach ($result['status'] as $status) {
-                       $this->assertStatus($status);
+                       self::assertStatus($status);
                }
        }
 
@@ -2640,17 +2631,17 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['list_id'] = 1;
                $result              = api_lists_statuses('rss');
-               $this->assertXml($result, 'statuses');
+               self::assertXml($result, 'statuses');
        }
 
        /**
         * Test the api_lists_statuses() function with an unallowed user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiListsStatusesWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_lists_statuses('json');
@@ -2665,7 +2656,7 @@ class ApiTest extends FixtureTest
        {
                $_GET['page'] = -1;
                $result       = api_statuses_f('friends');
-               $this->assertArrayHasKey('user', $result);
+               self::assertArrayHasKey('user', $result);
        }
 
        /**
@@ -2676,7 +2667,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesFWithFollowers()
        {
                $result = api_statuses_f('followers');
-               $this->assertArrayHasKey('user', $result);
+               self::assertArrayHasKey('user', $result);
        }
 
        /**
@@ -2687,7 +2678,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesFWithBlocks()
        {
                $result = api_statuses_f('blocks');
-               $this->assertArrayHasKey('user', $result);
+               self::assertArrayHasKey('user', $result);
        }
 
        /**
@@ -2698,7 +2689,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesFWithIncoming()
        {
                $result = api_statuses_f('incoming');
-               $this->assertArrayHasKey('user', $result);
+               self::assertArrayHasKey('user', $result);
        }
 
        /**
@@ -2709,7 +2700,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesFWithUndefinedCursor()
        {
                $_GET['cursor'] = 'undefined';
-               $this->assertFalse(api_statuses_f('friends'));
+               self::assertFalse(api_statuses_f('friends'));
        }
 
        /**
@@ -2720,7 +2711,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesFriends()
        {
                $result = api_statuses_friends('json');
-               $this->assertArrayHasKey('user', $result);
+               self::assertArrayHasKey('user', $result);
        }
 
        /**
@@ -2731,7 +2722,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesFriendsWithUndefinedCursor()
        {
                $_GET['cursor'] = 'undefined';
-               $this->assertFalse(api_statuses_friends('json'));
+               self::assertFalse(api_statuses_friends('json'));
        }
 
        /**
@@ -2742,7 +2733,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesFollowers()
        {
                $result = api_statuses_followers('json');
-               $this->assertArrayHasKey('user', $result);
+               self::assertArrayHasKey('user', $result);
        }
 
        /**
@@ -2753,7 +2744,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesFollowersWithUndefinedCursor()
        {
                $_GET['cursor'] = 'undefined';
-               $this->assertFalse(api_statuses_followers('json'));
+               self::assertFalse(api_statuses_followers('json'));
        }
 
        /**
@@ -2764,7 +2755,7 @@ class ApiTest extends FixtureTest
        public function testApiBlocksList()
        {
                $result = api_blocks_list('json');
-               $this->assertArrayHasKey('user', $result);
+               self::assertArrayHasKey('user', $result);
        }
 
        /**
@@ -2775,7 +2766,7 @@ class ApiTest extends FixtureTest
        public function testApiBlocksListWithUndefinedCursor()
        {
                $_GET['cursor'] = 'undefined';
-               $this->assertFalse(api_blocks_list('json'));
+               self::assertFalse(api_blocks_list('json'));
        }
 
        /**
@@ -2786,7 +2777,7 @@ class ApiTest extends FixtureTest
        public function testApiFriendshipsIncoming()
        {
                $result = api_friendships_incoming('json');
-               $this->assertArrayHasKey('id', $result);
+               self::assertArrayHasKey('id', $result);
        }
 
        /**
@@ -2797,7 +2788,7 @@ class ApiTest extends FixtureTest
        public function testApiFriendshipsIncomingWithUndefinedCursor()
        {
                $_GET['cursor'] = 'undefined';
-               $this->assertFalse(api_friendships_incoming('json'));
+               self::assertFalse(api_friendships_incoming('json'));
        }
 
        /**
@@ -2808,16 +2799,16 @@ class ApiTest extends FixtureTest
        public function testApiStatusnetConfig()
        {
                $result = api_statusnet_config('json');
-               $this->assertEquals('localhost', $result['config']['site']['server']);
-               $this->assertEquals('default', $result['config']['site']['theme']);
-               $this->assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
-               $this->assertTrue($result['config']['site']['fancy']);
-               $this->assertEquals('en', $result['config']['site']['language']);
-               $this->assertEquals('UTC', $result['config']['site']['timezone']);
-               $this->assertEquals(200000, $result['config']['site']['textlimit']);
-               $this->assertEquals('false', $result['config']['site']['private']);
-               $this->assertEquals('false', $result['config']['site']['ssl']);
-               $this->assertEquals(30, $result['config']['site']['shorturllength']);
+               self::assertEquals('localhost', $result['config']['site']['server']);
+               self::assertEquals('default', $result['config']['site']['theme']);
+               self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
+               self::assertTrue($result['config']['site']['fancy']);
+               self::assertEquals('en', $result['config']['site']['language']);
+               self::assertEquals('UTC', $result['config']['site']['timezone']);
+               self::assertEquals(200000, $result['config']['site']['textlimit']);
+               self::assertEquals('false', $result['config']['site']['private']);
+               self::assertEquals('false', $result['config']['site']['ssl']);
+               self::assertEquals(30, $result['config']['site']['shorturllength']);
        }
 
        /**
@@ -2828,7 +2819,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusnetVersion()
        {
                $result = api_statusnet_version('json');
-               $this->assertEquals('0.9.7', $result['version']);
+               self::assertEquals('0.9.7', $result['version']);
        }
 
        /**
@@ -2839,17 +2830,17 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesNew()
        {
                $result = api_direct_messages_new('json');
-               $this->assertNull($result);
+               self::assertNull($result);
        }
 
        /**
         * Test the api_direct_messages_new() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiDirectMessagesNewWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_direct_messages_new('json');
        }
@@ -2864,7 +2855,7 @@ class ApiTest extends FixtureTest
                $_POST['text']    = 'message_text';
                $_POST['user_id'] = $this->otherUser['id'];
                $result           = api_direct_messages_new('json');
-               $this->assertEquals(['direct_message' => ['error' => -1]], $result);
+               self::assertEquals(['direct_message' => ['error' => -1]], $result);
        }
 
        /**
@@ -2874,13 +2865,13 @@ class ApiTest extends FixtureTest
         */
        public function testApiDirectMessagesNewWithScreenName()
        {
-               $this->app->user    = ['nickname' => $this->selfUser['nick']];
+               $this->app->setLoggedInUserNickname($this->selfUser['nick']);
                $_POST['text']        = 'message_text';
                $_POST['screen_name'] = $this->friendUser['nick'];
                $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']);
+               self::assertStringContainsString('message_text', $result['direct_message']['text']);
+               self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
+               self::assertEquals(1, $result['direct_message']['friendica_seen']);
        }
 
        /**
@@ -2890,15 +2881,15 @@ class ApiTest extends FixtureTest
         */
        public function testApiDirectMessagesNewWithTitle()
        {
-               $this->app->user    = ['nickname' => $this->selfUser['nick']];
+               $this->app->setLoggedInUserNickname($this->selfUser['nick']);
                $_POST['text']        = 'message_text';
                $_POST['screen_name'] = $this->friendUser['nick'];
                $_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']);
-               $this->assertEquals(1, $result['direct_message']['friendica_seen']);
+               self::assertStringContainsString('message_text', $result['direct_message']['text']);
+               self::assertStringContainsString('message_title', $result['direct_message']['text']);
+               self::assertEquals('selfcontact', $result['direct_message']['sender_screen_name']);
+               self::assertEquals(1, $result['direct_message']['friendica_seen']);
        }
 
        /**
@@ -2908,21 +2899,21 @@ class ApiTest extends FixtureTest
         */
        public function testApiDirectMessagesNewWithRss()
        {
-               $this->app->user    = ['nickname' => $this->selfUser['nick']];
+               $this->app->setLoggedInUserNickname($this->selfUser['nick']);
                $_POST['text']        = 'message_text';
                $_POST['screen_name'] = $this->friendUser['nick'];
                $result               = api_direct_messages_new('rss');
-               $this->assertXml($result, 'direct-messages');
+               self::assertXml($result, 'direct-messages');
        }
 
        /**
         * Test the api_direct_messages_destroy() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiDirectMessagesDestroy()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_direct_messages_destroy('json');
        }
 
@@ -2935,7 +2926,7 @@ class ApiTest extends FixtureTest
        {
                $_GET['friendica_verbose'] = 'true';
                $result                    = api_direct_messages_destroy('json');
-               $this->assertEquals(
+               self::assertEquals(
                        [
                                '$result' => [
                                        'result'  => 'error',
@@ -2950,10 +2941,10 @@ class ApiTest extends FixtureTest
         * Test the api_direct_messages_destroy() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_direct_messages_destroy('json');
        }
@@ -2962,10 +2953,10 @@ class ApiTest extends FixtureTest
         * Test the api_direct_messages_destroy() function with a non-zero ID.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiDirectMessagesDestroyWithId()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $_REQUEST['id'] = 1;
                api_direct_messages_destroy('json');
        }
@@ -2981,7 +2972,7 @@ class ApiTest extends FixtureTest
                $_REQUEST['friendica_parenturi'] = 'parent_uri';
                $_GET['friendica_verbose']       = 'true';
                $result                          = api_direct_messages_destroy('json');
-               $this->assertEquals(
+               self::assertEquals(
                        [
                                '$result' => [
                                        'result'  => 'error',
@@ -3012,7 +3003,7 @@ class ApiTest extends FixtureTest
                $_REQUEST['page']   = -1;
                $_REQUEST['max_id'] = 10;
                $result             = api_direct_messages_box('json', 'sentbox', 'false');
-               $this->assertArrayHasKey('direct_message', $result);
+               self::assertArrayHasKey('direct_message', $result);
        }
 
        /**
@@ -3023,7 +3014,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesBoxWithConversation()
        {
                $result = api_direct_messages_box('json', 'conversation', 'false');
-               $this->assertArrayHasKey('direct_message', $result);
+               self::assertArrayHasKey('direct_message', $result);
        }
 
        /**
@@ -3034,7 +3025,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesBoxWithAll()
        {
                $result = api_direct_messages_box('json', 'all', 'false');
-               $this->assertArrayHasKey('direct_message', $result);
+               self::assertArrayHasKey('direct_message', $result);
        }
 
        /**
@@ -3045,7 +3036,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesBoxWithInbox()
        {
                $result = api_direct_messages_box('json', 'inbox', 'false');
-               $this->assertArrayHasKey('direct_message', $result);
+               self::assertArrayHasKey('direct_message', $result);
        }
 
        /**
@@ -3056,7 +3047,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesBoxWithVerbose()
        {
                $result = api_direct_messages_box('json', 'sentbox', 'true');
-               $this->assertEquals(
+               self::assertEquals(
                        [
                                '$result' => [
                                        'result'  => 'error',
@@ -3075,17 +3066,17 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesBoxWithRss()
        {
                $result = api_direct_messages_box('rss', 'sentbox', 'false');
-               $this->assertXml($result, 'direct-messages');
+               self::assertXml($result, 'direct-messages');
        }
 
        /**
         * Test the api_direct_messages_box() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiDirectMessagesBoxWithUnallowedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
                api_direct_messages_box('json', 'sentbox', 'false');
@@ -3099,7 +3090,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesSentbox()
        {
                $result = api_direct_messages_sentbox('json');
-               $this->assertArrayHasKey('direct_message', $result);
+               self::assertArrayHasKey('direct_message', $result);
        }
 
        /**
@@ -3110,7 +3101,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesInbox()
        {
                $result = api_direct_messages_inbox('json');
-               $this->assertArrayHasKey('direct_message', $result);
+               self::assertArrayHasKey('direct_message', $result);
        }
 
        /**
@@ -3121,7 +3112,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesAll()
        {
                $result = api_direct_messages_all('json');
-               $this->assertArrayHasKey('direct_message', $result);
+               self::assertArrayHasKey('direct_message', $result);
        }
 
        /**
@@ -3132,7 +3123,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesConversation()
        {
                $result = api_direct_messages_conversation('json');
-               $this->assertArrayHasKey('direct_message', $result);
+               self::assertArrayHasKey('direct_message', $result);
        }
 
        /**
@@ -3159,10 +3150,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photoalbum_delete() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoalbumDelete()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_fr_photoalbum_delete('json');
        }
 
@@ -3170,10 +3161,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photoalbum_delete() function with an album name.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoalbumDeleteWithAlbum()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $_REQUEST['album'] = 'album_name';
                api_fr_photoalbum_delete('json');
        }
@@ -3192,10 +3183,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photoalbum_delete() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoalbumUpdate()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_fr_photoalbum_update('json');
        }
 
@@ -3203,10 +3194,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photoalbum_delete() function with an album name.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoalbumUpdateWithAlbum()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $_REQUEST['album'] = 'album_name';
                api_fr_photoalbum_update('json');
        }
@@ -3215,10 +3206,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photoalbum_delete() function with an album name.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoalbumUpdateWithAlbumAndNewAlbum()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $_REQUEST['album']     = 'album_name';
                $_REQUEST['album_new'] = 'album_name';
                api_fr_photoalbum_update('json');
@@ -3228,10 +3219,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photoalbum_update() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFrPhotoalbumUpdateWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_fr_photoalbum_update('json');
        }
@@ -3254,29 +3245,27 @@ class ApiTest extends FixtureTest
        public function testApiFrPhotosList()
        {
                $result = api_fr_photos_list('json');
-               $this->assertArrayHasKey('photo', $result);
+               self::assertArrayHasKey('photo', $result);
        }
 
        /**
         * Test the api_fr_photos_list() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFrPhotosListWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_fr_photos_list('json');
        }
 
        /**
         * Test the api_fr_photo_create_update() function.
-        *
-        * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoCreateUpdate()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_fr_photo_create_update('json');
        }
 
@@ -3284,10 +3273,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photo_create_update() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_fr_photo_create_update('json');
        }
@@ -3296,10 +3285,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photo_create_update() function with an album name.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoCreateUpdateWithAlbum()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $_REQUEST['album'] = 'album_name';
                api_fr_photo_create_update('json');
        }
@@ -3328,10 +3317,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photo_delete() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoDelete()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_fr_photo_delete('json');
        }
 
@@ -3339,10 +3328,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photo_delete() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFrPhotoDeleteWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_fr_photo_delete('json');
        }
@@ -3351,10 +3340,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photo_delete() function with a photo ID.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoDeleteWithPhotoId()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $_REQUEST['photo_id'] = 1;
                api_fr_photo_delete('json');
        }
@@ -3373,10 +3362,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photo_detail() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFrPhotoDetail()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_fr_photo_detail('json');
        }
 
@@ -3384,10 +3373,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photo_detail() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFrPhotoDetailWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_fr_photo_detail('json');
        }
@@ -3396,10 +3385,10 @@ class ApiTest extends FixtureTest
         * Test the api_fr_photo_detail() function with a photo ID.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\NotFoundException
         */
        public function testApiFrPhotoDetailWithPhotoId()
        {
+               $this->expectException(\Friendica\Network\HTTPException\NotFoundException::class);
                $_REQUEST['photo_id'] = 1;
                api_fr_photo_detail('json');
        }
@@ -3418,10 +3407,10 @@ class ApiTest extends FixtureTest
         * Test the api_account_update_profile_image() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiAccountUpdateProfileImage()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_account_update_profile_image('json');
        }
 
@@ -3429,10 +3418,10 @@ class ApiTest extends FixtureTest
         * Test the api_account_update_profile_image() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_account_update_profile_image('json');
        }
@@ -3441,10 +3430,10 @@ class ApiTest extends FixtureTest
         * Test the api_account_update_profile_image() function with an uploaded file.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiAccountUpdateProfileImageWithUpload()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $this->markTestIncomplete();
        }
 
@@ -3460,12 +3449,12 @@ class ApiTest extends FixtureTest
                $_POST['description'] = 'new_description';
                $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']);
-               $this->assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
-               $this->assertEquals('dfrn', $result['user']['network']);
-               $this->assertEquals('new_name', $result['user']['name']);
-               $this->assertEquals('new_description', $result['user']['description']);
+               self::assertEquals($this->selfUser['id'], $result['user']['cid']);
+               self::assertEquals('DFRN', $result['user']['location']);
+               self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
+               self::assertEquals('dfrn', $result['user']['network']);
+               self::assertEquals('new_name', $result['user']['name']);
+               self::assertEquals('new_description', $result['user']['description']);
        }
 
        /**
@@ -3477,7 +3466,7 @@ class ApiTest extends FixtureTest
        {
                $result = check_acl_input('<aclstring>');
                // Where does this result come from?
-               $this->assertEquals(1, $result);
+               self::assertEquals(1, $result);
        }
 
        /**
@@ -3488,7 +3477,7 @@ class ApiTest extends FixtureTest
        public function testCheckAclInputWithEmptyAclString()
        {
                $result = check_acl_input(' ');
-               $this->assertFalse($result);
+               self::assertFalse($result);
        }
 
        /**
@@ -3521,43 +3510,6 @@ class ApiTest extends FixtureTest
                $this->markTestIncomplete();
        }
 
-       /**
-        * Test the api_friendica_remoteauth() function.
-        *
-        * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
-        */
-       public function testApiFriendicaRemoteauth()
-       {
-               api_friendica_remoteauth();
-       }
-
-       /**
-        * Test the api_friendica_remoteauth() function with an URL.
-        *
-        * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
-        */
-       public function testApiFriendicaRemoteauthWithUrl()
-       {
-               $_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['c_url'] = $this->selfUser['nurl'];
-               api_friendica_remoteauth();
-       }
-
        /**
         * Test the api_share_as_retweet() function.
         *
@@ -3567,7 +3519,7 @@ class ApiTest extends FixtureTest
        {
                $item   = ['body' => '', 'author-id' => 1, 'owner-id' => 1];
                $result = api_share_as_retweet($item);
-               $this->assertFalse($result);
+               self::assertFalse($result);
        }
 
        /**
@@ -3588,11 +3540,11 @@ class ApiTest extends FixtureTest
        public function testApiInReplyTo()
        {
                $result = api_in_reply_to(['id' => 0, 'parent' => 0, 'uri' => '', 'thr-parent' => '']);
-               $this->assertArrayHasKey('status_id', $result);
-               $this->assertArrayHasKey('user_id', $result);
-               $this->assertArrayHasKey('status_id_str', $result);
-               $this->assertArrayHasKey('user_id_str', $result);
-               $this->assertArrayHasKey('screen_name', $result);
+               self::assertArrayHasKey('status_id', $result);
+               self::assertArrayHasKey('user_id', $result);
+               self::assertArrayHasKey('status_id_str', $result);
+               self::assertArrayHasKey('user_id_str', $result);
+               self::assertArrayHasKey('screen_name', $result);
        }
 
        /**
@@ -3614,7 +3566,7 @@ class ApiTest extends FixtureTest
        {
                $_REQUEST['include_entities'] = 'true';
                $result                       = api_clean_plain_items('some_text [url="some_url"]some_text[/url]');
-               $this->assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
+               self::assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
        }
 
        /**
@@ -3626,7 +3578,7 @@ class ApiTest extends FixtureTest
        {
                $contacts = [];
                $result   = api_best_nickname($contacts);
-               $this->assertNull($result);
+               self::assertNull($result);
        }
 
        /**
@@ -3733,10 +3685,10 @@ class ApiTest extends FixtureTest
         * Test the api_friendica_notification() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFriendicaNotification()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_friendica_notification('json');
        }
 
@@ -3744,10 +3696,10 @@ class ApiTest extends FixtureTest
         * Test the api_friendica_notification() function without an authenticated user.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
         */
        public function testApiFriendicaNotificationWithoutAuthenticatedUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['authenticated'] = false;
                api_friendica_notification('json');
        }
@@ -3759,11 +3711,10 @@ class ApiTest extends FixtureTest
         */
        public function testApiFriendicaNotificationWithEmptyResult()
        {
-               $this->app->argv = ['api', 'friendica', 'notification'];
-               $this->app->argc = count($this->app->argv);
+               DI::args()->setArgv(['api', 'friendica', 'notification']);
                $_SESSION['uid'] = 41;
                $result          = api_friendica_notification('json');
-               $this->assertEquals(['note' => false], $result);
+               self::assertEquals(['note' => false], $result);
        }
 
        /**
@@ -3773,17 +3724,16 @@ class ApiTest extends FixtureTest
         */
        public function testApiFriendicaNotificationWithXmlResult()
        {
-               $this->app->argv = ['api', 'friendica', 'notification'];
-               $this->app->argc = count($this->app->argv);
-               $result          = api_friendica_notification('xml');
+               DI::args()->setArgv(['api', 'friendica', 'notification']);
+               $result  = api_friendica_notification('xml');
                $dateRel = Temporal::getRelativeDate('2020-01-01 12:12:02');
                $assertXml=<<<XML
 <?xml version="1.0"?>
 <notes>
-  <note id="1" hash="" type="8" name="Reply to" url="http://localhost/display/1" photo="http://localhost/" date="2020-01-01 12:12:02" msg="A test reply from an item" uid="42" uri-id="" link="http://localhost/notification/1" iid="4" parent="0" parent-uri-id="" seen="0" verb="" otype="item" name_cache="Reply to" msg_cache="A test reply from an item" timestamp="1577880722" date_rel="{$dateRel}" msg_html="A test reply from an item" msg_plain="A test reply from an item"/>
+  <note id="1" hash="" type="8" name="Reply to" url="http://localhost/display/1" photo="http://localhost/" date="2020-01-01 12:12:02" msg="A test reply from an item" uid="42" uri-id="" link="http://localhost/notification/1" iid="4" parent="" parent-uri-id="" seen="0" verb="" otype="item" name_cache="Reply to" msg_cache="A test reply from an item" timestamp="1577880722" date_rel="{$dateRel}" msg_html="A test reply from an item" msg_plain="A test reply from an item"/>
 </notes>
 XML;
-               $this->assertXmlStringEqualsXmlString($assertXml, $result);
+               self::assertXmlStringEqualsXmlString($assertXml, $result);
        }
 
        /**
@@ -3793,10 +3743,9 @@ XML;
         */
        public function testApiFriendicaNotificationWithJsonResult()
        {
-               $this->app->argv = ['api', 'friendica', 'notification'];
-               $this->app->argc = count($this->app->argv);
-               $result          = json_encode(api_friendica_notification('json'));
-               $this->assertJson($result);
+               DI::args()->setArgv(['api', 'friendica', 'notification']);
+               $result = json_encode(api_friendica_notification('json'));
+               self::assertJson($result);
        }
 
        /**
@@ -3837,9 +3786,9 @@ XML;
        public function testApiSavedSearchesList()
        {
                $result = api_saved_searches_list('json');
-               $this->assertEquals(1, $result['terms'][0]['id']);
-               $this->assertEquals(1, $result['terms'][0]['id_str']);
-               $this->assertEquals('Saved search', $result['terms'][0]['name']);
-               $this->assertEquals('Saved search', $result['terms'][0]['query']);
+               self::assertEquals(1, $result['terms'][0]['id']);
+               self::assertEquals(1, $result['terms'][0]['id_str']);
+               self::assertEquals('Saved search', $result['terms'][0]['name']);
+               self::assertEquals('Saved search', $result['terms'][0]['query']);
        }
 }