]> git.mxchange.org Git - friendica.git/commitdiff
Reenable Followers&Friends Lists and fixes a array_reverse() Bug
authorPhilipp <admin@philipp.info>
Sat, 4 Dec 2021 22:29:29 +0000 (23:29 +0100)
committerPhilipp <admin@philipp.info>
Sun, 5 Dec 2021 19:34:00 +0000 (20:34 +0100)
src/Module/Api/Twitter/Followers/Lists.php
src/Module/Api/Twitter/Friends/Lists.php
tests/src/Module/Api/Twitter/Followers/ListsTest.php
tests/src/Module/Api/Twitter/Friends/ListsTest.php

index 5f6696341d8bc1437b924c4672aa3d970d120967..1982d921be4b080337e2db1cc60de895ebad47a2 100644 (file)
@@ -92,6 +92,6 @@ class Lists extends ContactEndpoint
 
                self::setLinkHeader();
 
-               System::jsonExit($return);
+               $this->response->exit('lists', ['lists' => $return]);
        }
 }
index 7b38ed3668b0a7aa109d976a264016797e397384..16947d0721ed62c17e50d5cf5b0c50b9ed3742a6 100644 (file)
@@ -92,6 +92,6 @@ class Lists extends ContactEndpoint
 
                self::setLinkHeader();
 
-               System::jsonExit($return);
+               $this->response->exit('lists', ['lists' => $return]);
        }
 }
index 20082279511c540dd705312ca3909567fd783fac..c1e053e5a1a6f038f5d153381883384b7f675ead 100644 (file)
@@ -2,30 +2,28 @@
 
 namespace Friendica\Test\src\Module\Api\Twitter\Followers;
 
+use Friendica\App\Router;
+use Friendica\DI;
+use Friendica\Module\Api\Twitter\Followers\Lists;
 use Friendica\Test\src\Module\Api\ApiTest;
 
 class ListsTest extends ApiTest
 {
        /**
         * Test the api_statuses_f() function.
-        *
-        * @return void
         */
        public function testApiStatusesFWithFollowers()
        {
-               // $result = api_statuses_f('followers');
-               // self::assertArrayHasKey('user', $result);
-       }
+               $lists    = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
+               $response = $lists->run();
 
-       /**
-        * Test the api_statuses_followers() function.
-        *
-        * @return void
-        */
-       public function testApiStatusesFollowers()
-       {
-               // $result = api_statuses_followers('json');
-               // self::assertArrayHasKey('user', $result);
+               $body = (string)$response->getBody();
+
+               self::assertJson($body);
+
+               $json = json_decode($body);
+
+               self::assertIsArray($json->users);
        }
 
        /**
@@ -35,6 +33,8 @@ class ListsTest extends ApiTest
         */
        public function testApiStatusesFollowersWithUndefinedCursor()
        {
+               self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
+
                // $_GET['cursor'] = 'undefined';
                // self::assertFalse(api_statuses_followers('json'));
        }
index c4c48daced85e762e915b7b2a931f03a64478fec..fbc5868424c2a20f00106f5348041e721e8dded8 100644 (file)
@@ -2,6 +2,9 @@
 
 namespace Friendica\Test\src\Module\Api\Twitter\Friends;
 
+use Friendica\App\Router;
+use Friendica\DI;
+use Friendica\Module\Api\Twitter\Friends\Lists;
 use Friendica\Test\src\Module\Api\ApiTest;
 
 class ListsTest extends ApiTest
@@ -13,7 +16,17 @@ class ListsTest extends ApiTest
         */
        public function testApiStatusesFWithFriends()
        {
-               // $_GET['page'] = -1;
+               $lists    = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
+               $response = $lists->run();
+
+               $body = (string)$response->getBody();
+
+               self::assertJson($body);
+
+               $json = json_decode($body);
+
+               self::assertIsArray($json->users);
+
                // $result       = api_statuses_f('friends');
                // self::assertArrayHasKey('user', $result);
        }
@@ -25,29 +38,9 @@ class ListsTest extends ApiTest
         */
        public function testApiStatusesFWithUndefinedCursor()
        {
-               // $_GET['cursor'] = 'undefined';
-               // self::assertFalse(api_statuses_f('friends'));
-       }
-
-       /**
-        * Test the api_statuses_friends() function.
-        *
-        * @return void
-        */
-       public function testApiStatusesFriends()
-       {
-               // $result = api_statuses_friends('json');
-               // self::assertArrayHasKey('user', $result);
-       }
+               self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
 
-       /**
-        * Test the api_statuses_friends() function an undefined cursor GET variable.
-        *
-        * @return void
-        */
-       public function testApiStatusesFriendsWithUndefinedCursor()
-       {
                // $_GET['cursor'] = 'undefined';
-               // self::assertFalse(api_statuses_friends('json'));
+               // self::assertFalse(api_statuses_f('friends'));
        }
 }