]> git.mxchange.org Git - friendica.git/blobdiff - tests/legacy/ApiTest.php
api_get_user isn't used without parameters anymore
[friendica.git] / tests / legacy / ApiTest.php
index e2224a19a178c971183c20a27fcd0cec3c39d303..34f3f6659b519964db1c3e22a0a2c4a3a1d006a1 100644 (file)
@@ -224,7 +224,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiUser()
        {
-               self::assertEquals($this->selfUser['id'], api_user());
+               self::assertEquals($this->selfUser['id'], BaseApi::getCurrentUserID());
        }
 
        /**
@@ -311,6 +311,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiLoginWithoutLogin()
        {
+               BasicAuth::setCurrentUserID();
                $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
                BasicAuth::getCurrentUserID(true);
        }
@@ -324,6 +325,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiLoginWithBadLogin()
        {
+               BasicAuth::setCurrentUserID();
                $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
                $_SERVER['PHP_AUTH_USER'] = 'user@server';
                BasicAuth::getCurrentUserID(true);
@@ -358,6 +360,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiLoginWithCorrectLogin()
        {
+               BasicAuth::setCurrentUserID();
                $_SERVER['PHP_AUTH_USER'] = 'Test user';
                $_SERVER['PHP_AUTH_PW']   = 'password';
                BasicAuth::getCurrentUserID(true);
@@ -371,6 +374,7 @@ class ApiTest extends FixtureTest
         */
        public function testApiLoginWithRemoteUser()
        {
+               BasicAuth::setCurrentUserID();
                $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
                $_SERVER['REDIRECT_REMOTE_USER'] = '123456dXNlcjpwYXNzd29yZA==';
                BasicAuth::getCurrentUserID(true);
@@ -641,8 +645,8 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUser()
        {
-               $user = api_get_user();
-               self::assertSelfUser($user);
+               // $user = api_get_user();
+               // self::assertSelfUser($user);
                // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
                // self::assertEquals('6fdbe8', $user['profile_link_color']);
                // self::assertEquals('ededed', $user['profile_background_color']);
@@ -655,10 +659,10 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithFrioSchema()
        {
-               $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
-               $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
-               $user = api_get_user();
-               self::assertSelfUser($user);
+               // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
+               // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
+               // $user = api_get_user();
+               // self::assertSelfUser($user);
                // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
                // self::assertEquals('6fdbe8', $user['profile_link_color']);
                // self::assertEquals('ededed', $user['profile_background_color']);
@@ -671,10 +675,10 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithEmptyFrioSchema()
        {
-               $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
-               $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
-               $user = api_get_user();
-               self::assertSelfUser($user);
+               // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
+               // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
+               // $user = api_get_user();
+               // self::assertSelfUser($user);
                // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']);
                // self::assertEquals('6fdbe8', $user['profile_link_color']);
                // self::assertEquals('ededed', $user['profile_background_color']);
@@ -687,13 +691,13 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithCustomFrioSchema()
        {
-               $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
-               $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
-               $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
-               $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
-               $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
-               $user = api_get_user();
-               self::assertSelfUser($user);
+               // $pConfig = $this->dice->create(IManagePersonalConfigValues::class);
+               // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
+               // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
+               // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
+               // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456');
+               // $user = api_get_user();
+               // self::assertSelfUser($user);
                // self::assertEquals('123456', $user['profile_sidebar_fill_color']);
                // self::assertEquals('123456', $user['profile_link_color']);
                // self::assertEquals('123456', $user['profile_background_color']);
@@ -707,10 +711,14 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithoutApiUser()
        {
+               // api_get_user() with empty parameters is not used anymore
+               /*
                $_SERVER['PHP_AUTH_USER'] = 'Test user';
                $_SERVER['PHP_AUTH_PW']   = 'password';
                $_SESSION['allow_api']    = false;
+               BasicAuth::setCurrentUserID();
                self::assertFalse(api_get_user());
+               */
        }
 
        /**
@@ -720,8 +728,8 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithGetId()
        {
-               $_GET['user_id'] = $this->otherUser['id'];
-               self::assertOtherUser(api_get_user());
+               // $_GET['user_id'] = $this->otherUser['id'];
+               // self::assertOtherUser(api_get_user());
        }
 
        /**
@@ -731,9 +739,9 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithWrongGetId()
        {
-               $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
-               $_GET['user_id'] = $this->wrongUserId;
-               self::assertOtherUser(api_get_user());
+               // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
+               // $_GET['user_id'] = $this->wrongUserId;
+               // self::assertOtherUser(api_get_user());
        }
 
        /**
@@ -743,8 +751,8 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithGetName()
        {
-               $_GET['screen_name'] = $this->selfUser['nick'];
-               self::assertSelfUser(api_get_user());
+               // $_GET['screen_name'] = $this->selfUser['nick'];
+               // self::assertSelfUser(api_get_user());
        }
 
        /**
@@ -754,8 +762,8 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithGetUrl()
        {
-               $_GET['profileurl'] = $this->selfUser['nurl'];
-               self::assertSelfUser(api_get_user());
+               // $_GET['profileurl'] = $this->selfUser['nurl'];
+               // self::assertSelfUser(api_get_user());
        }
 
        /**
@@ -765,10 +773,10 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithNumericCalledApi()
        {
-               global $called_api;
-               $called_api         = ['api_path'];
-               DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
-               self::assertOtherUser(api_get_user());
+               // global $called_api;
+               // $called_api         = ['api_path'];
+               // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
+               // self::assertOtherUser(api_get_user());
        }
 
        /**
@@ -778,9 +786,9 @@ class ApiTest extends FixtureTest
         */
        public function testApiGetUserWithCalledApi()
        {
-               global $called_api;
-               $called_api = ['api', 'api_path'];
-               self::assertSelfUser(api_get_user());
+               // global $called_api;
+               // $called_api = ['api', 'api_path'];
+               // self::assertSelfUser(api_get_user());
        }
 
        /**
@@ -997,6 +1005,7 @@ class ApiTest extends FixtureTest
        public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_account_verify_credentials('json');
        }
@@ -1067,8 +1076,8 @@ class ApiTest extends FixtureTest
        public function testApiStatusesMediapWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
-               $_SESSION['authenticated'] = false;
                BasicAuth::setCurrentUserID();
+               $_SESSION['authenticated'] = false;
                api_statuses_mediap('json');
        }
 
@@ -1120,6 +1129,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesUpdateWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_statuses_update('json');
        }
@@ -1173,6 +1183,7 @@ class ApiTest extends FixtureTest
        public function testApiMediaUploadWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_media_upload();
        }
@@ -1423,6 +1434,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_search('json');
        }
 
@@ -1479,6 +1491,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_statuses_home_timeline('json');
        }
 
@@ -1550,6 +1563,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_statuses_public_timeline('json');
        }
 
@@ -1604,6 +1618,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_statuses_networkpublic_timeline('json');
        }
 
@@ -1667,6 +1682,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_statuses_show('json');
        }
 
@@ -1708,6 +1724,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_conversation_show('json');
        }
 
@@ -1730,6 +1747,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesRepeatWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_statuses_repeat('json');
        }
@@ -1770,6 +1788,7 @@ class ApiTest extends FixtureTest
        public function testApiStatusesDestroyWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_statuses_destroy('json');
        }
@@ -1822,6 +1841,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_statuses_mentions('json');
        }
 
@@ -1889,6 +1909,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_statuses_user_timeline('json');
        }
 
@@ -1977,6 +1998,7 @@ class ApiTest extends FixtureTest
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_favorites_create_destroy('json');
        }
@@ -2017,6 +2039,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_favorites('json');
        }
 
@@ -2390,6 +2413,7 @@ class ApiTest extends FixtureTest
        public function testApiListsOwnershipsWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_lists_ownerships('json');
        }
@@ -2442,6 +2466,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_lists_statuses('json');
        }
 
@@ -2630,6 +2655,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesNewWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_direct_messages_new('json');
        }
@@ -2734,6 +2760,7 @@ class ApiTest extends FixtureTest
        public function testApiDirectMessagesDestroyWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_direct_messages_destroy('json');
        }
@@ -2868,6 +2895,7 @@ class ApiTest extends FixtureTest
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
                $_SESSION['allow_api'] = false;
                $_GET['screen_name']   = $this->selfUser['nick'];
+               BasicAuth::setCurrentUserID();
                api_direct_messages_box('json', 'sentbox', 'false');
        }
 
@@ -2954,6 +2982,7 @@ class ApiTest extends FixtureTest
        public function testApiFrPhotosListWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_fr_photos_list('json');
        }
@@ -2975,6 +3004,7 @@ class ApiTest extends FixtureTest
        public function testApiFrPhotoCreateUpdateWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_fr_photo_create_update('json');
        }
@@ -3030,6 +3060,7 @@ class ApiTest extends FixtureTest
        public function testApiFrPhotoDetailWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_fr_photo_detail('json');
        }
@@ -3075,6 +3106,7 @@ class ApiTest extends FixtureTest
        public function testApiAccountUpdateProfileImageWithoutAuthenticatedUser()
        {
                $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
+               BasicAuth::setCurrentUserID();
                $_SESSION['authenticated'] = false;
                api_account_update_profile_image('json');
        }