]> 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 265f502f0aae3c7283e868a16c89152ac1ed6a63..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 = [];
        }
 
        /**
@@ -140,7 +137,7 @@ class ApiTest extends FixtureTest
         *
         * @return void
         */
-       private function assertOtherUser(array $user)
+       private function assertOtherUser(array $user = [])
        {
                self::assertEquals($this->otherUser['id'], $user['id']);
                self::assertEquals($this->otherUser['id'], $user['id_str']);
@@ -157,10 +154,10 @@ class ApiTest extends FixtureTest
         *
         * @return void
         */
-       private function assertStatus(array $status)
+       private function assertStatus(array $status = [])
        {
-               self::assertInternalType('string', $status['text']);
-               self::assertInternalType('int', $status['id']);
+               self::assertIsString($status['text'] ?? '');
+               self::assertIsInt($status['id'] ?? '');
                // We could probably do more checks here.
        }
 
@@ -171,11 +168,11 @@ class ApiTest extends FixtureTest
         *
         * @return void
         */
-       private function assertList(array $list)
+       private function assertList(array $list = [])
        {
-               self::assertInternalType('string', $list['name']);
-               self::assertInternalType('int', $list['id']);
-               self::assertInternalType('string', $list['id_str']);
+               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 = '')
        {
                self::assertStringStartsWith('<?xml version="1.0"?>', $result);
-               self::assertContains('<' . $root_element, $result);
+               self::assertStringContainsString('<' . $root_element, $result);
                // We could probably do more checks here.
        }
 
@@ -302,24 +299,26 @@ class ApiTest extends FixtureTest
        /**
         * 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);
        }
@@ -404,8 +404,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCall()
        {
@@ -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()
        {
@@ -468,8 +468,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function without any result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithNoResult()
        {
@@ -494,8 +494,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an unimplemented API.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithUninplementedApi()
        {
@@ -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()
        {
@@ -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()
        {
@@ -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()
        {
@@ -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()
        {
@@ -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()
        {
@@ -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()
        {
@@ -660,8 +660,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with a JSON result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithJson()
        {
@@ -674,8 +674,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an XML result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithXml()
        {
@@ -695,8 +695,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an RSS result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithRss()
        {
@@ -716,8 +716,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an Atom result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithAtom()
        {
@@ -761,7 +761,7 @@ class ApiTest extends FixtureTest
        public function testApiRssExtraWithoutUserInfo()
        {
                $result = api_rss_extra($this->app, [], null);
-               self::assertInternalType('array', $result['$user']);
+               self::assertIsArray($result['$user']);
                self::assertArrayHasKey('alternate', $result['$rss']);
                self::assertArrayHasKey('self', $result['$rss']);
                self::assertArrayHasKey('base', $result['$rss']);
@@ -859,8 +859,8 @@ class ApiTest extends FixtureTest
        /**
         * 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()
        {
@@ -885,10 +885,10 @@ class ApiTest extends FixtureTest
         * 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;
                self::assertOtherUser(api_get_user($this->app));
        }
@@ -924,7 +924,7 @@ class ApiTest extends FixtureTest
        {
                global $called_api;
                $called_api         = ['api_path'];
-               $this->app->argv[1] = $this->otherUser['id'] . '.json';
+               DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
                self::assertOtherUser(api_get_user($this->app));
        }
 
@@ -954,10 +954,10 @@ class ApiTest extends FixtureTest
         * Test the api_get_user() function with a wrong user ID.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiGetUserWithWrongUser()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                self::assertOtherUser(api_get_user($this->app, $this->wrongUserId));
        }
 
@@ -1150,10 +1150,10 @@ class ApiTest extends FixtureTest
         * 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');
        }
@@ -1197,7 +1197,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesMediap()
        {
-               $this->app->argc = 2;
+               DI::args()->setArgc(2);
 
                $_FILES         = [
                        'media' => [
@@ -1220,10 +1220,10 @@ class ApiTest extends FixtureTest
         * 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');
        }
@@ -1272,10 +1272,10 @@ class ApiTest extends FixtureTest
         * 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,7 +1369,7 @@ class ApiTest extends FixtureTest
                        ]
                ];
                $app       = DI::app();
-               $app->argc = 2;
+               DI::args()->setArgc(2);
 
                $result = api_media_upload();
                self::assertEquals('image/png', $result['media']['image']['image_type']);
@@ -1462,10 +1462,10 @@ class ApiTest extends FixtureTest
         * 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');
        }
 
@@ -1504,7 +1504,7 @@ class ApiTest extends FixtureTest
                $result             = api_search('json');
                foreach ($result['status'] as $status) {
                        self::assertStatus($status);
-                       self::assertContains('reply', $status['text'], null, true);
+                       self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
                }
        }
 
@@ -1520,7 +1520,7 @@ class ApiTest extends FixtureTest
                $result            = api_search('json');
                foreach ($result['status'] as $status) {
                        self::assertStatus($status);
-                       self::assertContains('reply', $status['text'], null, true);
+                       self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
                }
        }
 
@@ -1536,14 +1536,13 @@ class ApiTest extends FixtureTest
                $result          = api_search('json');
                foreach ($result['status'] as $status) {
                        self::assertStatus($status);
-                       self::assertContains('reply', $status['text'], null, true);
+                       self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
                }
        }
 
        /**
         * Test the api_search() function with an q parameter contains hashtag.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiSearchWithHashtag()
        {
@@ -1551,14 +1550,13 @@ class ApiTest extends FixtureTest
                $result        = api_search('json');
                foreach ($result['status'] as $status) {
                        self::assertStatus($status);
-                       self::assertContains('#friendica', $status['text'], null, true);
+                       self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
                }
        }
 
        /**
         * Test the api_search() function with an exclude_replies parameter.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiSearchWithExcludeReplies()
        {
@@ -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');
        }
 
@@ -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');
@@ -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');
@@ -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');
@@ -1780,10 +1778,10 @@ class ApiTest extends FixtureTest
         * 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,8 +1792,8 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesShowWithId()
        {
-               $this->app->argv[3] = 1;
-               $result             = api_statuses_show('json');
+               DI::args()->setArgv(['', '', '', 1]);
+               $result = api_statuses_show('json');
                self::assertStatus($result['status']);
        }
 
@@ -1806,7 +1804,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesShowWithConversation()
        {
-               $this->app->argv[3]       = 1;
+               DI::args()->setArgv(['', '', '', 1]);
                $_REQUEST['conversation'] = 1;
                $result                   = api_statuses_show('json');
                self::assertNotEmpty($result['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,7 +1844,7 @@ 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');
@@ -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,13 +1897,13 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesRepeatWithId()
        {
-               $this->app->argv[3] = 1;
-               $result             = api_statuses_repeat('json');
+               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');
+               DI::args()->setArgv(['', '', '', 5]);
+               $result = api_statuses_repeat('json');
                self::assertStatus($result['status']);
        }
 
@@ -1913,10 +1911,10 @@ class ApiTest extends FixtureTest
         * 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,8 +1937,8 @@ class ApiTest extends FixtureTest
         */
        public function testApiStatusesDestroyWithId()
        {
-               $this->app->argv[3] = 1;
-               $result             = api_statuses_destroy('json');
+               DI::args()->setArgv(['', '', '', 1]);
+               $result = api_statuses_destroy('json');
                self::assertStatus($result['status']);
        }
 
@@ -1951,7 +1949,7 @@ 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');
                self::assertEmpty($result['status']);
@@ -1974,10 +1972,10 @@ class ApiTest extends FixtureTest
         * 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');
@@ -2041,10 +2039,10 @@ class ApiTest extends FixtureTest
         * 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,10 +2092,9 @@ 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');
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
+               $_REQUEST['id'] = 3;
+               $result         = api_favorites_create_destroy('json');
                self::assertStatus($result['status']);
        }
 
@@ -2111,10 +2105,9 @@ 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');
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
+               $_REQUEST['id'] = 3;
+               $result         = api_favorites_create_destroy('rss');
                self::assertXml($result, 'status');
        }
 
@@ -2125,10 +2118,9 @@ 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');
+               DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
+               $_REQUEST['id'] = 3;
+               $result         = api_favorites_create_destroy('json');
                self::assertStatus($result['status']);
        }
 
@@ -2136,12 +2128,11 @@ class ApiTest extends FixtureTest
         * 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');
        }
@@ -2176,10 +2167,10 @@ class ApiTest extends FixtureTest
         * 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,9 +2184,9 @@ 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']
                );
                self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
                self::assertEquals(1, $result['id']);
@@ -2214,9 +2205,9 @@ 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']
                );
                self::assertEquals('item_title', $result['title']);
                self::assertEquals('<strong>item_body</strong>', $result['text']);
@@ -2231,9 +2222,9 @@ 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']
                );
                self::assertEquals('item_title', $result['title']);
                self::assertEquals('item_body', $result['text']);
@@ -2248,9 +2239,9 @@ 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']
                );
                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 ' .
@@ -2309,11 +2301,12 @@ class ApiTest extends FixtureTest
                        [
                                'network' => 'feed',
                                'title'   => 'item_title',
+                               'uri-id'  => -1,
                                'body'    => '',
                                'plink'   => 'item_plink'
                        ]
                );
-               self::assertEquals('item_title', $result['text']);
+               self::assertEquals("item_title", $result['text']);
                self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
        }
 
@@ -2326,8 +2319,9 @@ 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,
                        ]
                );
                self::assertEquals('item_title item_body', $result['text']);
@@ -2342,7 +2336,7 @@ class ApiTest extends FixtureTest
        public function testApiGetAttachments()
        {
                $body = 'body';
-               self::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]';
-               self::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]';
-               self::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';
-               self::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');
-               self::assertInternalType('array', $result['hashtags']);
-               self::assertInternalType('array', $result['symbols']);
-               self::assertInternalType('array', $result['urls']);
-               self::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']);
        }
 
        /**
@@ -2474,8 +2468,7 @@ class ApiTest extends FixtureTest
 
        /**
         * Test the api_format_items() function.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiFormatItems()
        {
@@ -2500,8 +2493,7 @@ class ApiTest extends FixtureTest
 
        /**
         * Test the api_format_items() function with an XML result.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiFormatItemsWithXml()
        {
@@ -2532,7 +2524,7 @@ class ApiTest extends FixtureTest
                $result = api_account_rate_limit_status('json');
                self::assertEquals(150, $result['hash']['remaining_hits']);
                self::assertEquals(150, $result['hash']['hourly_limit']);
-               self::assertInternalType('int', $result['hash']['reset_time_in_seconds']);
+               self::assertIsInt($result['hash']['reset_time_in_seconds']);
        }
 
        /**
@@ -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()
        {
@@ -2647,10 +2638,10 @@ class ApiTest extends FixtureTest
         * 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');
@@ -2846,10 +2837,10 @@ class ApiTest extends FixtureTest
         * 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');
        }
@@ -2874,11 +2865,11 @@ 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');
-               self::assertContains('message_text', $result['direct_message']['text']);
+               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,13 +2881,13 @@ 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');
-               self::assertContains('message_text', $result['direct_message']['text']);
-               self::assertContains('message_title', $result['direct_message']['text']);
+               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,7 +2899,7 @@ 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');
@@ -2919,10 +2910,10 @@ class ApiTest extends FixtureTest
         * 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');
        }
 
@@ -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');
        }
@@ -3082,10 +3073,10 @@ class ApiTest extends FixtureTest
         * 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');
@@ -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');
        }
@@ -3261,22 +3252,20 @@ class ApiTest extends FixtureTest
         * 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();
        }
 
@@ -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.
         *
@@ -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,8 +3711,7 @@ 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');
                self::assertEquals(['note' => false], $result);
@@ -3773,9 +3724,8 @@ 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"?>
@@ -3793,9 +3743,8 @@ XML;
         */
        public function testApiFriendicaNotificationWithJsonResult()
        {
-               $this->app->argv = ['api', 'friendica', 'notification'];
-               $this->app->argc = count($this->app->argv);
-               $result          = json_encode(api_friendica_notification('json'));
+               DI::args()->setArgv(['api', 'friendica', 'notification']);
+               $result = json_encode(api_friendica_notification('json'));
                self::assertJson($result);
        }