]> git.mxchange.org Git - friendica.git/blobdiff - tests/legacy/ApiTest.php
Replace `assertContains()` for string assertions
[friendica.git] / tests / legacy / ApiTest.php
index 265f502f0aae3c7283e868a16c89152ac1ed6a63..837b7409b061aea9400a5213bb11d1b2e449420b 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 = [];
@@ -108,10 +110,6 @@ class ApiTest extends FixtureTest
                        'authenticated' => true,
                        'uid'           => $this->selfUser['id']
                ];
-
-               $_POST   = [];
-               $_GET    = [];
-               $_SERVER = [];
        }
 
        /**
@@ -140,7 +138,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 +155,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::assertInternalType('string', $status['text'] ?? '');
+               self::assertInternalType('int', $status['id'] ?? '');
                // We could probably do more checks here.
        }
 
@@ -171,7 +169,7 @@ 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']);
@@ -188,10 +186,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 +300,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 +347,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 +361,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 +405,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCall()
        {
@@ -431,8 +432,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with the profiled enabled.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithProfiler()
        {
@@ -468,8 +469,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function without any result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithNoResult()
        {
@@ -494,8 +495,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an unimplemented API.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithUninplementedApi()
        {
@@ -508,8 +509,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with a JSON result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithJson()
        {
@@ -534,8 +535,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an XML result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithXml()
        {
@@ -560,8 +561,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an RSS result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithRss()
        {
@@ -587,8 +588,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an Atom result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithAtom()
        {
@@ -614,8 +615,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an unallowed method.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithWrongMethod()
        {
@@ -635,8 +636,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_call() function with an unauthorized user.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiCallWithWrongAuth()
        {
@@ -660,8 +661,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with a JSON result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithJson()
        {
@@ -674,8 +675,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an XML result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithXml()
        {
@@ -695,8 +696,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an RSS result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithRss()
        {
@@ -716,8 +717,8 @@ class ApiTest extends FixtureTest
        /**
         * Test the api_error() function with an Atom result.
         *
-        * @return void
         * @runInSeparateProcess
+        * @preserveGlobalState disabled
         */
        public function testApiErrorWithAtom()
        {
@@ -859,8 +860,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 +886,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));
        }
@@ -954,10 +955,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 +1151,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');
        }
@@ -1220,10 +1221,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 +1273,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 +1313,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 +1326,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 +1338,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,
@@ -1462,10 +1463,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 +1474,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 +1505,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 +1521,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 +1537,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 +1551,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 +1574,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 +1587,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 +1630,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 +1701,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 +1755,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 +1779,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');
        }
 
@@ -1819,10 +1818,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 +1831,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');
        }
 
@@ -1860,10 +1859,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 +1872,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 +1883,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');
        }
@@ -1913,10 +1912,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 +1923,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');
        }
@@ -1974,10 +1973,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 +2040,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,10 +2053,10 @@ class ApiTest extends FixtureTest
         * Test the api_favorites_create_destroy() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFavoritesCreateDestroy()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $this->app->argv = ['api', '1.1', 'favorites', 'create'];
                $this->app->argc = count($this->app->argv);
                api_favorites_create_destroy('json');
@@ -2067,10 +2066,10 @@ 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->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $this->app->argv = ['api', '1.1', 'favorites', 'create', '12.json'];
                $this->app->argc = count($this->app->argv);
                api_favorites_create_destroy('json');
@@ -2080,10 +2079,10 @@ 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->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $this->app->argv = ['api', '1.1', 'favorites', 'change.json'];
                $this->app->argc = count($this->app->argv);
                $_REQUEST['id']  = 1;
@@ -2136,10 +2135,10 @@ 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->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $this->app->argv           = ['api', '1.1', 'favorites', 'create.json'];
                $this->app->argc           = count($this->app->argv);
                $_SESSION['authenticated'] = false;
@@ -2176,10 +2175,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');
@@ -2474,8 +2473,7 @@ class ApiTest extends FixtureTest
 
        /**
         * Test the api_format_items() function.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiFormatItems()
        {
@@ -2500,8 +2498,7 @@ class ApiTest extends FixtureTest
 
        /**
         * Test the api_format_items() function with an XML result.
-        *
-        * @return void
+        * @doesNotPerformAssertions
         */
        public function testApiFormatItemsWithXml()
        {
@@ -2596,10 +2593,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 +2604,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 +2643,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 +2842,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');
        }
@@ -2878,7 +2874,7 @@ class ApiTest extends FixtureTest
                $_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']);
        }
@@ -2895,8 +2891,8 @@ class ApiTest extends FixtureTest
                $_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']);
        }
@@ -2919,10 +2915,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 +2946,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 +2958,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 +3078,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 +3155,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 +3166,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 +3188,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 +3199,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 +3211,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 +3224,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 +3257,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 +3278,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 +3290,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 +3322,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 +3333,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 +3345,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 +3367,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 +3378,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 +3390,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 +3412,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 +3423,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 +3435,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();
        }
 
@@ -3525,10 +3519,10 @@ class ApiTest extends FixtureTest
         * Test the api_friendica_remoteauth() function.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFriendicaRemoteauth()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                api_friendica_remoteauth();
        }
 
@@ -3536,10 +3530,10 @@ class ApiTest extends FixtureTest
         * Test the api_friendica_remoteauth() function with an URL.
         *
         * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
         */
        public function testApiFriendicaRemoteauthWithUrl()
        {
+               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
                $_GET['url']   = 'url';
                $_GET['c_url'] = 'url';
                api_friendica_remoteauth();
@@ -3733,10 +3727,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 +3738,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');
        }